Commit graph

2039 commits

Author SHA1 Message Date
Raman Gupta
aab58ad89c
Fix entity and device selector TypedDict's () 2023-06-13 10:52:55 +02:00
Erik Montnemery
59f5b8f2d6
Remove unneeded checks for Entity.platform ()
* Remove unneeded checks for Entity.platform

* Update tests

* Prevent breaking integrations without an EntityComponent

* Warn when entity has no platform
2023-06-09 15:17:41 +02:00
Erik Montnemery
4085c4f6d8
Tweak typing of Entity.platform ()
* Tweak typing of Entity.platform

* Fix mypy errors

* Fix update test

* Improve comments
2023-06-09 10:56:04 +02:00
Franck Nijhof
6db1fbf480
Fix repair issue about no yaml for config entries () 2023-06-08 18:22:34 +02:00
Michael Benz
305fa128fb
Add reload support to intent_script ()
* support live reload of intent_script

* add services.yaml

* update tesls for full code coverage

* Update based on feedback

* fix intent_script reload when no intent_script config

* Update homeassistant/helpers/intent.py

* update tests to handle no_existing better

---------

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2023-06-03 14:02:23 -04:00
J. Nick Koston
457bc4571d
Make RestoreStateData.async_get_instance backwards compatible () 2023-06-01 19:31:17 +02:00
Erik Montnemery
f9037d5f6d
Add platform only config schema to nsw_fuel_station and ping () 2023-06-01 17:30:15 +02:00
Erik Montnemery
c1c319d4d1
Rename cv.no_yaml_config_schema to cv.config_entry_only_config_schema ()
* Rename cv.no_yaml_config_schema to cv.config_entry_only_config_schema

* ✏️
2023-06-01 13:15:48 +02:00
Erik Montnemery
e0db9ab041
Add CONFIG_SCHEMA to broadlink ()
* Add CONFIG_SCHEMA to broadlink

* Simplify error message

* Rename to no_yaml_config_schema

* Add tests

* Raise issue

* Tweak repairs issue description and title

* Update homeassistant/helpers/config_validation.py

* Add link

* Update homeassistant/components/homeassistant/strings.json

Co-authored-by: Franck Nijhof <git@frenck.dev>

* Fix logic, add test

---------

Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-06-01 09:51:26 +02:00
Marc Mueller
c72477811e
Fix event typing () 2023-05-31 12:33:56 +02:00
Erik Montnemery
59c6220b7c
Subscribe to device registry changes from entities ()
* Subscribe to device registry changes from entities

* Use async_track_device_registry_updated_event

* Fix unsubscribe

* Fix logic, add tests
2023-05-31 11:01:55 +02:00
J. Nick Koston
fba826ae9e
Migrate restore_state helper to use registry loading pattern ()
* Migrate restore_state helper to use registry loading pattern

As more entities have started using restore_state over time, it
has become a startup bottleneck as each entity being added is
creating a task to load restore state data that is already loaded
since it is a singleton

We now use the same pattern as the registry helpers

* fix refactoring error -- guess I am tired

* fixes

* fix tests

* fix more

* fix more

* fix zha tests

* fix zha tests

* comments

* fix error

* add missing coverage

* s/DATA_RESTORE_STATE_TASK/DATA_RESTORE_STATE/g
2023-05-30 20:48:17 -05:00
J. Nick Koston
3186ddb095
Speed up setting up event trackers ()
noticed in https://github.com/home-assistant/core/pull/93601 that
the cost of creating the function in the closure was a bit expensive
since we do it once per entity
2023-05-30 20:12:52 -04:00
J. Nick Koston
9f0d3bfce8
Use ReadOnlyDict for entity registry options ()
* Use ReadOnlyDict for entity registry options

While reviewing  it was noticed this was slow at startup
https://github.com/home-assistant/core/pull/93601#issuecomment-1568958280

This is a first pass attempt to improve the performance

* fix tests
2023-05-30 20:11:39 -04:00
Erik Montnemery
8b662dc94f
Detect attempt to setup config entry integration via YAML () 2023-05-29 21:01:47 +02:00
G Johansson
c6feb30c31
Raise issue "does not support platform setup" ()
* Raise issue on platform missing

* Modify issue

* Remove deprecation

* Fix strings

* Strings

* Last strings

* strings to common
2023-05-28 21:53:32 +02:00
J. Nick Koston
083cf7a38b
Fix refactoring error with updating polling entities in sequence ()
* Fix refactoring error with updating in sequence

see 

* coverage

* make sure entities are being updated in parallel

* make sure entities are being updated in sequence
2023-05-28 16:20:48 +02:00
Erik Montnemery
49c3a8886f
Make cv.empty_config_schema log an error instead of raise ()
* Make cv.empty_config_schema log an error instead of raise

* Add test

* Update homeassistant/helpers/config_validation.py

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>

---------

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
2023-05-28 15:54:22 +02:00
J. Nick Koston
0a9c4f15c4
Add event helper to dispatch device registry updates by device_id ()
* Add event helper to dispatch device registry updates by device_id

* Update homeassistant/helpers/event.py

* dry

* dry

* reduce

* reduce

* reorder

* reduce

* cleanup stack depth

* dry

* fix double lookup

* remove unused

* collapse
2023-05-27 20:04:09 -04:00
J. Nick Koston
b966ff7a3d
Await in sequence when we know we will be blocked by the entity platform semaphore ()
* Defer creating tasks we know are going to wait on the entity platform semaphore

When looking at whats going on with aiomonitor-ng, I noticed
we end up creating a lot of tasks that block waiting for the
executor because of the entity platform parallel_updates semaphore.

When we know the tasks are going to block we now await them
in sequence to avoid feeding the loop a herd of tasks that
will block on the semaphore

* change during iteration fix

* change during iteration fix

* cleanup

* cleanup

* fix vizio test
2023-05-27 19:58:02 -04:00
J. Nick Koston
5feceee588
Improve performance when serializing small bits of JSON ()
* Improve performance when serializing small bits of JSON

Making json_bytes a partial reduced the run time to
build the small JSON messages by ~18.75%

We serialize a lot of small messages over the websocket

* typing
2023-05-27 19:53:52 -04:00
J. Nick Koston
560e744f1e
Reduce overhead to filter entities in the recorder ()
* Reduce overhead to filter entities in the recorder

* fix type
2023-05-27 19:52:42 -04:00
J. Nick Koston
3a1389c3b4
Switch some frequently called call_laters to call_at ()
* Switch some frequently called call_laters to call_at

call_at is a bit faster than call_later since call_later
is a wrapper around call_at.

We call at lot of these at startup so it helps a bit when
we are resource constrained

* update test

* update test
2023-05-27 19:45:35 -04:00
Erik Montnemery
d4462829f5
Add CONFIG_SCHEMA to analytics () 2023-05-26 16:29:32 +02:00
Erik Montnemery
a71c097aeb
Revert "Allow setting an entity's name by its device class" () 2023-05-25 17:20:54 +02:00
J. Nick Koston
5c6ed8f6d5
Use call_at for events instead call_later ()
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
2023-05-24 21:04:07 +02:00
Mike Degatano
08a719e09e
Add backup location and mount failed repair ()
* Add backup location and mount failed repair

* Fix coverage

* Change storage_location to backup_location

* Use backticks

* Update homeassistant/helpers/selector.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-05-24 10:33:41 +02:00
J. Nick Koston
aa937b1640
Use slots for template RenderInfo () 2023-05-22 08:52:49 +02:00
J. Nick Koston
b993fe1c9d
Cache generation of the service descriptions () 2023-05-16 21:42:37 -05:00
J. Nick Koston
32b70ea133
Bump PyJWT to 2.7.0 () 2023-05-16 10:26:04 +02:00
J. Nick Koston
99265a983a
Speed up reconnects by caching state serialize () 2023-05-16 02:33:12 -05:00
J. Nick Koston
72a6d3a748
Re-enable cleanup_closed on cpython >= 3.11.4 () 2023-05-15 21:29:41 +02:00
J. Nick Koston
3314eed8d1
Switch to using a ContextVar for template RenderInfo ()
The ContextVar is about 40% faster than the attr
and dict lookups
2023-05-14 12:23:31 -04:00
J. Nick Koston
7d371a33bb
Disable cleanup_closed for aiohttp.TCPConnector with cpython 3.11.1+ ()
* Disable cleanup_closed for aiohttp.TCPConnector with cpython 3.11.2+

There is currently a relatively fast memory leak when using
cpython 3.11.2+ and cleanup_closed with aiohttp

For my production instance it was leaking ~450MiB per day
of `MemoryBIO`, `SSLProtocol`, `SSLObject`, `_SSLProtocolTransport`
`memoryview`, and `managedbuffer` objects

see https://github.com/aio-libs/aiohttp/issues/7252
see https://github.com/python/cpython/pull/98540

* Update homeassistant/helpers/aiohttp_client.py
2023-05-13 20:15:02 -04:00
Erik Montnemery
30f52b8d96
Minor typing adjustment in entity_platform () 2023-05-12 15:17:01 +02:00
J. Nick Koston
93bfd7d8d0
Small speed up to validating entity ids () 2023-05-12 15:04:09 +02:00
J. Nick Koston
24284fe379
Speed up validating domains in templates ()
This path gets called quite a bit since most templates
access the state via states.DOMAIN...
2023-05-12 14:57:51 +02:00
J. Nick Koston
3c8659d5d7
Fix missing f-string in async_track_utc_time_change () 2023-05-11 08:37:15 +02:00
Erik Montnemery
67c1051305
Allow setting an entity's name by its device class ()
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-05-09 18:55:55 +02:00
G Johansson
6ad4e13b38
Manual trigger entity and refactor command_line switch ()
* TriggerEntity to CoordinatorTriggerEntity

* _render_templates

* split manual vs coordinator

* name

* ManualTriggerEntity

* value

* Remove ManualTriggerEntity

* ManualTriggerEntity

* process_manual_data

* Add test

* imports

* Move ManualTriggerEntity

* cmd_line switch

* Review comments

* Fix templating

* Review comments

* Remove unneeded logging
2023-05-08 10:19:37 +02:00
J. Nick Koston
4c3e98b77c
Fix parallel_updates being acquired too late for entity executor jobs ()
* Fix parallel_updates being acquired too late for entity executor jobs

* tweak
2023-05-06 16:46:00 +02:00
epenet
70bfbde8aa
Add ability to shutdown a coordinator on STOP () 2023-05-05 16:05:03 +02:00
Michael Hansen
74560ab139
Skip unexposed entities in intent handlers ()
* Filter intent handler entities by exposure

* Add test for skipping unexposed entities
2023-05-03 12:18:31 -04:00
Erik Montnemery
0126cfa9d9
Allow exposing any entity to the default conversation agent ()
* Allow exposing any entity to the default conversation agent

* Tweak

* Fix race, update tests

* Update tests
2023-05-03 09:45:54 -04:00
Bram Kragten
aa4544accb
Add assist pipeline and language selectors () 2023-04-26 18:39:02 +02:00
G Johansson
1fa82fa886
Move TriggerBaseEntity into helpers ()
* Move TriggerBaseEntity

* mypy
2023-04-25 09:56:40 +02:00
J. Nick Koston
fba7c6cacd
Remove deprecated async_get_registry ()
Deprecated in 2021 via , report was added a year ago in 
2023-04-23 23:02:21 -04:00
epenet
79ad9a3646
Shutdown coordinator on entry unload ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-04-21 10:07:31 +02:00
Erik Montnemery
03dcb915e3
Add missing callback decorator on StorageCollectionWebsocket.ws_list_item () 2023-04-20 07:58:11 -04:00
epenet
ae0cbffdd8
Add ability to shutdown update coordinator ()
* Add ability to shutdown update coordinator

* Adjust nibe_heatpump

* Add tests

* Use async

* Remove duplicate code in update coordinator

* Adjust

* Revert nibe changes - it can now be done in a follow-up PR

* Adjust

* Fix incorrect merge

* async_fire_time_changed
2023-04-18 18:56:43 +02:00