Commit graph

33 commits

Author SHA1 Message Date
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
J. Nick Koston
1206f2c1da
Fix memory leaks in websocket api ()
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-06-19 18:27:22 -05:00
Erik Montnemery
80e2f96097
Add WS command thread/delete_dataset ()
* Add WS command thread/delete_dataset

* Return not_allowed when trying to delete the preferred dataset
2023-02-15 12:55:10 -05:00
J. Nick Koston
0f4b17755e
Improve logging and handling when websocket gets behind ()
fixes undefined
2023-01-29 10:49:27 -10:00
J. Nick Koston
57239769ba
Only build compressed states once () 2023-01-09 12:07:32 -10: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
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
e2cef55162
Add history/history_during_period websocket endpoint () 2022-05-11 17:52:22 -05: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
Marc Mueller
67c35652f0
Update typing - collections.abc (2) () 2022-01-12 09:04:37 +01:00
Marc Mueller
bcb93d95bb
Update typing (4) [u-z] () 2022-01-11 21:26:45 +01:00
Ruslan Sayfutdinov
42ff687c32
Add missing type hints to websocket_api () 2021-05-21 09:39:18 -07:00
Martin Hjelmare
5ec09eab42
Move not loaded websocket constant to zwave_js () 2021-05-06 17:59:03 -07:00
Martin Hjelmare
38d7652176
Fix zwave_js websocket api KeyError on unloaded entry () 2021-05-06 16:43:14 +02:00
Ville Skyttä
dc880118a4
Lint suppression cleanups ()
* Unused pylint suppression cleanups

* Remove outdated pylint bug references

* Add flake8-noqa config and note to run it every now and then

* Add codes to noqa's

* Unused noqa cleanups
2021-03-02 09:02:04 +01: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
jjlawren
6d95ee7a00
Websocket media browsing for Plex ()
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-08-24 12:41:01 +02:00
Paulus Schoutsen
bea354b82a
Allow WS queue to temporarily peak ()
* Allow WS queue to temporarily peak

* Remove unused code
2020-04-13 18:50:36 -07:00
springstan
e3bcfb88e7
Improve string formatting v4 ()
* Improve string formatting v4

* Use normal strings instead of f-strings

* Fix zeroconf test by adding back part of a condition
2020-04-05 16:01:41 +02:00
Ville Skyttä
9b2544c923
Remove some unneeded pylint suppressions () 2020-02-24 16:47:15 -08:00
Paulus Schoutsen
b9aba30a6e
Extract Collection helper from Person integration ()
* Add CRUD foundation

* Use collection helper in person integration

* Lint/pytest

* Add tests

* Lint

* Create notification
2020-01-03 21:37:11 +01:00
springstan
6de8072e8a Move imports to top for websocket_api ()
* Move imports to top for websocket_api

* Move back an import because of circular dependency, add annotations
2019-12-08 12:19:15 +01:00
Paulus Schoutsen
4de97abc3a Black 2019-07-31 12:25:30 -07:00
Paulus Schoutsen
f5f86993f1
Improve Alexa error handling () 2019-06-24 22:04:31 -07:00
Paulus Schoutsen
45085dd97f
Better handle large amounts of data being sent over WS ()
* Better handle large amounts of data being sent over WS

* Lint
2019-05-14 05:57:47 +02:00
Penny Wood
2527731865 Fix websocket connection sensor ()
* Fix for 

* Singleton count
2019-04-13 10:48:40 -07:00
Penny Wood
1ddc65a0ce Fixing the api_streams sensor ()
* Fire events with websocket messages.

* Added tests to validate

* Fixed api_streams sensor to use new sensor

* Delete from coverageac as now works.

* Removed websocket request event.

* Use dispatcher instead of events.

* Moved sensor to under websocket_api

* Changes as per code review

* Fixed tests.

* Modified test

* Patch
2019-03-22 11:59:10 -07: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
9d7b1fc3a7
Enforce permissions for Websocket API ()
* Handle unauth exceptions in websocket

* Enforce permissions in websocket API
2018-11-27 10:12:31 +01:00
Paulus Schoutsen
2e6346ca43 Break up websocket 2 ()
* Break up websocket 2

* Lint+Test

* Lintttt

* Rename
2018-10-01 16:09:31 +02:00
Paulus Schoutsen
22a80cf733
Break up websocket component ()
* Break up websocket component

* Lint
2018-10-01 11:21:00 +02:00