Commit Graph

498 Commits (dev)

Author SHA1 Message Date
Erik Montnemery 59a690f214
Use ConfigFlow.has_matching_flow to deduplicate homekit_controller flows (#126894) 2024-09-27 13:41:55 +02:00
Erik Montnemery 3c0be47d3c
Add FlowManager.async_has_matching_flow (#126804)
* Add FlowManager.async_flow_has_matching_flow

* Revert changes from the future

* Apply suggested changes to apple_tv config flow

* Rename methods after discussion

* Update homeassistant/data_entry_flow.py

Co-authored-by: J. Nick Koston <nick@koston.org>

* Move deduplication functions to config_entries, add tests

* Adjust tests

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-09-27 10:51:36 +02:00
Erik Montnemery 7d61cb1ef5
Remove unignore flow (#126765) 2024-09-25 20:29:14 +02:00
Erik Montnemery 589910b49b
Reinitialize zeroconf discovery flow on config entry removal (#126595) 2024-09-24 13:37:28 +02:00
Erik Montnemery 4a66395d51
Simplify signal_discovered_config_entry_removed job (#126591) 2024-09-24 08:44:11 +02:00
Erik Montnemery d82bff1bc2
Index config entry discovery_keys by discovery domain (#126563)
* Index config entry discovery_keys by discovery domain

* Add new signal

* Update tests

* Update homeassistant/config_entries.py

Co-authored-by: J. Nick Koston <nick@koston.org>

* Fix imports

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-09-23 21:48:11 +02:00
Erik Montnemery b2982c18bb
Reinitialize zeroconf discovery flow on unignore (#125753)
* Reinitialize zeroconf discovery flow on unignore

* Adjust tests

* Improve comments

* Fix logic for updating discovery keys

* Add tests

* Use mock_config_flow helper in new config_entries test

* Add discovery_keys attribute to ConfigEntry

* Update zeroconf rediscovery

* Change type of ConfigEntry.discovery_keys

* Update tests

* Fix DiscoveryKey.from_json_dict and add tests

* Fix test

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-09-23 16:49:21 +02:00
Erik Montnemery 252ce2c95b
Improve FlowManager.async_finish_flow docstring (#126178)
* Improve FlowManager.async_finish_flow docstring

* Fix typos
2024-09-18 18:19:13 +02:00
epenet 3536ba43f5
End deprecation setting disabled_by as string (#125646) 2024-09-10 20:39:51 +02:00
epenet 97c55ae6f1
Warn on non-string config entry unique IDs (#125662)
* Warn on non-string config entry unique IDs

* Add comment

* isinstance
2024-09-10 15:30:03 +02:00
G Johansson 436ac72b82
End deprecation setting attributes directly on config entry (#123729)
* End deprecation setting attr directly on config entry

* Update ollama test

* Fix android_tv
2024-09-03 15:56:00 +02:00
Erik Montnemery 9cae786f40
Add ConfigEntries.async_get_loaded (#124705) 2024-08-27 14:20:57 +02:00
J. Nick Koston 91951ed734
Speed up initializing config flows (#124015) 2024-08-16 16:48:03 -05:00
J. Nick Koston b6de2cd741
Unpack non-performant any expressions in config flow discovery path (#123124) 2024-08-03 17:33:46 -05:00
Robert Resch ad50136dbd
Add created_at/modified_at to config entries (#122456) 2024-07-29 22:08:46 +02:00
epenet 07c7bb8b2a
Use HOMEASSISTANT_DOMAIN alias for core DOMAIN (#122760) 2024-07-29 13:35:36 +02:00
Marc Mueller ca55986057
Import Generator from collections.abc (1) (#120914) 2024-07-01 11:51:51 +02:00
Erik Montnemery 471e2a17a2
Improve error messages when config entry is in wrong state (#119591)
* Improve error messages when config entry is in wrong state

* Apply suggestions from code review

Co-authored-by: Joakim Sørensen <ludeeus@ludeeus.dev>

* Adjust tests

---------

Co-authored-by: Joakim Sørensen <ludeeus@ludeeus.dev>
2024-06-14 08:00:36 +02:00
J. Nick Koston dbd3147c9b
Remove `async_late_forward_entry_setups` and instead implicitly hold the lock (#119088)
* Refactor config entry forwards to implictly obtain the lock instead of explictly

This is a bit of a tradeoff to not need async_late_forward_entry_setups

The downside is we can no longer detect non-awaited plastform setups
as we will always implicitly obtain the lock instead of explictly.

Note, this PR is incomplete and is only for discussion purposes
at this point

* preen

* cover

* cover

* restore check for non-awaited platform setup

* cleanup

* fix missing word

* make non-awaited test safer
2024-06-12 21:06:11 -04:00
Jake Martin 9bb9792607
Move runtime_data deletion after unload (#119224)
* Move runtime_data deletion after unload.

Doing this before unload means we can't use, eg. the coordinator, during teardown.

* Re-order config entry on unload

* Add test

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-06-10 22:11:07 -04:00
Marc Mueller fe21e2b8ba
Import Generator from typing_extensions (1) (#118986) 2024-06-06 17:02:13 +02:00
J. Nick Koston ed0568c655
Ensure config entries are not unloaded while their platforms are setting up (#118767)
* Report non-awaited/non-locked config entry platform forwards

Its currently possible for config entries to be reloaded while their platforms
are being forwarded if platform forwards are not awaited or done after the
config entry is setup since the lock will not be held in this case.

In https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards
we advised to await platform forwards to ensure this does not happen, however
for sleeping devices and late discovered devices, platform forwards may happen
later.

If config platform forwards are happening during setup, they should be awaited

If config entry platform forwards are not happening during setup, instead
async_late_forward_entry_setups should be used which will hold the lock to
prevent the config entry from being unloaded while its platforms are being
setup

* Report non-awaited/non-locked config entry platform forwards

Its currently possible for config entries to be reloaded while their platforms
are being forwarded if platform forwards are not awaited or done after the
config entry is setup since the lock will not be held in this case.

In https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards
we advised to await platform forwards to ensure this does not happen, however
for sleeping devices and late discovered devices, platform forwards may happen
later.

If config platform forwards are happening during setup, they should be awaited

If config entry platform forwards are not happening during setup, instead
async_late_forward_entry_setups should be used which will hold the lock to
prevent the config entry from being unloaded while its platforms are being
setup

* run with error on to find them

* cert_exp, hold lock

* cert_exp, hold lock

* shelly async_late_forward_entry_setups

* compact

* compact

* found another

* patch up mobileapp

* patch up hue tests

* patch up smartthings

* fix mqtt

* fix esphome

* zwave_js

* mqtt

* rework

* fixes

* fix mocking

* fix mocking

* do not call async_forward_entry_setup directly

* docstrings

* docstrings

* docstrings

* add comments

* doc strings

* fixed all in core, turn off strict

* coverage

* coverage

* missing

* coverage
2024-06-04 21:34:39 -04:00
Erik Montnemery 35dcda29b9
Use ULID instead of UUID for config entry id and flow ID (#118677) 2024-06-03 10:34:09 +02:00
Jan-Philipp Benecke 88257c9c42
Allow to reconfigure integrations with `single_config_entry` set (#117939) 2024-05-23 08:41:12 +02:00
J. Nick Koston 13ba8e62a9
Fix race in config entry setup (#117756) 2024-05-20 09:47:47 +02:00
Marc Mueller 4cf0a3f154
Use PEP 695 for function annotations (3) (#117660) 2024-05-18 11:43:32 +02:00
Marc Mueller 87bb7ced79
Use PEP 695 for simple type aliases (#117633) 2024-05-17 14:42:21 +02:00
J. Nick Koston 7871e9279b
Adjust thread safety check messages to point to developer docs (#117392) 2024-05-14 15:20:31 +02:00
Erik Montnemery 0b47bfc823
Add minor version + migration to config entry store (#117350) 2024-05-13 10:16:18 +02:00
Erik Montnemery b006aadeff
Remove options from FlowResult (#117351) 2024-05-13 10:11:33 +02:00
Erik Montnemery 90ef19a255
Alphabetize some parts of config_entries (#117347) 2024-05-13 09:39:18 +02:00
Erik Montnemery b09565b4ff
Remove migration of config entry data pre version 0.73 (#117345) 2024-05-13 09:39:04 +02:00
Erik Montnemery d0c60ab21b
Fix typo and useless default in config_entries (#117346) 2024-05-13 09:26:18 +02:00
Marc Mueller 3434fb70fb
Remove ConfigEntry runtime_data on unload (#117312) 2024-05-12 13:53:22 -04:00
J. Nick Koston b061e7d1aa
Small speed up to setting up integrations and config entries (#117278)
* Small speed up to setting up integration and config entries

When profiling tests, I noticed many calls to get_running_loop. In the places
where we are already in a coro, pass the existing loop so it does not have to
be looked up. I did not do this for places were we are not in a coro since there
is risk that an integration could be doing a non-thread-safe call and its better
that the code raises when trying to fetch the running loop vs the performance
improvement for these cases.

* fix merge

* missed some
2024-05-11 22:39:20 -04:00
J. Nick Koston 481de8cdc9
Ensure config entry operations are always holding the lock (#117214)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-05-12 08:20:08 +09:00
J. Nick Koston daef625985
Speed up init and finish flow (#117226)
Since every flow now has to check for single config entry, change
the check to see if a config entry exists first before calling
the _support_single_config_entry_only since _support_single_config_entry_only
has to load the integration which adds up quite a bit in test runs
2024-05-11 09:47:17 +02:00
J. Nick Koston 52cca26473
Use async_get_loaded_integration in config_entries (#117192) 2024-05-11 10:30:34 +09:00
J. Nick Koston 2e60e09ba2
Ensure config entry setup lock is held when removing a config entry (#117086) 2024-05-11 09:47:26 +09:00
J. Nick Koston c74c2f3652
Add state check to config entry setup to ensure it cannot be setup twice (#117193) 2024-05-11 07:09:28 +09:00
J. Nick Koston 89049bc022
Fix config entry _async_process_on_unload being called for forwarded platforms (#117084) 2024-05-08 23:59:37 +02:00
Sid 2cc916db6d
Replace pylint broad-except with Ruff BLE001 (#116250) 2024-05-07 14:00:27 +02:00
Marc Mueller 3d700e2b71
Add HassDict implementation (#103844) 2024-05-07 10:53:13 +02:00
Sid b456d97e65
Replace pylint protected-access with Ruff SLF001 (#115735) 2024-05-06 20:33:26 +02:00
J. Nick Koston 91fa8b50cc
Turn on thread safety checks in async_dispatcher_send (#116867)
* Turn on thread safety checks in async_dispatcher_send

We keep seeing issues where async_dispatcher_send is called from
a thread which means we call the callback function on the other
side in the thread as well which usually leads to a crash

* Turn on thread safety checks in async_dispatcher_send

We keep seeing issues where async_dispatcher_send is called from
a thread which means we call the callback function on the other
side in the thread as well which usually leads to a crash

* adjust
2024-05-05 16:29:43 -04:00
J. Nick Koston 6cf1c5c1f2
Hold a lock to prevent concurrent setup of config entries (#116482) 2024-04-30 18:47:12 -05:00
Marc Mueller dace9b32de
Store runtime data inside ConfigEntry (#115669) 2024-04-30 11:29:43 +02:00
J. Nick Koston 164403de20
Add thread safety checks to async_create_task (#116339)
* Add thread safety checks to async_create_task

Calling async_create_task from a thread almost always results in an
fast crash. Since most internals are using async_create_background_task
or other task APIs, and this is the one integrations seem to get wrong
the most, add a thread safety check here

* Add thread safety checks to async_create_task

Calling async_create_task from a thread almost always results in an
fast crash. Since most internals are using async_create_background_task
or other task APIs, and this is the one integrations seem to get wrong
the most, add a thread safety check here

* missed one

* Update homeassistant/core.py

* fix mocks

* one more internal

* more places where internal can be used

* more places where internal can be used

* more places where internal can be used

* internal one more place since this is high volume and was already eager_start
2024-04-28 18:29:00 -04:00
J. Nick Koston 3f0c0a72db
Prevent setup retry from delaying shutdown (#116328) 2024-04-28 08:13:51 -05:00
J. Nick Koston 76639252c9
Make discovery flow tasks background tasks (#116327) 2024-04-28 08:13:37 -05:00
Jan Bouwhuis 70b358bca1
Always reload after a successful reauth flow (#116026)
* Always reload after a succesfull reauth-flow

* Add test, fix CI failures

* Add kwarg to prevent reloading and tests

* Do not reload entry for bond if it exists

* Remove mocks on internals

* Rename kwarg to always_reload

* Update tests/components/weatherflow_cloud/test_config_flow.py

* Update tests/components/homeworks/test_config_flow.py

* Update tests/components/homeworks/test_config_flow.py

* Rename to option to reload_even_if_entry_is_unchanged
2024-04-24 15:13:33 +02:00
J. Nick Koston e9e401ae29
Migrate discovery debouncer callback to async_fire_internal (#116078) 2024-04-24 11:26:48 +02:00
J. Nick Koston f62a3a7176
Simplify config_entries entity registry filter (#115678) 2024-04-17 09:42:23 -05:00
J. Nick Koston 14b794b0f7
Migrate config entry reauth to use eager_start (#115549) 2024-04-13 18:38:33 -05:00
J. Nick Koston ee535ee611
Ensure test async_create_task eager start behavior matches production (#115517) 2024-04-13 15:58:52 -05:00
J. Nick Koston 08e2b655be
Migrate EntityRegistryDisabledHandler to use async_schedule_reload (#115544)
async_schedule_reload ensures that any setup retries are cancelled
before executing the reload. Its unlikely in this case but its
still possible
2024-04-13 16:30:59 -04:00
J. Nick Koston 82d0f478a5
Hold the reload lock while attempting config entry setup retry (#115538) 2024-04-13 15:26:41 -05:00
J. Nick Koston 28bdbec14e
Bypass ConfigEntry __setattr__ in __init__ (#115405)
ConfigEntries.async_initialize was trigger asyncio warnings because of the CPU time
to call __setattr__ for every variable for each ConfigEntry being loaded at startup
2024-04-11 22:16:01 -04:00
J. Nick Koston ca5ed274cb
Deprecate calling async_listen and async_listen_once with run_immediately (#115169) 2024-04-08 10:07:54 -10:00
Marc Mueller 4e94f11665
Use EventType for entity_registry_updated (#115187) 2024-04-08 08:44:59 -10:00
J. Nick Koston 29bc67234e
Make eager_start default to True for config entry async_create_task (#115047) 2024-04-06 11:22:02 -10:00
J. Nick Koston 52957849cf
Make eager_start default to True for config entry async_create_background_task (#115050) 2024-04-06 10:59:24 -10:00
Marc Mueller 81d682874f
Update typing extensions to 4.11.0 (#114985) 2024-04-06 14:23:32 +02:00
Marc Mueller 816ce116bf
Remove unnecessary functools.cached_property backport (#114239) 2024-04-04 11:24:26 +02:00
J. Nick Koston ef047707d9
Simplify config entry cache clear (#114691)
same as #113136 but for config entries
2024-04-03 12:21:37 +02:00
J. Nick Koston 41a88c876d
Avoid useless done check in config entries async_create_task (#114695)
If the task is not started with eager_start it will
never be done right away
2024-04-03 11:49:32 +02:00
Sid 6587ee20db
Enable Ruff TRY300 (#114437)
* Enable Ruff TRY300

* Update validation.py

* Address review comments
2024-03-30 10:37:59 +01:00
G Johansson fc4d960d17
Add translation support to Config Entry errors (#106305)
* Config Entry error translation

* split key and placeholders

* Fix config entries tests

* translation optional

* Mods
2024-03-28 10:52:21 +01:00
Marc Mueller 911a31f860
Use SignalType to improve typing [core] (#114298) 2024-03-27 14:25:02 +01:00
Marc Mueller d0ecad78ac
Revert "Update typing-extensions to 4.11.0rc1 (#114116)" (#114216) 2024-03-25 20:44:57 -10:00
Joost Lekkerkerker 6bb4e7d62c
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00
Marc Mueller 188dbfbd2a
Update typing-extensions to 4.11.0rc1 (#114116) 2024-03-25 11:27:47 +01:00
J. Nick Koston d0dc820ced
Cancel config entry setup retry at shutdown (#114124) 2024-03-24 09:09:24 -10:00
J. Nick Koston 4f18f0d902
Fix setup timings when config entry platform loads are not awaited (#113959)
* Move setup time logging into the context manager

We were fetching the time twice but since the context
manager already has the timing, move it there

* remove log setup assertions from integration test

* tweak logging to give us better data for tracking issues

* redundant

* adjust

* preen

* fixes

* adjust

* make api change internal so nobody uses it

* coverage

* fix test

* fix more tests

* coverage

* more tests assuming internal calls

* fix more

* adjust

* adjust

* fix axis tests

* fix broadlink -- it does not call async_forward_entry_setup

* missed some

* remove useless patch

* rename, detect it both ways

* clear

* debug

* try to fix

* handle phase finishing out while paused

* where its set does not need to know its late as that is an implemenation detail of setup

* where its set does not need to know its late as that is an implemenation detail of setup

* tweak

* simplify

* reduce complexity

* revert order change as it makes review harder

* revert naming changes as it makes review harder

* improve comment

* improve debug

* late dispatch test

* test the other way as well

* Update setup.py

* Update setup.py

* Update setup.py

* simplify

* reduce
2024-03-23 15:26:38 -04:00
J. Nick Koston 3b66328591
Add a fast path for async_get_platform (#113917) 2024-03-21 09:34:33 +01:00
Erik Montnemery d31124d5d4
Avoid creating unneeded Context and Event objects when firing events (#113798)
* Avoid creating unneeded Context and Event objects when firing events

* Add test

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-20 09:40:06 +01:00
J. Nick Koston c615b52840
Refactor integration startup time to show wall clock time (#113707)
* Refactor setup time tracking to exclude time waiting on other operations

We now exclude the import time and th time waiting on
base platforms to setup from the setup times

* tweak

* tweak

* tweak

* tweak

* adjust

* fixes

* fixes

* preen

* preen

* tweak

* tweak

* adjust

* tweak

* reduce

* do not count integrtion platforms against their parent integration

* handle legacy tts platforms

* stt as well

* one more wait

* use the same pattern in all the legacy

* fix tts and stt legacy

* fix

* fix

* reduce

* preen

* entity comp does not wait for platforms

* scene blocks as well

* fix test

* test fixes

* coverage

* coverage

* coverage

* fix test

* Update tests/test_setup.py

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

* Update tests/test_setup.py

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

* Update homeassistant/setup.py

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

* strip

* strip WAIT_PLATFORM_INTEGRATION

* strip WAIT_PLATFORM_INTEGRATION

* strip WAIT_PLATFORM_INTEGRATION

* strip WAIT_PLATFORM_INTEGRATION

* remove complexity

* Apply suggestions from code review

* no longer works that way

* fixes

* fixes

* fixes

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-03-18 21:45:34 -04:00
J. Nick Koston 6a6f3d46a9
Create config entry async_on_unload tasks eagerly (#113626) 2024-03-16 14:43:49 -10:00
J. Nick Koston 6e3e2d1693
Shutdown config entry manager immediately at the stop event (#113632) 2024-03-16 13:39:31 -10:00
G Johansson e8de1a7031
Revert "Avoid pre-importing config_flows if the integration does not … (#113553)
Revert "Avoid pre-importing config_flows if the integration does not support …"

This reverts commit 9940f51b95.
2024-03-15 23:15:36 +01:00
J. Nick Koston 9940f51b95
Avoid pre-importing config_flows if the integration does not support migration (#113369)
* Avoid pre-importing config_flows if the integration does support migration

Currently we pre-import the config flow module if it exists since
setting up the config entry required comparing the versions found
in the config_flow.py. We can avoid the pre-import if the integration
does not support async_migrate_entry which means we avoid loading
many config flows in memory at startup.

* cover

* fix missing block

* do not call directly

* its too fast now, the test gets more along

* Update homeassistant/loader.py
2024-03-14 00:13:40 -04:00
J. Nick Koston e347096ef5
Add a task name to the config entry retry tasks (#113188) 2024-03-12 14:19:22 -10:00
J. Nick Koston 65358c129a
Replace periodic tasks with background tasks (#112726)
* Phase out periodic tasks

* false by default or some tests will block forever, will need to fix each one manually

* kwarg works

* kwarg works

* kwarg works

* fixes

* fix more tests

* fix more tests

* fix lifx

* opensky

* pvpc_hourly_pricing

* adjust more

* adjust more

* smarttub

* adjust more

* adjust more

* adjust more

* adjust more

* adjust

* no eager executor

* zha

* qnap_qsw

* fix more

* fix fix

* docs

* its a wrapper now

* add more coverage

* coverage

* cover all combos

* more fixes

* more fixes

* more fixes

* remaining issues are legit bugs in tests

* make tplink test more predictable

* more fixes

* feedreader

* grind out some more

* make test race safe

* one more
2024-03-08 21:45:10 -05:00
Marc Mueller 19ab3d6daf
Add empty line after module docstring [helpers + other] (#112707) 2024-03-08 10:36:11 -05: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 82efb3d35b
Make FlowResult a generic type (#111952) 2024-03-07 12:41:14 +01: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 a277d0c4b5
Migrate system flows to use the discovery helper (#112291)
Ensures we are not creating new flows or loading
their platforms until the started event
once the import executor has clamed down
2024-03-05 10:01:31 -05:00
J. Nick Koston 7cb8a8bbc9
Migrate remaining calls in config modules to async_get_component (#112293)
* Migrate remaining calls in config modules to async_get_component

There were a few cases that were still using get_component that
could have done blocking I/O in the event loop, although it
was unlikely.

The caching check in async_get_component has been moved
up to avoid creating the future if the module is already in
the cache

* fix one more
2024-03-05 09:59:52 -05: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
J. Nick Koston 5227976aa2
Group loading of platforms in the import executor (#112141)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-03-03 21:32:19 -10:00
Erik Montnemery 3a5e0c14bf
Remove config flow specifics from FlowResult (#111932)
* Remove config flow specifics from FlowResult

* Improve docstring

* Update pylint rules
2024-03-01 13:07:13 +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
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
J. Nick Koston 63c3d6e113
Fix race in config entry setup again (#111800)
Because the setup again was scheduled as a task, it would
not unset self._async_cancel_retry_setup in time and we would
try to unsub self._async_cancel_retry_setup after it had already
fired. Change it to call a callback that runs right away so it
unsets self._async_cancel_retry_setup as soon as its called
so there is no race

fixes #111796
2024-02-29 15:47:36 +01:00
J. Nick Koston b9718fe2e9
Avoid tracking tasks that finish right away (#111690) 2024-02-27 19:09:34 -10:00
Erik Montnemery fc4b18b907
Return FlowResultType.ABORT when violating single_config_entry (#111637)
* Return FlowResultType.ABORT when violating single_config_entry

* Fix translations

* Fix tests
2024-02-27 18:28:19 +01:00
Erik Montnemery 6ccf7dea32
Always allow ignore and unignore flows for single config entry integrations (#111631)
* Always allow ignore and unignore flows for single config entry integrations

* Update tests/test_config_entries.py

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

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-02-27 15:47:56 +01:00
J. Nick Koston 7d9fa2f407
Load config entry platforms eagerly (#111498)
We can avoid one event loop iteration to start the tasks here.
2024-02-26 23:55:41 -05:00
J. Nick Koston 4ea1c5cc3c
Add support for importing integrations in the executor (#111336)
* Add support for pre-imports at setup time

alternative solution to #111331

* refactor

* refactor

* refactor

* mark >1.0s integrations

* no point in executor if already loaded

* no point in executor if already loaded

* cleanup

* cleanup

* two more

* one more

* analytics loads a lot more integrations

* cloud

* debug

* psutil, hardwre

* try zha

* Update homeassistant/setup.py

* await

* comments

* coverage

* coverage

* coverage

* move logic to loader

* move logic to loader

* preserve comments
2024-02-26 14:49:43 -05:00