Commit Graph

134 Commits

Author SHA1 Message Date
2c13c70e12 Update ruff to 0.12.0 (#147106) 2025-06-19 20:39:09 +02:00
f295d72cd9 Fix error stack trace for HomeAssistantError in websocket service call (#145699)
* Add test

* Fix error stack trace for HomeAssistantError in websocket service call
2025-05-27 12:54:57 +02:00
0105332476 Add WS command integration/wait (#142040)
* Add WS command integration/wait

* Add test

* Update homeassistant/components/websocket_api/commands.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Use helper setup.async_wait_component

* Add onboarding view

* Revert "Add onboarding view"

This reverts commit df3a1a0580.

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2025-04-11 16:09:15 +02:00
3fb70316da Fix error messaging for cascading service calls (#136966) 2025-01-31 11:10:57 +01:00
9dfabc3fb7 Adjust automation to plural triggers/conditions/actions keys (#123823)
* Adjust automation to plural triggers/conditions/actions keys

* Fix some tests

* Adjust websocket tests

* Fix search tests

* Convert blueprint and blueprint inputs to modern schema

* Pass schema when creating Blueprint object

* Update tests

* Adjust websocket api

---------

Co-authored-by: Joostlek <joostlek@outlook.com>
Co-authored-by: Erik <erik@montnemery.com>
2024-09-24 20:03:23 +02:00
d8161c431f Add support for using an entityfilter to subscribe_entities (#124641)
* Add support for using an entityfilter to subscribe_entities

* filter init

* fix

* coverage
2024-08-27 11:17:05 +02:00
8099ea8817 Improve WS command validate_config (#118864)
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: Robert Resch <robert@resch.dev>
2024-06-05 18:53:44 +02:00
3b4b36a9fd Fix partial typing (#118022) 2024-05-24 10:24:18 +02:00
c5cc9801a6 Cache serialize of manifest for loaded integrations (#117965)
* Cache serialize of manifest for loaded integrations

The manifest/list and manifest/get websocket apis
are called frequently when moving around in the UI.
Since the manifest does not change we can make
the the serialized version a cached property

* reduce

* reduce
2024-05-23 10:52:05 -04:00
Sid
2cc916db6d Replace pylint broad-except with Ruff BLE001 (#116250) 2024-05-07 14:00:27 +02:00
9995207817 Avoid re-encoding the message id as bytes for every event/state change (#116460) 2024-04-30 12:02:28 -05:00
ca5ed274cb Deprecate calling async_listen and async_listen_once with run_immediately (#115169) 2024-04-08 10:07:54 -10:00
0f03079065 Update import for EventStateChangedData [i-z] (#114900) 2024-04-04 11:48:29 -10:00
Sid
a5b609f081 Enable ruff TRY401 (#114395)
* Enable ruff TRY401

* fix tests
2024-03-29 07:20:36 +01:00
c615b52840 Refactor integration startup time to show wall clock time (#113707)
* Refactor setup time tracking to exclude time waiting on other operations

We now exclude the import time and th time waiting on
base platforms to setup from the setup times

* tweak

* tweak

* tweak

* tweak

* adjust

* fixes

* fixes

* preen

* preen

* tweak

* tweak

* adjust

* tweak

* reduce

* do not count integrtion platforms against their parent integration

* handle legacy tts platforms

* stt as well

* one more wait

* use the same pattern in all the legacy

* fix tts and stt legacy

* fix

* fix

* reduce

* preen

* entity comp does not wait for platforms

* scene blocks as well

* fix test

* test fixes

* coverage

* coverage

* coverage

* fix test

* Update tests/test_setup.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update tests/test_setup.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/setup.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* strip

* strip WAIT_PLATFORM_INTEGRATION

* strip WAIT_PLATFORM_INTEGRATION

* strip WAIT_PLATFORM_INTEGRATION

* strip WAIT_PLATFORM_INTEGRATION

* remove complexity

* Apply suggestions from code review

* no longer works that way

* fixes

* fixes

* fixes

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-03-18 21:45:34 -04:00
a66399ad3d Add Event typing to websocket_api for entity subscriptions (#112786) 2024-03-08 22:29:46 -05:00
3db28d46b2 Replace EventType with Event [t-z] (#112742) 2024-03-08 19:37:26 +01:00
c773d57d39 Add empty line after module docstring [w-z] (#112706) 2024-03-08 10:35:45 -05:00
def6c5c21c Refactor integration startup time tracking to reduce overhead (#110136)
* Refactor integration startup time tracking to reduce overhead

- Use monotonic time for watching integration startup time as it avoids incorrect values if time moves backwards because of ntp during startup and reduces many time conversions since we want durations in seconds and not local time

- Use loop scheduling instead of a task

- Moves all the dispatcher logic into the new _WatchPendingSetups

* websocket as well

* tweaks

* simplify logic

* preserve logic

* preserve logic

* lint

* adjust
2024-02-17 21:47:55 -05:00
9cf45882a7 Use bytes join fast path for large states payload (#110694)
b"".join has a fast path for when there are more than two bytes-strings
to combine

f383ca1a6f/Objects/stringlib/join.h (L123)
2024-02-16 07:58:11 +01:00
0b3bcca49b Avoid string decode/encode round trip in websocket_api get_services (#108632)
The cache was converting from bytes to str and when we read
the cache we converted it back to bytes again
2024-01-21 22:53:45 -05:00
60ab360fe7 Avoid bytes to string to bytes conversion in websocket api (#108139) 2024-01-16 21:37:34 +01:00
6ada825805 Use faster is_admin check for websocket state and event subscriptions (#107621) 2024-01-13 10:42:41 -10:00
24b1e01d71 Update Ruff to 0.1.8, avoid linter/formatter conflicts (#106080)
* Disable Ruff rules that may conflict with the formatter

* Upgrade Ruff to 0.1.8

- https://github.com/astral-sh/ruff/releases/tag/v0.1.7
- https://github.com/astral-sh/ruff/releases/tag/v0.1.8

* Format with Ruff 0.1.8
2023-12-20 23:55:09 +01:00
47426a3ddc Remove redundant websocket_api exception handler (#104727) 2023-11-29 16:56:26 +01:00
efd330f182 Send localization info on websocket_api script errors (#104638)
* Send localization info on script errors

* Use connection exception hander

* Keep HomeAssistantError is unknown_error

* Move specific exception handling
2023-11-29 10:47:23 +01:00
618b666126 Add support for responses to call_service WS cmd (#98610)
* Add support for responses to call_service WS cmd

* Revert ServiceNotFound removal and add a parameter for return_response

* fix type

* fix tests

* remove exception handling that was added

* Revert unnecessary modifications

* Use kwargs
2023-11-10 21:44:43 +01:00
54cf7010cd Add ServiceValidationError and translation support (#102592)
* Add ServiceValidationError

* Add translation support

* Extend translation support to HomeAssistantError

* Add translation support for ServiceNotFound exc

* Frontend translation & translation_key from caller

* Improve fallback message

* Set websocket_api as default translation_domain

* Add MQTT ServiceValidationError exception

* Follow up comments

* Revert removing gueard on translation_key

* Revert test changes to fix CI test

* Follow up comments

* Fix CI test

* Follow up

* Improve language

* Follow up comment
2023-11-06 15:45:04 +01:00
1a6184a9aa Allow non-admins to subscribe to the issue registry updated event (#103145) 2023-10-31 16:29:22 -05:00
5648dc6cd1 Reduce string copy needed to subscribe to entities (#102870) 2023-10-28 09:18:25 -05:00
009dc91b97 Fix inner callback decorators with partials (#102873) 2023-10-28 08:38:42 -05:00
93f10cdce8 Move event permissions out of the websocket api into auth (#101975) 2023-10-15 23:14:19 +02:00
547f32818c Make core States use cached_property (#100312)
Need to validate this is worth removing __slots__
2023-09-13 20:33:25 -04:00
aedd06b9a9 Tweak entity/source WS command handler (#100272) 2023-09-13 11:14:01 +02:00
51576b7214 Improve typing of entity.entity_sources (#99407)
* Improve typing of entity.entity_sources

* Calculate entity info source when generating WS response

* Adjust typing

* Update tests
2023-09-12 20:41:26 +02:00
fabb098ec3 Simplify WS command entity/source (#99439) 2023-09-12 15:39:11 +02:00
1654ef7759 Make WS command render_template not give up if initial render raises (#99808) 2023-09-08 21:02:06 +02:00
e5210c5823 Always set severity level flag on render_template error events (#99804) 2023-09-07 12:00:19 +02:00
48f7924e9e Allow specifying a custom log function for template render (#99572)
* Allow specifying a custom log function for template render

* Bypass template cache when reporting errors + fix tests

* Send errors as events

* Fix logic for creating new TemplateEnvironment

* Add strict mode back

* Only send error events if report_errors is True

* Force test of websocket_api only

* Debug test

* Run pytest with higher verbosity

* Timeout after 1 minute, enable syslog output

* Adjust timeout

* Add debug logs

* Fix unsafe call to WebSocketHandler._send_message

* Remove debug code

* Improve test coverage

* Revert accidental change

* Include severity in error events

* Remove redundant information from error events
2023-09-06 10:03:35 +02:00
7e36da4cc0 Small cleanup of WS command render_template (#99562) 2023-09-04 14:17:30 -04:00
7b1c0c2df2 Extend template entities with a script section (#96175)
* Extend template entities with a script section

This allows making a trigger entity that triggers a few times a day,
and allows collecting data from a service resopnse which can be
fed into a template entity.

The current alternatives are to publish and subscribe to events or to
store data in input entities.

* Make variables set in actions accessible to templates

* Format code

---------

Co-authored-by: Erik <erik@montnemery.com>
2023-09-02 16:19:45 -07:00
582499a260 Improve async_track_template_result callback typing (#97135) 2023-07-24 12:42:17 +02:00
78880f0c9d Fix execute device actions with WS execute_script (#95783) 2023-07-03 14:21:01 -04:00
2aff138b92 Small improvements to websocket api performance (#95693) 2023-07-02 12:33:25 -05:00
e18f7dffb0 Teach validate_config to validate lists of conditions (#95380)
* Teach validate_config to validate lists of conditions

* Update test
2023-06-27 19:44:23 +02:00
5f14cdf69d Allow stopping a script with a response value (#95284) 2023-06-27 08:24:22 +02:00
e1b7d68134 Speed up processing subscribe_events and subscribe_entites when user has read all permissions (#93611)
Speed up processing subscribe_events and subscribe_entites when user the read all permissions
2023-05-27 19:59:46 -04:00
b993fe1c9d Cache generation of the service descriptions (#93131) 2023-05-16 21:42:37 -05:00
99265a983a Speed up reconnects by caching state serialize (#93050) 2023-05-16 02:33:12 -05:00
8711735ec0 Improve websocket throughput and reduce latency (#92967) 2023-05-13 00:13:57 +09:00