Commit graph

86 commits

Author SHA1 Message Date
J. Nick Koston
99265a983a
Speed up reconnects by caching state serialize () 2023-05-16 02:33:12 -05:00
J. Nick Koston
8711735ec0
Improve websocket throughput and reduce latency () 2023-05-13 00:13:57 +09:00
J. Nick Koston
e7e7f603c2
Remove async_response from websocket apis where nothing was being awaited () 2023-03-23 20:53:18 -04:00
J. Nick Koston
48b93e03ee
Cache transient templates compiles provided via api ()
* Cache transient templates compiles provided via api

partially fixes  (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
epenet
ba23816a0c
Inverse json import logic ()
* Fix helpers and util

* Adjust components

* Move back errors

* Add report

* mypy

* mypy

* Assert deprecation messages

* Move test_json_loads_object

* Adjust tests

* Fix rebase

* Adjust pylint plugin

* Fix plugin

* Adjust references

* Adjust backup tests
2023-02-16 11:37:57 +01:00
J. Nick Koston
0f4b17755e
Improve logging and handling when websocket gets behind ()
fixes undefined
2023-01-29 10:49:27 -10:00
Franck Nijhof
e738924780
Enable Ruff SIM105 ()
* Enable Ruff SIM105

* Adjust existing cases
2023-01-26 21:06:22 -05:00
Franck Nijhof
79b52a2b41
Stricter pylint message control () 2023-01-20 13:47:55 +01:00
J. Nick Koston
57239769ba
Only build compressed states once () 2023-01-09 12:07:32 -10:00
Jan Bouwhuis
23bc39b7f4
Add type hints on Template().__init__() () 2022-11-23 20:26:55 +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
J. Nick Koston
61cc9f5288
Consolidate executor jobs when loading integration manifests () 2022-07-14 13:06:08 -07: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
d612b9e0b4
Reduce event loop overhead for listeners that already queue ()
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-05-05 23:09:10 -04:00
J. Nick Koston
fe6a4bfb1d
Remove EVENT_TIME_CHANGED and EVENT_TIMER_OUT_OF_SYNC ()
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-04-09 09:05:54 -10:00
J. Nick Koston
ea6da674df
Remove unneeded permissions check from subscribe entities () 2022-03-12 13:30:27 -08: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
7f4faafe38
Add type code that is being ignored () 2022-02-26 13:56:47 -08:00
J. Nick Koston
c9e46d360b
Use compact encoding for JSON websocket messages ()
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-02-23 22:15:20 -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
Marc Mueller
b2ee7cebc9
Improve setup_time typing () 2022-02-14 14:24:58 +01:00
Erik Montnemery
8d6e2ae354
Import persistent notification part 1 () 2022-01-11 17:24:59 +01:00
Marc Mueller
198ade5e2b
Fix typing TrackTemplateResultListener [helpers.event] () 2022-01-06 13:43:54 -10: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
Michael
90e52cd3ad
Use relative imports [S-Z] () 2021-12-13 09:39:13 +01:00
Erik Montnemery
caf5ee2fab
Remove optional validation when creating conditions () 2021-11-28 14:54:07 +01:00
Marc Mueller
aa7dc78a1e
Use assignment expressions 11 () 2021-10-17 20:15:48 +02:00
Ville Skyttä
470f2dd73f
Upgrade pyupgrade to 2.21.2, apply its changes () 2021-07-19 10:46:09 +02:00
Ruslan Sayfutdinov
42ff687c32
Add missing type hints to websocket_api () 2021-05-21 09:39:18 -07:00
Paulus Schoutsen
1e10772497
Add support for local push channels to mobile_app () 2021-05-17 11:06:42 -07:00
J. Nick Koston
53853f035d
Prevent calling stop or restart services during db upgrade () 2021-04-12 17:18:38 -07:00
Jason
7cc857a298
Add custom JSONEncoder for subscribe_trigger WS endpoint () 2021-04-09 20:47:10 -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
J. Nick Koston
1fb9008488
Include platform only integrations in the manifest list api () 2021-03-29 12:51:48 +02: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