Commit Graph
135 Commits
Author SHA1 Message Date
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
J. Nick KostonandGitHub 8711735ec0 Improve websocket throughput and reduce latency (#92967) 2023-05-13 00:13:57 +09:00
Paulus SchoutsenandGitHub 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
ecf87ae979 Improve performance of websocket_api dispatch (#88496)
Co-authored-by: Paulus Schoutsen <[email protected]>
2023-02-20 19:51:34 +01:00
epenetandGitHub a16e298599 Adjust json imports in tests (#88248) 2023-02-17 19:13:48 +01:00
epenetandGitHub aa50096a31 Add type hints to integration tests (part 24) (#88307) 2023-02-17 16:34:53 +01:00
Franck NijhofandGitHub ed79265843 Enable Ruff PT006 (#88165)
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
epenetandGitHub 278050a73f Add type hints to integration tests (t-z) (#87707) 2023-02-08 19:10:53 +01:00
J. Nick KostonandGitHub 0f4b17755e Improve logging and handling when websocket gets behind (#86854)
fixes undefined
2023-01-29 10:49:27 -10:00
e50a531cd9 Code styling tweaks to the tests - Part 2 (#86662)
Co-authored-by: jjlawren <[email protected]>
2023-01-26 01:23:53 +01:00
Franck NijhofandGitHub 5c99e2e5d3 Improve error logging of WebSocket API (#81360) 2022-11-01 14:11:50 -04:00
Franck NijhofandGitHub bb287dd0ed Integrations v2.1: Virtual integrations (#80613) 2022-10-20 23:09:06 -04:00