Commit graph

71 commits

Author SHA1 Message Date
J. Nick Koston
f6a03625ba
Implement websocket message coalescing (#77238)
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 (#75176) 2022-07-14 13:06:08 -07:00
Paulus Schoutsen
41ec8cd354
Expose supported brands via API (#75074) 2022-07-12 13:49:54 -07:00
J. Nick Koston
8b067e83f7
Initial orjson support take 3 (#73849)
* Initial orjson support take 2

Still need to work out problem building wheels

--

Redux of #72754 / #32153 Now possible since the following is solved:
ijl/orjson#220 (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 (#72754)" (#72789)
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 (#72754) 2022-05-31 12:18:11 -07:00
J. Nick Koston
78f0716574
Add support for specifying the integrations manifest/list fetches (#71982)
* 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 (#71364)
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 (#69643)
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 (#68044) 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) (#67891) 2022-03-11 20:54:49 -08:00
Paulus Schoutsen
7f4faafe38
Add type code that is being ignored (#67311) 2022-02-26 13:56:47 -08:00
J. Nick Koston
c9e46d360b
Use compact encoding for JSON websocket messages (#67148)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-02-23 22:15:20 -08:00
Paulus Schoutsen
a42547c0e5
Allow get_states to recover (#67146) 2022-02-23 21:15:48 -08:00
Paulus Schoutsen
756e711850
Add a new validate config WS command (#67057) 2022-02-22 22:28:37 +01:00
Mike Degatano
8ea6cbc257
Support variables in templates with timeout (#66990) 2022-02-21 09:56:20 -08:00
Marc Mueller
b2ee7cebc9
Improve setup_time typing (#66509) 2022-02-14 14:24:58 +01:00
Erik Montnemery
8d6e2ae354
Import persistent notification part 1 (#63898) 2022-01-11 17:24:59 +01:00
Marc Mueller
198ade5e2b
Fix typing TrackTemplateResultListener [helpers.event] (#63541) 2022-01-06 13:43:54 -10:00
Nico Müller
cf1df5ff38
Add 'fire_event' command to websocket api (#63378)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-01-05 12:28:40 -08:00
Michael
90e52cd3ad
Use relative imports [S-Z] (#61576) 2021-12-13 09:39:13 +01:00
Erik Montnemery
caf5ee2fab
Remove optional validation when creating conditions (#60481) 2021-11-28 14:54:07 +01:00
Marc Mueller
aa7dc78a1e
Use assignment expressions 11 (#57792) 2021-10-17 20:15:48 +02:00
Ville Skyttä
470f2dd73f
Upgrade pyupgrade to 2.21.2, apply its changes (#52987) 2021-07-19 10:46:09 +02:00
Ruslan Sayfutdinov
42ff687c32
Add missing type hints to websocket_api (#50915) 2021-05-21 09:39:18 -07:00
Paulus Schoutsen
1e10772497
Add support for local push channels to mobile_app (#50750) 2021-05-17 11:06:42 -07:00
J. Nick Koston
53853f035d
Prevent calling stop or restart services during db upgrade (#49098) 2021-04-12 17:18:38 -07:00
Jason
7cc857a298
Add custom JSONEncoder for subscribe_trigger WS endpoint (#48664) 2021-04-09 20:47:10 -07:00
Erik Montnemery
16196e2e16
Don't log template errors from developer tool (#48933) 2021-04-09 12:10:02 -07:00
J. Nick Koston
1f80c756ab
Fix subscribe_bootstrap_integrations to send events (#48754) 2021-04-08 07:30:33 -10:00
J. Nick Koston
12e3bc8101
Provide api to see which integrations are being loaded (#48274)
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 (#48613) 2021-04-02 06:27:41 -07:00
J. Nick Koston
1fb9008488
Include platform only integrations in the manifest list api (#48269) 2021-03-29 12:51:48 +02:00
Erik Montnemery
333e6a215a
Add execute_script WS API (#47964)
* 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 (#47467) 2021-03-05 15:34:18 -08:00
Bram Kragten
4b493c5ab9
Add target to service call API (#45898)
* 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 (#45602)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-01-27 15:20:22 +01:00
Kendell R
5b67030c26
Change WHITELIST to ALLOWLIST for websockets (#44766) 2021-01-04 12:40:03 +01:00
Jason Cronquist
787027958d
Use the async_call context in result of call_service (#44458) 2020-12-31 16:15:39 -10:00
Philip Allgaier
dde6305549
Cleanup unused loggers (components N-Z + tests) (#41982) 2020-10-16 21:24:08 -05:00
J. Nick Koston
b897ca7260
Ensure all template errors are caught and the websocket api reports them (#41719) 2020-10-12 16:38:24 +02:00
J. Nick Koston
e08ee282ab
Abort execution of template renders that overwhelm the system (#40647) 2020-09-28 14:43:22 +02:00
J. Nick Koston
57b7559832
Ensure all jinja2 errors are trapped and displayed in the developer tools (#40624)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-09-26 17:03:32 -05:00
J. Nick Koston
f0f817c361
Serialize websocket event message once (#40453)
Since most of the json serialize work for the websocket was done
multiple times for the same message, we can avoid the overhead
of serializing the same message many times (once per websocket
client) with a cache.
2020-09-22 08:47:04 -05:00
J. Nick Koston
741487a1fc
Return the listeners with the template result for the websocket api (#39925) 2020-09-11 13:18:40 -05:00
J. Nick Koston
a77e09b2c2
Make async_track_template_result track multiple templates (#39371)
* Make async_track_template_result track multiple templates

Combine template entity updates to only write ha
state once per template group update

* Make async_track_template_result use dataclasses for input/output

* black versions

* naming
2020-08-31 19:07:40 -05:00
Paulus Schoutsen
2a1fe9d29a
Add websocket trigger/condition commands (#39109) 2020-08-24 23:01:57 +02:00
J. Nick Koston
f560256546
Update websocket api to use async_track_template_result (#39057) 2020-08-21 14:04:29 +02:00
Paulus Schoutsen
3dc79aa60a
Track entity sources (#37258)
Co-authored-by: David Mulcahey <david.mulcahey@me.com>
2020-08-19 14:57:38 +02:00
J. Nick Koston
20d5d3c162
Switch a few more async_track_state_change to the faster async_track_state_change_event (#37833)
async_track_state_change_event is faster than async_track_state_change
and since we do not care about the data being returned to the callback
this is a simple speedup
2020-07-14 22:31:34 -07:00