Commit graph

82 commits

Author SHA1 Message Date
Jan Bouwhuis
861bb48ab6
Assign specific error code for HomeAssistantError on websocket_api connection exceptions ()
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 ()
* 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 ()
* 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 Bouwhuis
54cf7010cd
Add ServiceValidationError and translation support ()
* 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
Erik Montnemery
6485320bc4
Improve type annotations in websocket_api tests () 2023-09-12 17:31:25 +02:00
Erik Montnemery
fabb098ec3
Simplify WS command entity/source () 2023-09-12 15:39:11 +02:00
Erik Montnemery
1654ef7759
Make WS command render_template not give up if initial render raises () 2023-09-08 21:02:06 +02:00
Erik Montnemery
e5210c5823
Always set severity level flag on render_template error events () 2023-09-07 12:00:19 +02:00
Erik Montnemery
48f7924e9e
Allow specifying a custom log function for template render ()
* 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 Mueller
a9ade1f84d
Use asyncio.timeout [core] () 2023-08-15 08:36:05 -05:00
Erik Montnemery
3b9d6f2dde
Add setup function to the component loader ()
* 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 Nijhof
868a5f377f
Ruff: isort don't split imports based on trailing comma () 2023-08-10 14:27:03 +02:00
Erik Montnemery
78880f0c9d
Fix execute device actions with WS execute_script () 2023-07-03 14:21:01 -04:00
Erik Montnemery
5f9da06e49
Fix flaky websocket_api test () 2023-07-03 11:53:21 -05:00
Allen Porter
7252c33df8
Limit fields returned for the list events service ()
* 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 Montnemery
e18f7dffb0
Teach validate_config to validate lists of conditions ()
* Teach validate_config to validate lists of conditions

* Update test
2023-06-27 19:44:23 +02:00
Erik Montnemery
cb22fb16f8
Allow returning a script variable from a script ()
* 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 <balloob@gmail.com>

* Format code

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-06-27 17:13:53 +02:00
Paulus Schoutsen
5f14cdf69d
Allow stopping a script with a response value () 2023-06-27 08:24:22 +02:00
J. Nick Koston
b993fe1c9d
Cache generation of the service descriptions () 2023-05-16 21:42:37 -05:00
epenet
a16e298599
Adjust json imports in tests () 2023-02-17 19:13:48 +01:00
epenet
aa50096a31
Add type hints to integration tests (part 24) () 2023-02-17 16:34:53 +01:00
Franck Nijhof
ed79265843
Enable Ruff PT006 ()
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
epenet
278050a73f
Add type hints to integration tests (t-z) () 2023-02-08 19:10:53 +01:00
Franck Nijhof
e50a531cd9
Code styling tweaks to the tests - Part 2 ()
Co-authored-by: jjlawren <jjlawren@users.noreply.github.com>
2023-01-26 01:23:53 +01:00
Franck Nijhof
bb287dd0ed
Integrations v2.1: Virtual integrations () 2022-10-20 23:09:06 -04:00
Charles Garwood
58d531841b
Fix typo SIGNAL_BOOTSTRAP_INTEGRATONS -> SIGNAL_BOOTSTRAP_INTEGRATIONS () 2022-10-09 17:06:28 -10:00
Erik Montnemery
b173ae7f44
Add support for integrations v2 ()
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-09-28 11:31:48 -04:00
Franck Nijhof
a19a7e64d5
Fix WebSocket condition testing () 2022-09-16 11:18:00 +02:00
Paulus Schoutsen
0e734e629c
Handle missing supported brands () 2022-09-09 07:47:33 +02:00
J. Nick Koston
f6a03625ba
Implement websocket message coalescing ()
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-08-24 22:50:48 -05:00
Paulus Schoutsen
41ec8cd354
Expose supported brands via API () 2022-07-12 13:49:54 -07:00
J. Nick Koston
8b067e83f7
Initial orjson support take 3 ()
* Initial orjson support take 2

Still need to work out problem building wheels

--

Redux of  /  Now possible since the following is solved:
 (comment)

This implements orjson where we use our default encoder.  This does not implement orjson where `ExtendedJSONEncoder` is used as these areas tend to be called far less frequently.  If its desired, this could be done in a followup, but it seemed like a case of diminishing returns (except maybe for large diagnostics files, or traces, but those are not expected to be downloaded frequently).

Areas where this makes a perceptible difference:
- Anything that subscribes to entities (Initial subscribe_entities payload)
- Initial download of registries on first connection / restore
- History queries
- Saving states to the database
- Large logbook queries
- Anything that subscribes to events (appdaemon)

Cavets:
orjson supports serializing dataclasses natively (and much faster) which
eliminates the need to implement `as_dict` in many places
when the data is already in a dataclass. This works
well as long as all the data in the dataclass can also
be serialized. I audited all places where we have an `as_dict`
for a dataclass and found only backups needs to be adjusted (support for `Path` needed to be added for backups).  I was a little bit worried about `SensorExtraStoredData` with `Decimal` but it all seems to work out from since it converts it before it gets to the json encoding cc @dgomes

If it turns out to be a problem we can disable this
with option |= [orjson.OPT_PASSTHROUGH_DATACLASS](https://github.com/ijl/orjson#opt_passthrough_dataclass) and it
will fallback to `as_dict`

Its quite impressive for history queries
<img width="1271" alt="Screen_Shot_2022-05-30_at_23_46_30" src="https://user-images.githubusercontent.com/663432/171145699-661ad9db-d91d-4b2d-9c1a-9d7866c03a73.png">

* use for views as well

* handle UnicodeEncodeError

* tweak

* DRY

* DRY

* not needed

* fix tests

* Update tests/components/http/test_view.py

* Update tests/components/http/test_view.py

* black

* templates
2022-06-22 21:59:51 +02:00
J. Nick Koston
c365454afb
Revert "Initial orjson support ()" ()
This was causing the wheels to fail to build. We need
to workout why when we don't have release pressure

This reverts commit d9d22a9556.
2022-05-31 13:51:55 -07:00
J. Nick Koston
d9d22a9556
Initial orjson support () 2022-05-31 12:18:11 -07:00
J. Nick Koston
78f0716574
Add support for specifying the integrations manifest/list fetches ()
* Add support for specifying the integrations manifest/list fetches

See https://github.com/home-assistant/core/pull/71979 for
the motovation

* Update homeassistant/components/websocket_api/commands.py

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-05-17 01:22:56 -05:00
J. Nick Koston
0d8f649bd6
Websocket api to subscribe to entities (payloads reduced by ~80%+ vs state_changed events) () 2022-03-11 20:54:49 -08:00
Paulus Schoutsen
a42547c0e5
Allow get_states to recover () 2022-02-23 21:15:48 -08:00
Paulus Schoutsen
756e711850
Add a new validate config WS command () 2022-02-22 22:28:37 +01:00
Mike Degatano
8ea6cbc257
Support variables in templates with timeout () 2022-02-21 09:56:20 -08:00
Erik Montnemery
b196064540
Import persistent notification (part 5) () 2022-01-13 08:45:30 +01:00
Nico Müller
cf1df5ff38
Add 'fire_event' command to websocket api ()
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-01-05 12:28:40 -08:00
J. Nick Koston
10d6247fee
Bump to aiohttp 3.8.0 () 2021-11-04 10:07:50 -05:00
Erik Montnemery
6954614e62
Warn if total_increasing sensor has negative states () 2021-09-30 07:49:16 -07:00
Erik Montnemery
bfd799dc04
Use hass_client_no_auth test fixture in integrations s-x () 2021-09-02 14:50:10 +02:00
jan iversen
9879b7becf
Rename HomeAssistantType to HomeAssistant, integrations w* - z* ()
* Integration zha: HomeAssistantType -> HomeAssistant.

* Integration zerproc: HomeAssistantType -> HomeAssistant.

* Integration xbox: HomeAssistantType -> HomeAssistant.

* Integration wunderground: HomeAssistantType -> HomeAssistant.

* Integration wled: HomeAssistantType -> HomeAssistant.

* Integration water_heater: HomeAssistantType -> HomeAssistant.

* Integration websocket_api: HomeAssistantType -> HomeAssistant.

* Integration wilight: HomeAssistantType -> HomeAssistant.
2021-04-22 11:04:28 -04:00
J. Nick Koston
53853f035d
Prevent calling stop or restart services during db upgrade () 2021-04-12 17:18:38 -07:00
Erik Montnemery
16196e2e16
Don't log template errors from developer tool () 2021-04-09 12:10:02 -07:00
J. Nick Koston
1f80c756ab
Fix subscribe_bootstrap_integrations to send events () 2021-04-08 07:30:33 -10:00
J. Nick Koston
12e3bc8101
Provide api to see which integrations are being loaded ()
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-04-04 22:11:44 -10:00
Paulus Schoutsen
bdbb4f939f
Add variables to execute script () 2021-04-02 06:27:41 -07:00