Commit graph

55 commits

Author SHA1 Message Date
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
Erik Montnemery
40ce25800c
Test that homeassistant stop and restart do not block WS () 2021-03-21 22:12:56 -07:00
Erik Montnemery
333e6a215a
Add execute_script WS API ()
* Add execute_script WS API

* Improve tests
2021-03-16 08:51:00 +01:00
Paulus Schoutsen
4c181bbfe5
Raise error instead of crashing when template passed to call service target () 2021-03-05 15:34:18 -08:00
Bram Kragten
4b493c5ab9
Add target to service call API ()
* Add target to service call API

* Fix _async_call_service_step

* CONF_SERVICE_ENTITY_ID overrules target

* Move merging up before processing schema

* Restore services.yaml

* Add test
2021-02-10 12:42:28 +01:00
Marc Mueller
fb39185420
Add schema error handling to websocket_api ()
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-01-27 15:20:22 +01:00
J. Nick Koston
31c21126a8
Implement time tracking in templates ()
Co-authored-by: Anders Melchiorsen <amelchio@nogoto.net>
2020-10-19 11:02:43 +02:00
J. Nick Koston
b897ca7260
Ensure all template errors are caught and the websocket api reports them () 2020-10-12 16:38:24 +02:00
J. Nick Koston
4798f37c6e
Convert States to dicts via as_dict only once ()
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-10-05 09:18:57 -05:00
J. Nick Koston
e08ee282ab
Abort execution of template renders that overwhelm the system () 2020-09-28 14:43:22 +02:00
J. Nick Koston
57b7559832
Ensure all jinja2 errors are trapped and displayed in the developer tools ()
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-09-26 17:03:32 -05:00
J. Nick Koston
741487a1fc
Return the listeners with the template result for the websocket api () 2020-09-11 13:18:40 -05:00
Paulus Schoutsen
2a1fe9d29a
Add websocket trigger/condition commands () 2020-08-24 23:01:57 +02:00
J. Nick Koston
f560256546
Update websocket api to use async_track_template_result () 2020-08-21 14:04:29 +02:00
Paulus Schoutsen
3dc79aa60a
Track entity sources ()
Co-authored-by: David Mulcahey <david.mulcahey@me.com>
2020-08-19 14:57:38 +02:00
Paulus Schoutsen
8ed1a29c82
Drop white blacklist pt1 () 2020-07-13 17:43:11 +02:00
Aaron Bach
7968cd650a
Add concept of allowed external URLs to config ()
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-24 17:37:01 -07:00
Paulus Schoutsen
9f1bffe3be
Add command to get integration manifests ()
* Add command to get integration manifests

* Add is_built_in value to manifest

* Update APIs
2020-04-15 13:36:16 -07:00
Bas Nijholt
3df40c7a16 Sort imports according to PEP8 for websocket_api () 2019-12-09 12:30:23 +01:00
Paulus Schoutsen
3231e22ddf
Remove direct authentication via trusted networks or API password ()
* Remove direct authentication via trusted networks and API password

* Fix tests
2019-10-14 14:56:45 -07:00
Thomas Lovén
e7e083c547 Websocket call for rendering jinja2 templates subscription ()
* Websocket call for rendering jinja2 templates

* Address review comments

* Address review comments

* Allow MATCH_ALL, but ignore it.

* Always register unsub method.
2019-08-10 12:46:49 -07:00
Paulus Schoutsen
4de97abc3a Black 2019-07-31 12:25:30 -07:00
Paulus Schoutsen
f995ab9d54
Don't pass in loop ()
* Don't pass in loop

* Revert some changes

* Lint + Axis revert

* reinstate loop

* Fix a test

* Set loop

* Update camera.py

* Lint
2019-05-22 21:09:59 -07:00
Paulus Schoutsen
de1fd5a7fa
WS: Improve service calling errors ()
* WS: Improve service calling errors

* Docstyle

* Types

* Update text
2019-05-14 07:09:11 +02:00
Paulus Schoutsen
29131a655d
Allow non-admins to listen to certain events () 2019-03-17 19:13:06 -07:00
Paulus Schoutsen
fc1ee9be43
Use new style for built-in ws commmands ()
* Use new style for built-in ws commmands

* Lint
2019-03-05 19:31:26 -08:00
Jason Hu
f1b867dccb Re-thrown exception occurred in the blocking service call ()
* Rethrown exception occurred in the actual service call

* Fix lint and test
2019-03-01 23:09:31 -08:00
Paulus Schoutsen
d1a621601d No more opt-out auth ()
* No more opt-out auth

* Fix var
2018-12-02 16:32:53 +01:00