Commit Graph

520 Commits

Author SHA1 Message Date
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
J. Nick Koston
f8934175cb Prevent integrations from retrying setup once shutdown has started (#88818)
* Prevent integrations from retrying setup once shutdown has started

* coverage
2023-02-26 22:01:02 -05:00
Paulus Schoutsen
3a32d2bdcb Add background tasks to config entries (#88335)
* Use a set for config entries task tracking

* Allow adding background tasks to config entries

* Add tests for config entry add tasks

* Update docstrings on core create task

* Migrate roon and august

* Use in more places

* Guard for None
2023-02-17 13:50:05 -05:00
Marc Mueller
342b406dc0 Add Self typing (1) [mypy 1.0] (#87598) 2023-02-06 22:29:47 -06:00
J. Nick Koston
7ddb467ba6 Increase async_setup_platforms deprecation logging to warning (#86582) 2023-01-25 14:38:26 +01:00
Ville Skyttä
5f0adfe6e4 Add missing config flow abort strings (#86180)
* Add missing `already_configured` and `already_in_progress` abort strings

* Note required strings.json entries in config_entries aborting functions
2023-01-24 08:59:32 +02:00
Marc Mueller
6397138589 Update Optional typing (1) [Py310] (#86417)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-01-23 09:56:10 +01:00
Franck Nijhof
79b52a2b41 Stricter pylint message control (#86154) 2023-01-20 13:47:55 +01:00
Erik Montnemery
f17a829bd8 Only wait for import flows to initialize at setup (#86106)
* Only wait for import flows to initialize at setup

* Update hassio tests

* Update hassio tests

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-01-18 10:44:18 +01:00
Erik Montnemery
3cd6bd87a7 Remove config entry specifics from FlowManager (#85565) 2023-01-17 15:26:17 +01:00
Franck Nijhof
64c2340fab Core code styling improvements (#85963) 2023-01-15 23:00:51 +01:00
Erik Montnemery
22dbbd4b71 Revert "Disable sky connect config entry if USB stick is not plugged in" (#85103) 2023-01-04 11:33:16 +01:00
Erik Montnemery
472c23d35f Disable sky connect config entry if USB stick is not plugged in (#84975)
* Disable sky connect config entry if USB stick is not plugged in

* Remove debug stuff
2023-01-02 22:24:59 +01:00
J. Nick Koston
4296f227cf Fix thundering heard in setup_again when there are many integrations (#84670) 2022-12-27 15:59:42 -10:00
Franck Nijhof
b0cee0bc46 String formatting and max line length - Part 1 (#84390)
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-12-22 10:12:50 +01:00
Erik Montnemery
bf4c399b19 Improve data entry flow typing (#84030) 2022-12-15 12:41:20 +01:00
Erik Montnemery
cc132bfad6 Make it optional to provide a title when finishing a FlowHandler (#83534)
* Make it optional to provide a title when finishing a FlowHandler

* Make ConfigEntry.title a str

* Revert changes in ConfigFlow

* Adjust tests
2022-12-09 10:24:08 +01:00
Michael
444ad52757 Fix info message in config_entries handle_reload (#82798) 2022-11-27 14:34:01 -05:00