Commit graph

238 commits

Author SHA1 Message Date
Ville Skyttä
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
Jan Bouwhuis
47426a3ddc
Remove redundant websocket_api exception handler (#104727) 2023-11-29 16:56:26 +01:00
Jan Bouwhuis
861bb48ab6
Assign specific error code for HomeAssistantError on websocket_api connection exceptions (#104700)
Assign specific error code for HomeAssistantError
2023-11-29 13:07:52 +01:00
Jan Bouwhuis
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
Raman Gupta
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
J. Nick Koston
da1780f9ec
Small cleanups to process_success_login (#103282) 2023-11-07 10:48:34 +01:00
Jan Bouwhuis
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
J. Nick Koston
1a6184a9aa
Allow non-admins to subscribe to the issue registry updated event (#103145) 2023-10-31 16:29:22 -05:00
J. Nick Koston
5648dc6cd1
Reduce string copy needed to subscribe to entities (#102870) 2023-10-28 09:18:25 -05:00
J. Nick Koston
009dc91b97
Fix inner callback decorators with partials (#102873) 2023-10-28 08:38:42 -05:00
J. Nick Koston
653da6e31f
Reduce websocket event and state JSON construction overhead (#101974) 2023-10-15 23:39:09 +02:00
J. Nick Koston
93f10cdce8
Move event permissions out of the websocket api into auth (#101975) 2023-10-15 23:14:19 +02:00
J. Nick Koston
547f32818c
Make core States use cached_property (#100312)
Need to validate this is worth removing __slots__
2023-09-13 20:33:25 -04:00
Erik Montnemery
aedd06b9a9
Tweak entity/source WS command handler (#100272) 2023-09-13 11:14:01 +02:00
Ville Skyttä
fa0b999d08
Upgrade ruff to 0.0.289 (#100238) 2023-09-12 22:22:10 +02:00
Erik Montnemery
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
Erik Montnemery
fabb098ec3
Simplify WS command entity/source (#99439) 2023-09-12 15:39:11 +02:00
J. Nick Koston
ad4619c038
Speed up serializing event messages (#100017) 2023-09-10 08:25:13 -05:00
Erik Montnemery
1654ef7759
Make WS command render_template not give up if initial render raises (#99808) 2023-09-08 21:02:06 +02:00
Erik Montnemery
e5210c5823
Always set severity level flag on render_template error events (#99804) 2023-09-07 12:00:19 +02:00
Erik Montnemery
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
Erik Montnemery
7e36da4cc0
Small cleanup of WS command render_template (#99562) 2023-09-04 14:17:30 -04:00
Allen Porter
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
Ville Skyttä
3094991236
Upgrade ruff to 0.0.285 (#98647) 2023-08-19 08:17:17 -04:00
Marc Mueller
a9ade1f84d
Use asyncio.timeout [core] (#98447) 2023-08-15 08:36:05 -05:00
Marc Mueller
582499a260
Improve async_track_template_result callback typing (#97135) 2023-07-24 12:42:17 +02:00
J. Nick Koston
dae264f79e
Fix websocket_api _state_diff_event using json_encoder_default (#96905) 2023-07-19 18:22:43 +02:00
J. Nick Koston
d242eaa375
Remove the ability to defer websocket message construction (#96734)
This was added in #71364 but all use cases of it were refactored
away so it can now be removed
2023-07-17 08:41:39 +02:00
Erik Montnemery
78880f0c9d
Fix execute device actions with WS execute_script (#95783) 2023-07-03 14:21:01 -04:00
J. Nick Koston
2aff138b92
Small improvements to websocket api performance (#95693) 2023-07-02 12:33:25 -05:00
Erik Montnemery
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
Franck Nijhof
3e85a29b86
Move overlapping pylint rules to ruff, disable mypy overlap (#94359) 2023-06-27 17:42:46 +02:00
Paulus Schoutsen
5f14cdf69d
Allow stopping a script with a response value (#95284) 2023-06-27 08:24:22 +02:00
J. Nick Koston
3f18f515e7
Improve websocket api coverage and typing (#94891) 2023-06-20 15:21:24 +01:00
J. Nick Koston
1206f2c1da
Fix memory leaks in websocket api (#94780)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-06-19 18:27:22 -05:00
Erik Montnemery
b5f5e1c8c3
Add empty config schema to integrations t-z (#93853) 2023-05-31 10:13:26 +02:00
J. Nick Koston
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
J. Nick Koston
b993fe1c9d
Cache generation of the service descriptions (#93131) 2023-05-16 21:42:37 -05:00
J. Nick Koston
99265a983a
Speed up reconnects by caching state serialize (#93050) 2023-05-16 02:33:12 -05:00
J. Nick Koston
b95405a7e9
Small performance improvements to state diff messages (#92963)
Adds missing test coverage
2023-05-14 12:28:34 -04:00
J. Nick Koston
2848f8648d
Log last message when websocket reaches peak limit (#93038)
When we hit the absolute limit, we would log the last messages as
it was key to finding out the source. We now do the same when
we hit the peak limit
2023-05-14 12:22:19 -04:00
J. Nick Koston
8711735ec0
Improve websocket throughput and reduce latency (#92967) 2023-05-13 00:13:57 +09:00
Erik Montnemery
4e0b8a7363
Allow complex schemas for validating WS commands (#91655) 2023-04-19 11:37:09 -04:00
J. Nick Koston
de2ca31a71
Remove lru_cache on websocket _state_diff (#90392) 2023-03-28 13:08:43 +02:00
J. Nick Koston
e7e7f603c2
Remove async_response from websocket apis where nothing was being awaited (#90204) 2023-03-23 20:53:18 -04:00
Paulus Schoutsen
0ca6723378
Allow passing binary to the WS connection (#89882)
* Allow passing binary to the WS connection

* Expand test coverage

* Test non-existing handler

* Allow signaling end of stream using empty payloads

* Store handlers in a list

* Handle binary handlers raising exceptions
2023-03-22 08:36:36 -04:00
J. Nick Koston
a8e95684fa
Fix websocket back pressure bottleneck (#89905) 2023-03-20 21:51:39 -10:00
Michael Hansen
e16f17f5a8
Voice assistant integration with pipelines (#89822)
* Initial commit

* Add websocket test tool

* Small tweak

* Tiny cleanup

* Make pipeline work with frontend branch

* Add some more info to start event

* Fixes

* First voice assistant tests

* Remove run_task

* Clean up for PR

* Add config_flow.py

* Remove CLI tool

* Simplify by removing stt/tts for now

* Clean up and fix tests

* More clean up and API changes

* Add quality_scale

* Remove data from run-finish

* Use StrEnum backport

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-03-16 20:42:26 -04:00
J. Nick Koston
48b93e03ee
Cache transient templates compiles provided via api (#89065)
* Cache transient templates compiles provided via api

partially fixes #89047 (there is more going on here)

* add a bit more coverage just to be sure

* switch method

* Revert "switch method"

This reverts commit 0e9e1c8cbe.

* tweak

* hold hass

* empty for github flakey
2023-03-02 21:31:12 -05:00
J. Nick Koston
ecf87ae979
Improve performance of websocket_api dispatch (#88496)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2023-02-20 19:51:34 +01:00