Commit graph

44 commits

Author SHA1 Message Date
J. Nick Koston
60ab360fe7
Avoid bytes to string to bytes conversion in websocket api () 2024-01-16 21:37:34 +01:00
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
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
Ville Skyttä
3094991236
Upgrade ruff to 0.0.285 () 2023-08-19 08:17:17 -04:00
J. Nick Koston
d242eaa375
Remove the ability to defer websocket message construction ()
This was added in  but all use cases of it were refactored
away so it can now be removed
2023-07-17 08:41:39 +02:00
J. Nick Koston
2aff138b92
Small improvements to websocket api performance () 2023-07-02 12:33:25 -05:00
Franck Nijhof
3e85a29b86
Move overlapping pylint rules to ruff, disable mypy overlap () 2023-06-27 17:42:46 +02:00
J. Nick Koston
3f18f515e7
Improve websocket api coverage and typing () 2023-06-20 15:21:24 +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
J. Nick Koston
8711735ec0
Improve websocket throughput and reduce latency () 2023-05-13 00:13:57 +09:00
Paulus Schoutsen
0ca6723378
Allow passing binary to the WS connection ()
* Allow passing binary to the WS connection

* Expand test coverage

* Test non-existing handler

* Allow signaling end of stream using empty payloads

* Store handlers in a list

* Handle binary handlers raising exceptions
2023-03-22 08:36:36 -04:00
Michael Hansen
e16f17f5a8
Voice assistant integration with pipelines ()
* Initial commit

* Add websocket test tool

* Small tweak

* Tiny cleanup

* Make pipeline work with frontend branch

* Add some more info to start event

* Fixes

* First voice assistant tests

* Remove run_task

* Clean up for PR

* Add config_flow.py

* Remove CLI tool

* Simplify by removing stt/tts for now

* Clean up and fix tests

* More clean up and API changes

* Add quality_scale

* Remove data from run-finish

* Use StrEnum backport

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-03-16 20:42:26 -04:00
J. Nick Koston
ecf87ae979
Improve performance of websocket_api dispatch ()
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2023-02-20 19:51:34 +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
5c99e2e5d3
Improve error logging of WebSocket API () 2022-11-01 14:11:50 -04: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
uvjustin
d989e4373d
Remove websocket_api send_big_result () 2022-07-19 21:08:11 -07:00
uvjustin
6b60fb9541
Don't use executor in send_big_result () 2022-07-19 08:40:23 -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
Zac West
20960e182d
Log unknown websocket commands at info instead of error () 2022-05-22 22:41:51 -07: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
Paulus Schoutsen
fbc39d1206
Log stack trace if exception without message () 2022-03-04 09:48:07 +01:00
Paulus Schoutsen
63f8e437ed
Add Home Assistant Content user () 2022-01-21 10:06:39 -08:00
Marc Mueller
d51487f82a
Import Callable from collections.abc (3) () 2021-09-29 16:19:06 +02:00
Paulus Schoutsen
677abcd484
Allow confirming local push notifications ()
* Allow confirming local push notifications

* Fix from Zac

* Add tests
2021-09-22 23:17:04 +02:00
Ruslan Sayfutdinov
42ff687c32
Add missing type hints to websocket_api () 2021-05-21 09:39:18 -07:00
Marc Mueller
c07646db5d
Update typing syntax ()
* Update typing syntax

* Replace typing imports with ones from collections where possible

* Changes after review
2021-04-20 17:40:41 +02:00
Marc Mueller
dcca29ef68
Update typing 14 () 2021-03-18 15:08:35 +01:00
Paulus Schoutsen
de12ac354a
Expose more Websocket API constants () 2020-10-25 21:10:13 +01: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
bd54ff3c02 Add TT WS API ()
* Add TT WS API

* Add a test

* Correctly convert TT errrors
2019-11-08 10:06:16 +01:00
Ville Skyttä
f259ff17d5
Type hint additions ()
* Type hint additions

* Remove optional from sidebar_icon comment

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Remove optional from sidebar_title comment

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Fix issues after rebase and mypy 0.730
2019-09-29 20:07:49 +03: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
Leonardo Merza
29ad3961e5 Use voluptuous error string for websocket validation error ()
* use voluptuous error string to websocket validation error

* added exception logging to websocket error

* add detailed message to websocket validation error

* add error message to websocket validation error

* Add humanize error for websocket invalid vol error

* Add humanize error for websocket invalid vol error

* Add humanize error for websocket invalid vol error
2019-03-27 10:40:39 -07:00
Paulus Schoutsen
429bbc05dc
Add WS subscription command for MQTT ()
* Add WS subscription command for MQTT

* Add test

* Add check for connected

* Rename event_listeners to subscriptions
2019-03-10 20:07:09 -07:00
Paulus Schoutsen
987b5cd905
Person component: add storage and WS commands ()
* Forbid duplicate IDs

* Allow loading persons from storage

* Convert to PersonManager

* Add storage support and WS commands to Person component

* Convert list command to differentiate types

* Allow loading person component without defining persons

* Fix cleanups after update/delete

* Address comments

* Start tracking when HA started
2019-02-09 10:41:40 -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