Commit Graph

2411 Commits (a033574ee2b5f8c0777f96857f80598d4be77712)

Author SHA1 Message Date
Marc Mueller d7e7dc96cc
Make Event data generic (#111955) 2024-03-08 13:46:16 +01:00
Marc Mueller 2d701d5a7d
Use aiohttp.AppKey for http cors keys (#112658) 2024-03-08 11:51:59 +01:00
Marc Mueller 4893087a7e
Add TypeVar defaults for DataUpdateCoordinator (#111949) 2024-03-08 11:14:16 +01:00
J. Nick Koston caefdc6192
Avoid writing registries to disk during startup (#112662) 2024-03-07 19:14:42 -10:00
J. Nick Koston a6b17dbe68
Schedule polling as periodic tasks (#112640)
* Schedule periodic coordinator updates as background tasks.

Currently, the coordinator's periodic refreshes delay startup because they are not scheduled as background tasks. We will wait if the startup takes long enough for the first planned refresh. Another coordinator's scheduled refresh will be fired on busy systems, further delaying the startup. This chain of events results in the startup taking a long time and hitting the safety timeout because too many coordinators are refreshing.

This case can also happen with scheduled entity refreshes, but it's less common. A future PR will address that case.

* periodic_tasks

* periodic_tasks

* periodic_tasks

* merge

* merge

* merge

* merge

* merge

* fix test that call the sync api from async

* one more place

* cannot chain

* async_run_periodic_hass_job

* sun and pattern time changes from automations also block startup

* Revert "sun and pattern time changes from automations also block startup"

This reverts commit 6de2defa05.

* make sure polling is cancelled when config entry is unloaded

* Revert "Revert "sun and pattern time changes from automations also block startup""

This reverts commit e8f12aad55.

* remove DisabledError from homewizard test as it relies on a race

* fix race

* direct coverage
2024-03-07 23:32:26 -05:00
Erik Montnemery 49d20eedd4
Remove local imports of hass-nabucasa (#112634) 2024-03-07 20:37:35 +01:00
Marc Mueller 8ca127df2a
Use KEY_HASS [h-z] (#112610) 2024-03-07 18:03:44 +01:00
Marc Mueller 531e25cbc6
Change KEY_HASS to be an aiohttp AppKey (#111954) 2024-03-07 13:37:48 +01:00
Erik Montnemery 82efb3d35b
Make FlowResult a generic type (#111952) 2024-03-07 12:41:14 +01:00
J. Nick Koston 1fb9cfe37e
Speed up the frame helper (#112562) 2024-03-06 20:54:09 -10:00
J. Nick Koston a7b4cd3512
Pass job type to event listeners when creating entities (#112551) 2024-03-06 16:10:07 -10:00
J. Nick Koston 84455dbe1d
Avoid having to work out the job type for each entity service at startup (#112557) 2024-03-06 16:09:55 -10:00
Erik Montnemery 8c2c3e0839
Improve integration_entities template function (#111943) 2024-03-06 11:05:06 +01:00
Jan-Philipp Benecke 995d93dd33
Remove deprecated `hass.components` usage in config entry flow (#111880)
* Remove deprecated `hass.components` usage in config entry flow

* Do local import

* Also use local import for webhook
2024-03-06 09:07:09 +01:00
J. Nick Koston f3a9756f81
Avoid waiting for integration platforms in the parent integration (#112467) 2024-03-05 21:16:42 -10:00
J. Nick Koston 8fe80a4766
Migrate remaining get_platform in check_config to async_get_platform (#112470)
These were very likely to be cached so they were low on the
list to migrate, but since they are called in the event loop
its best to be sure we do no blocking I/O
2024-03-05 23:47:41 -05:00
J. Nick Koston 982c8f8f4a
Fix incorrect scope on checking files to load in translations (#112457)
discovered in https://github.com/home-assistant/core/pull/112295#discussion_r1513505710

We only checked if the last language had files to load
instead of all of them. The checks for each language
are the same because the only reason we would skip
a language is a missing/broken integration or the integration
is a single file. Both of these loop conditions are always
the same reguardless of the language so the check worked
2024-03-05 23:46:24 -05:00
J. Nick Koston e568f867d2
Adjust MAX_LOAD_CONCURRENTLY constant to allow 6 storage loaders (#112468) 2024-03-05 16:31:10 -10:00
J. Nick Koston fbabbc8f92
Limit legacy state translations to custom components (#112295)
* Limit legacy state translations to custom components

We were trying to load **thousands** of `*.light.json`, `*.switch.json` files at run time that did not exist.

There have been replaced with entity translations: https://github.com/home-assistant/developers.home-assistant/pull/1557 https://github.com/home-assistant/core/pull/82701

https://github.com/home-assistant/core/pull/112023 will completely remove them, but
for now we will only load them for custom components to reduce the number
of files having to be examined

* reduce

* reduce

* reduce

* reduce

* comment

* coverage

* try to remove empty dict in loaded_translations fallback when missing
2024-03-05 17:27:45 -05:00
Erik Montnemery 3d3e9900c3
Add TypeVar default for FlowResult (#112345)
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2024-03-05 22:52:11 +01:00
J. Nick Koston 390f5822fe
Initialize triggers eagerly (#112294)
Most of these will never suspend and do not need
to be scheduled as tasks on the event loop
2024-03-05 09:58:43 -05:00
J. Nick Koston f3eb292c2d
Remove async_entity_ids and get_entity_ids from entity registry (#112311)
added in #112277 but not used yet.
2024-03-05 14:50:41 +01:00
J. Nick Koston 8b017016b0
Refactor integration platforms to import in the executor (#112168)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-03-04 19:21:18 -10:00
J. Nick Koston 1e173e82d0
Add support for preloading platforms in the loader (#112282)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-03-04 16:33:12 -10:00
J. Nick Koston 2c179dc5fb
Reduce some linear searches to cleanup the device registry (#112277)
Some of the data we had to search for was already available
in a dict or underlying data structure. Make it available
instead of having to build it every time.

There are more places these can be used, but I only did
the device registry cleanup for now
2024-03-04 20:59:12 -05:00
RoboMagus b381922a20
Issues template function (#95206)
* Add 'issues' template function for listing active issues.

* Add issue template function test

* Add 'issue' template function for getting specific issue by domain and issue_id

* Remove comment

* Fix function description

* Remove reduntant function,
Fix tests

* remove pass_context

* remove issues filter

Co-authored-by: Erik Montnemery <erik@montnemery.com>

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-03-04 14:22:14 +01:00
J. Nick Koston 331989de4c
Migrate condition/state/trigger helper to use async_get_platform (#112144)
Currently these would always load the platform in the loop
if it was not already loaded
2024-03-03 21:20:47 -05:00
J. Nick Koston da6eca7b68
Avoid compiling entity service schema when passed defaults (#112099)
* Avoid compiling entity service schema when passed defaults

* dry
2024-03-03 12:50:04 -05:00
J. Nick Koston a37c82e34c
Add comment to integration platform helper about blocking I/O (#112103) 2024-03-03 07:00:35 -10:00
J. Nick Koston c8cb0ff61d
Avoid trying to import platforms that do not exist (#112028)
* Avoid trying to import platforms that do not exist

* adjust

* fixes

* cleanup

* cleanup

* cleanup

* Apply suggestions from code review

* docs

* fixes

* fixes

* comment

* coverage

* coverage

* coverage

* Switch config to use async_get_component

This was another path where integrations that were marked to load in the executor
would be loaded in the loop

* Switch config to use async_get_component/async_get_platform

This was another path where integrations that were marked to load in the executor
would be loaded in the loop

* merge

* refactor

* refactor

* coverage

* preen

* preen
2024-03-02 22:14:28 -05:00
J. Nick Koston 6421a08ba8
Avoid expensive inspect calls in config validators (#112085)
* Avoid expensive inspect calls in config validators

inspect has a performance problem https://github.com/python/cpython/issues/92041

We now avoid calling inspect unless we are going to log

* remove unused

* reduce

* get_integration_logger
2024-03-02 21:50:35 -05:00
Jan-Philipp Benecke 196089e8b7
Remove deprecated `hass.components.hassio` usage (#111878) 2024-03-02 15:38:31 +01:00
Marc Mueller daf8d1939b
Fix generic HassJob typing (#111973) 2024-03-01 20:51:45 +01:00
G Johansson 9989a63cdf
Add reconfigure step to config flow (#108794)
* Initial commit reconfigure

* test config config_entries

* Fix reconfigure

* test_config_entries

* review comment

* No reconfigure if reauth ongoing

* Fix tests

* Fix tests

* handle source creating flows

* combine

* No black

* Also check reconfigure in reauth flow

* Fix support

* Add entry id

* reset data entry flow

* Mods

* context data

* reset formatting

* Fix config flow platforms

* Fix tests

* Fix step message

* Handling reconfigure step

* Fix more tests

* Config entries tests

* entry_id always means reconfigure

* Mods

* Remove no longer valid exception

* Fixes

* reset silabs test

* dev reg

* resets

* assist pipeline

* Adjust config_entries

* Fix

* Fixes

* docstrings

* Review comment

* docstring
2024-03-01 12:29:35 +01:00
Michael Hansen 0d0b64d351
Move HassSetPosition to homeassistant domain (#111867)
* Move HassSetPosition to homeassistant domain

* Add test for unsupported domain with HassSetPosition

* Split service intent handler

* cleanup

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-02-29 21:53:52 -05:00
J. Nick Koston c1750f7c3a
Fix circular imports in core integrations (#111875)
* Fix circular imports in core integrations

* fix circular import

* fix more circular imports

* fix more circular imports

* fix more circular imports

* fix more circular imports

* fix more circular imports

* fix more circular imports

* fix more circular imports

* adjust

* fix

* increase timeout

* remove unused logger

* keep up to date

* make sure its reprod
2024-02-29 21:04:41 -05:00
Erik Montnemery a0e558c457
Add generic classes BaseFlowHandler and BaseFlowManager (#111814)
* Add generic classes BaseFlowHandler and BaseFlowManager

* Migrate zwave_js

* Update tests

* Update tests

* Address review comments
2024-02-29 16:52:39 +01:00
Erik Montnemery 3a8b6412ed
Remove areas template filter (#111827) 2024-02-29 10:52:26 -05:00
Jan-Philipp Benecke bc6b4d01c8
Deprecate `hass.components` and log warning if used inside custom component (#111508)
* Deprecate @bind_hass and log error if used inside custom component

* Log also when accessing `hass.components`

* Log warning only when `hass.components` is used

* Change version

* Process code review
2024-02-29 12:25:46 +01:00
Jan-Philipp Benecke f31244bac4
Add normalized name registry items base class (#111666)
* Add normalized name base registry items class

* Add tests
2024-02-29 01:31:33 +01:00
Erik Montnemery b336095239
Allow translating device names (#110711)
* Allow translating device names

* Don't keep a reference to translations in config entry

* Update kitchen_sink tests

* Add tests
2024-02-28 15:59:59 +01:00
J. Nick Koston 913ee90e1a
Use eager tasks when updating entity state after service calls (#111702)
In a multi-entity update case the state update may not need
to suspend and can get executed without scheduling a task
on the event loop
2024-02-28 12:46:32 +01:00
J. Nick Koston 69a1da0a1a
Make entity component platform setup tasks eager (#111698)
Many of these that setup from YAML will never suspend
because they do no I/O
2024-02-28 12:44:23 +01:00
Jan-Philipp Benecke ebfba7258e
Revert "Drop `@bind_hass` use from hassio component (#111522)" (#111705)
This reverts commit 4e4345f04e.
2024-02-28 10:51:37 +01:00
J. Nick Koston 78bb6dbe75
Reduce latency in storage by making the tasks eager (#111500)
* Reduce latancy to load storage by making the task eager

This changes the semantics a bit under the hood because it
can raise sooner which means we do not store the task
as _load_task if it raises right away. That means
concurrent calls that result in failure are likely to try
again now which will be a tiny performance hit for this
case.

* fix

* will now finish in time
2024-02-27 23:27:37 -05:00
Jan-Philipp Benecke 4e4345f04e
Drop `@bind_hass` use from hassio component (#111522)
* Drop `@bind_hass` use from hassio component

* Add comment why we import locally

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-02-28 00:25:46 +01:00
Jan-Philipp Benecke c8b7f098e5
Avoid call to `hass.helpers.store` in FloorRegistry (#111554)
* Avoid call to `hass.helpers.store` in FloorRegistry

* Change type annotation
2024-02-27 23:03:28 +01:00
J. Nick Koston a6f4f6eae8
Use eager task creation to add entities to entity platform (#111553) 2024-02-27 09:54:51 -10:00
Jan-Philipp Benecke 070b411820
Avoid call to `hass.helpers.store` in LabelRegistry (#111555)
* Avoid call to `hass.helpers.store` in LabelRegistry

* Change type annotation
2024-02-27 09:37:45 -05:00
J. Nick Koston 08e0008d31
Use an eager task to setup entity platforms (#111574)
* Use an eager task to setup entity platforms

Ideally we would have awaited this function instead, but we want
to shield it from cancellation so we wrap it in asyncio.shield
which schedules it as a task. Since we have integrations that
never suspend in async_setup_entry, we can avoid scheduling on
the evnet loop with an eager task for this case

* its an executor future

* its an executor future

* fix

* doc string lied
2024-02-27 08:45:45 -05:00