Commit Graph

537 Commits

Author SHA1 Message Date
J. Nick Koston
4bc28489c5 Improve performance of waiting for after dependencies and device config entries (#110902)
To wait for after dependencies we created a task to wait an asyncio.Event object,
instead of using an Event we can use an asyncio.Future instead and avoid the need
for a task wrapper
2024-02-19 10:28:50 +01:00
J. Nick Koston
0a01161cdd Cache JSON representation of ConfigEntry objects (#110823)
* Cache JSON representation of ConfigEntry objects

* fix recursive set

* tweak

* adjust

* order
2024-02-17 20:52:39 -05:00
J. Nick Koston
094fd3d918 Simplify ConfigFlow._async_current_entries (#110799)
async_entries supports the flags needed for this function so we
can now hand it off instead
2024-02-17 18:04:27 +01:00
J. Nick Koston
0bf95df4d6 Avoid creating tasks to setup ignored and disabled config entries (#110756)
* Avoid creating tasks to setup ignored and disabled config entries

* lint
2024-02-17 10:34:03 +01:00
J. Nick Koston
d449eadac3 Guard ConfigEntry from being mutated externally without using the built-in interfaces (#110023)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-02-16 10:15:05 -06:00
J. Nick Koston
4c11371898 Adjust ConfigEntry.async_setup comments to be more clear (#110726) 2024-02-16 10:13:35 -06:00
J. Nick Koston
01c3205635 Small performance improvements to config entry setup retry (#110448)
* Small performance improvements to config entry setup retry

- cache some properties that never change
- avoid loader.async_get_integration when we already have it
- avoid multiple integration.domain checks

* tweaks
2024-02-13 13:28:52 +01:00
J. Nick Koston
6e134b325d Make ConfigEntryItems responsible for updating unique ids (#110018)
* Make ConfigEntryItems responsible for updating unique ids

* Make ConfigEntryItems responsible for updating unique ids

* Make ConfigEntryItems responsible for updating unique ids

* Make ConfigEntryItems responsible for updating unique ids

* Make ConfigEntryItems responsible for updating unique ids
2024-02-09 08:51:02 -05:00
Erik Montnemery
793b6aa97d Allow passing version to ConfigEntry.async_update_entry (#110077)
Allow passing minor_version and version to ConfigEntry.async_update_entry
2024-02-09 10:10:25 +01:00
Erik Montnemery
2f15053311 Don't blow up if config entries have unhashable unique IDs (#109966)
* Don't blow up if config entries have unhashable unique IDs

* Add test

* Add comment on when we remove the guard

* Don't stringify hashable non string unique_id
2024-02-08 15:39:01 +01:00
Marc Mueller
5de76c0be0 Include exception when reraising inside except (#109706) 2024-02-06 12:17:39 +01:00
Erik Montnemery
ffdcdaf43b Create issues for reauth flows (#109105) 2024-01-31 15:05:52 +01:00
J. Nick Koston
dff5e45761 Small speed up to listing config entries in the websocket api (#108892) 2024-01-25 20:20:19 -10:00
Jan-Philipp Benecke
0b79504cf0 Extend config entry update/abort helper to also update unique id (#108681)
* Extend config entry update/abort helper to also update unique id

* Move kwarg to end

* Make additionals kwargs only
2024-01-22 23:01:55 +01:00
Jan-Philipp Benecke
988d72b8b6 Add helper function to update and reload config entry to config flow (#108034)
* Add helper function to update and reload config entry to config flow

* Use async_create_task

* Remove await

* Reload only when update & add task name

* Rename function
2024-01-22 17:40:20 +01:00
J. Nick Koston
3649cb96de Refactor config entry storage and index (#107590) 2024-01-13 10:34:15 -10:00
J. Nick Koston
4b7a313ece Use identity checks for CoreState (#107846)
Some of the checks used ==, and some used is. Switch
everything to is as its faster
2024-01-12 10:21:26 +01:00
J. Nick Koston
b2f7fd12a2 Add comment to ConfigEntry.async_setup about race safety (#107756) 2024-01-10 13:03:09 -10:00
Erik Montnemery
6908497c3d Add minor version to config entries (#105479) 2023-12-12 08:44:35 +01:00
Jan Bouwhuis
487ff8cd7f Rename ex to exc as name for exceptions (#104479) 2023-11-25 08:30:18 +01:00
J. Nick Koston
9b27552238 Fix race in starting reauth flows (#103130) 2023-10-31 12:38:05 -05:00
Franck Nijhof
6853d54050 Remove logging of retrying config entry warning (#101483) 2023-10-05 22:12:01 +02:00
J. Nick Koston
a03ad87cfb Avoid ConfigEntry lookups in hass.config_entries.async_entries for domain index (#100598) 2023-09-20 18:43:15 +02:00
J. Nick Koston
1d5905b591 Use is for UNDEFINED check in async_update_entry (#100599) 2023-09-20 01:08:32 +02:00
J. Nick Koston
e3f228ea52 Switch config_entries to use loop.create_future() (#100011) 2023-09-09 17:34:49 -05:00
J. Nick Koston
e5ebba0753 Fix module check in _async_get_flow_handler (#99509)
We should have been checking for the module in hass.data[DATA_COMPONENTS]
and not hass.config.components as the check was ineffective if there were
no existing integrations instances for the domain which is the case for
discovery or when the integration is ignored
2023-09-04 14:19:10 -04:00
J. Nick Koston
b8f8cd1797 Reduce overhead to retry config entry setup (#99471) 2023-09-02 16:46:53 -05:00
J. Nick Koston
99e97782b6 Improve performance of abort_entries_match (#98932)
* Improve performance of abort_entries_match

In #90406 a ChainMap was added which called __iter__
and __contains__ which ends up creating temp dicts
for matching

174e9da083/Lib/collections/__init__.py (L1022)

We can avoid this by removing the ChainMap since there
are only two mappings to match on.

This also means options no longer obscures data

* adjust comment
2023-08-24 15:34:45 +02:00
Erik Montnemery
d282ba6bac Use a single WS command for group preview (#98903)
* Use a single WS command for group preview

* Fix tests
2023-08-24 11:59:24 +02:00
Erik Montnemery
b885dfa5a8 Add preview to sensor group config and option flows (#83638) 2023-08-22 10:29:16 +02:00
J. Nick Koston
1adfa6bbeb Reduce overhead to start a config entry flow by optimizing fetching the handler (#97883) 2023-08-06 20:25:03 -10:00
Franck Nijhof
30058297cf Migrate backported StrEnum to built-in StrEnum (#97101) 2023-07-23 23:19:24 +02:00
Marc Mueller
77f38e33e5 Import names from typing instead of typing_extensions [3.11] (#97065) 2023-07-22 17:03:44 -05:00
J. Nick Koston
9fba6870fe Fix task leak on config entry unload/retry (#96981)
Since the task was added to self._tasks without a `task.add_done_callback(self._tasks.remove)`
each unload/retry would leak a new set of tasks
2023-07-20 21:00:07 -04:00
J. Nick Koston
6bb81b862c Add a message to the config entry cancel call (#96925) 2023-07-19 19:22:38 -05:00
J. Nick Koston
085eebc903 Make async_set_state in ConfigEntry a protected method (#96727)
I added this in #77803 but I never designed it to be called
externally. External usage may break at any time because the
class is not designed for this. I should have made it protected
in the original PR but I did not think it would get called
externally (my mistake)
2023-07-17 08:58:12 +02:00
Paulus Schoutsen
0f725a24bd Remove the weak ref for tracking update listeners (#95798) 2023-07-03 13:56:21 -05:00
J. Nick Koston
34b725bb99 Debounce discoveries to improve event loop stability at the started event (#94690)
* Debounce discoveries to improve event loop stability at the started event

The first one is immediate and anything that fires within the next
second will be debounced to only happen once every second

* fix mock
2023-06-15 22:15:07 -04:00
J. Nick Koston
9e666ae0c0 Reduce in progress flow matching overhead (#94403)
* Reduce config flow matching overhead

Much of the config flow matching is happening on the context data
after converting via a series of functions. Avoid the conversions
by passing the context matcher deeper into the stack so only
relvant entries need to be processed.

The goal is to reduce the overhead and reduce the chance
the event loop falls behind at the started event when
all the discoveries are processed

* Reduce config flow matching overhead

Much of the config flow matching is happening on the context data
after converting via a series of functions. Avoid the conversions
by passing the context matcher deeper into the stack so only
relvant entries need to be processed.

The goal is to reduce the overhead and reduce the chance
the event loop falls behind at the started event when
all the discoveries are processed

* Reduce config flow matching overhead

Much of the config flow matching is happening on the context data
after converting via a series of functions. Avoid the conversions
by passing the context matcher deeper into the stack so only
relvant entries need to be processed.

The goal is to reduce the overhead and reduce the chance
the event loop falls behind at the started event when
all the discoveries are processed

* augment cover
2023-06-11 10:41:38 +02:00
J. Nick Koston
cf69da40f3 Only check support_entry_unload/support_remove_from_device once (#92041) 2023-04-26 10:23:18 +02:00
J. Nick Koston
739963b5ee Remove deprecated async_setup_platforms (#91929) 2023-04-23 22:38:35 -05:00
epenet
3364f0fce2 Allow config entries unload action to be coroutine (#91531)
* Allow config entries unload action to be coroutine

* Adjust comment
2023-04-17 08:41:25 -04:00
epenet
a061f56833 Fix lingering timer in EntityRegistryDisabledHandler (#91376)
Mark EntityRegistryDisabledHandler as cancellable
2023-04-14 06:37:49 +02:00
epenet
611d4135fd Add ComponentProtocol to improve type checking (#90586) 2023-03-31 14:19:58 -04:00
epenet
f7925763a4 Make abort_entries_match available in options flow (#90406)
* Make abort_entries_match available in options flow

* Add tests

* Exclude ignore entries and add test

* Move to OptionsFlow

* Adjust tests

* Use mock_config_flow

* Use AbortFlow

* Remove duplicate code
2023-03-29 17:20:51 +02:00
Erik Montnemery
3931e11fd9 Try to load integration before starting option flow (#90111)
* Try to load integration before starting option flow

* Adjust tests
2023-03-22 20:10:10 +01:00
Jesse Moody
d7de23fa65 Adjust eventloop -> event loop spelling (#89931)
eventloop -> event loop spelling
2023-03-19 21:53:21 +01:00
J. Nick Koston
4ce36366c3 Add names to the config entry setup and shutdown tasks (#89309)
* name the entry setup tasks

* name a few more tasks

* Update homeassistant/config_entries.py

* Update homeassistant/setup.py
2023-03-08 10:19:36 -05:00
J. Nick Koston
11681f3f31 Pass a helpful name when creating common asyncio tasks in core (#89171) 2023-03-05 12:46:02 +01:00
Erik Montnemery
2c2489284b Catch CancelledError when setting up components (#88635)
* Catch CancelledError when setting up components

* Catch CancelledError when setting up components

* Also catch SystemExit
2023-02-27 09:29:14 -05:00