Commit Graph
146 Commits
Author SHA1 Message Date
J. Nick KostonandGitHub 9995207817 Avoid re-encoding the message id as bytes for every event/state change (#116460) 2024-04-30 12:02:28 -05:00
J. Nick KostonandGitHub 588c260dc5 Skip processing websocket_api schema if it has no arguments (#115618)
* Skip processing websocket_api schema if has no arguments

About 40% of the websocket commands on first connection have
no arguments. We can skip processing the schema for these cases

* cover

* fixes

* allow extra

* Revert "allow extra"

This reverts commit 85d9ec36b3.

* match behavior
2024-04-18 10:41:08 -04:00
3299bc5ddc Translate service validation errors (#115024)
* Move service validation error message to translation cache

* Fix test

* Revert unrelated change

* Address review comments

* Improve error message

---------

Co-authored-by: J. Nick Koston <[email protected]>
2024-04-18 14:36:03 +02:00
348e1df949 Add strict connection (#112387)
Co-authored-by: Martin Hjelmare <[email protected]>
2024-04-12 14:47:46 +02:00
J. Nick KostonandGitHub 137514edb7 Bump aiohttp to 3.9.4 (#110730)
* Bump aiohttp to 3.9.4

This is rc0 for now but will be updated when the full release it out

* cleanup cruft

* regen

* fix tests (these changes are fine)

* chunk size is too small to read since boundry is now enforced

* chunk size is too small to read since boundry is now enforced
2024-04-11 11:58:56 -10:00
epenetandGitHub 9204ccfa17 Use is in ConfigEntryState enum comparison in tests (N-Z) (#114926) 2024-04-05 17:37:00 +02:00
6bb4e7d62c Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <[email protected]>
Co-authored-by: Marc Mueller <[email protected]>
Co-authored-by: J. Nick Koston <[email protected]>
2024-03-26 00:02:16 +01:00
00ec7f11f0 Enable Ruff rule PT007 (#113764)
Co-authored-by: Franck Nijhof <[email protected]>
2024-03-19 09:01:07 +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 <[email protected]>

* Update tests/test_setup.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update homeassistant/setup.py

Co-authored-by: Martin Hjelmare <[email protected]>

* 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 <[email protected]>
2024-03-18 21:45:34 -04:00
SidandGitHub 82a60fe8ad Enable Ruff RSE (#113695) 2024-03-18 00:40:38 +01:00
Joost LekkerkerkerandGitHub 49fc59548a Improve lists in integrations [V-W] (#113252) 2024-03-13 19:38:04 +01:00
Marc MuellerandGitHub 32f3f46542 Add empty line after module docstring (2) [tests.components] (#112737) 2024-03-08 19:16:21 +01:00
Marc MuellerandGitHub 87165c0d6e Add empty line after module docstring [tests t-z] (#112712) 2024-03-08 14:44:56 +01:00
J. Nick KostonandGitHub 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
J. Nick KostonandGitHub f6d4617c7a Avoid directly changing config entry state in tests (part 2) (#110115)
followup to #110048 for more places
2024-02-10 07:20:15 +01:00
Marc MuellerandGitHub 8b0c9d3d18 Use builtin TimeoutError [t-z] (#109683) 2024-02-05 12:20:36 +01:00
825fed8319 Bump aiohttp to 3.9.3 (#109025)
Co-authored-by: Joost Lekkerkerker <[email protected]>
2024-01-29 23:15:18 +01:00
J. Nick KostonandGitHub 2eea658fd8 Convert getting and removing access tokens to normal functions (#108670) 2024-01-22 20:51:33 -10:00
52b5d2e370 Avoid json encoder default fallback when serializing config (#108360)
Co-authored-by: Paulus Schoutsen <[email protected]>
2024-01-19 19:22:17 -10:00
J. Nick KostonandGitHub 60ab360fe7 Avoid bytes to string to bytes conversion in websocket api (#108139) 2024-01-16 21:37:34 +01:00
J. Nick KostonandGitHub 6ada825805 Use faster is_admin check for websocket state and event subscriptions (#107621) 2024-01-13 10:42:41 -10:00
J. Nick KostonandGitHub 03fcb81a59 Small speed up to compressed state diff (#106624) 2023-12-29 08:36:20 +01:00
Jan BouwhuisandGitHub 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 BouwhuisandGitHub 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 GuptaandGitHub 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
Jan BouwhuisandGitHub 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 KostonandGitHub 653da6e31f Reduce websocket event and state JSON construction overhead (#101974) 2023-10-15 23:39:09 +02:00
Erik MontnemeryandGitHub 6485320bc4 Improve type annotations in websocket_api tests (#100198) 2023-09-12 17:31:25 +02:00
Erik MontnemeryandGitHub fabb098ec3 Simplify WS command entity/source (#99439) 2023-09-12 15:39:11 +02:00
Erik MontnemeryandGitHub 1654ef7759 Make WS command render_template not give up if initial render raises (#99808) 2023-09-08 21:02:06 +02:00
Erik MontnemeryandGitHub e5210c5823 Always set severity level flag on render_template error events (#99804) 2023-09-07 12:00:19 +02:00
Erik MontnemeryandGitHub 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
Marc MuellerandGitHub 544d6b05a5 Replace mock_coro with AsyncMock (#99014)
* Replace mock_coro with AsyncMock

* Remove mock_coro test helper function

* Remove redundant AsyncMock
2023-08-25 22:54:55 +02:00
Ville SkyttäandGitHub b51c0f6ddc Remove unnnecessary pylint configs from components [s-z]* (#98925) 2023-08-24 01:25:32 +02:00
Marc MuellerandGitHub a9ade1f84d Use asyncio.timeout [core] (#98447) 2023-08-15 08:36:05 -05:00
Erik MontnemeryandGitHub 3b9d6f2dde Add setup function to the component loader (#98148)
* Add setup function to the component loader

* Update test

* Setup the loader in safe mode and in check_config script
2023-08-15 10:59:42 +02:00
Franck NijhofandGitHub 868a5f377f Ruff: isort don't split imports based on trailing comma (#98162) 2023-08-10 14:27:03 +02:00
J. Nick KostonandGitHub dae264f79e Fix websocket_api _state_diff_event using json_encoder_default (#96905) 2023-07-19 18:22:43 +02:00
Erik MontnemeryandGitHub 78880f0c9d Fix execute device actions with WS execute_script (#95783) 2023-07-03 14:21:01 -04:00
Erik MontnemeryandGitHub 5f9da06e49 Fix flaky websocket_api test (#95786) 2023-07-03 11:53:21 -05:00
Allen PorterandGitHub 7252c33df8 Limit fields returned for the list events service (#95506)
* Limit fields returned for the list events service

* Update websocket tests and fix bugs in response fields

* Omit 'None' fields in the list events response
2023-06-29 13:25:25 -04:00
Erik MontnemeryandGitHub 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
cb22fb16f8 Allow returning a script variable from a script (#95346)
* Allow returning a script variable from a script

* Don't allow returning a template result

* Raise if response variable is undefined

* Add test

* Update homeassistant/helpers/script.py

Co-authored-by: Paulus Schoutsen <[email protected]>

* Format code

---------

Co-authored-by: Paulus Schoutsen <[email protected]>
2023-06-27 17:13:53 +02:00
Paulus SchoutsenandGitHub 5f14cdf69d Allow stopping a script with a response value (#95284) 2023-06-27 08:24:22 +02:00
J. Nick KostonandGitHub 3f18f515e7 Improve websocket api coverage and typing (#94891) 2023-06-20 15:21:24 +01:00
1206f2c1da Fix memory leaks in websocket api (#94780)
Co-authored-by: Martin Hjelmare <[email protected]>
2023-06-19 18:27:22 -05:00
J. Nick KostonandGitHub b993fe1c9d Cache generation of the service descriptions (#93131) 2023-05-16 21:42:37 -05:00
J. Nick KostonandGitHub 99265a983a Speed up reconnects by caching state serialize (#93050) 2023-05-16 02:33:12 -05:00
J. Nick KostonandGitHub b95405a7e9 Small performance improvements to state diff messages (#92963)
Adds missing test coverage
2023-05-14 12:28:34 -04:00
J. Nick KostonandGitHub 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