Commit graph

73 commits

Author SHA1 Message Date
Marc Mueller
a9ade1f84d
Use asyncio.timeout [core] () 2023-08-15 08:36:05 -05:00
Erik Montnemery
3b9d6f2dde
Add setup function to the component loader ()
* Add setup function to the component loader

* Update test

* Setup the loader in safe mode and in check_config script
2023-08-15 10:59:42 +02:00
Franck Nijhof
868a5f377f
Ruff: isort don't split imports based on trailing comma () 2023-08-10 14:27:03 +02:00
Erik Montnemery
78880f0c9d
Fix execute device actions with WS execute_script () 2023-07-03 14:21:01 -04:00
Erik Montnemery
5f9da06e49
Fix flaky websocket_api test () 2023-07-03 11:53:21 -05:00
Allen Porter
7252c33df8
Limit fields returned for the list events service ()
* Limit fields returned for the list events service

* Update websocket tests and fix bugs in response fields

* Omit 'None' fields in the list events response
2023-06-29 13:25:25 -04:00
Erik Montnemery
e18f7dffb0
Teach validate_config to validate lists of conditions ()
* Teach validate_config to validate lists of conditions

* Update test
2023-06-27 19:44:23 +02:00
Erik Montnemery
cb22fb16f8
Allow returning a script variable from a script ()
* Allow returning a script variable from a script

* Don't allow returning a template result

* Raise if response variable is undefined

* Add test

* Update homeassistant/helpers/script.py

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Format code

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-06-27 17:13:53 +02:00
Paulus Schoutsen
5f14cdf69d
Allow stopping a script with a response value () 2023-06-27 08:24:22 +02:00
J. Nick Koston
b993fe1c9d
Cache generation of the service descriptions () 2023-05-16 21:42:37 -05:00
epenet
a16e298599
Adjust json imports in tests () 2023-02-17 19:13:48 +01:00
epenet
aa50096a31
Add type hints to integration tests (part 24) () 2023-02-17 16:34:53 +01:00
Franck Nijhof
ed79265843
Enable Ruff PT006 ()
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
epenet
278050a73f
Add type hints to integration tests (t-z) () 2023-02-08 19:10:53 +01:00
Franck Nijhof
e50a531cd9
Code styling tweaks to the tests - Part 2 ()
Co-authored-by: jjlawren <jjlawren@users.noreply.github.com>
2023-01-26 01:23:53 +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
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