-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for #18: Workaround attempting to schedule yaml after restore fro…
…m 'storage' (.storage/core.entity_registry) Notes: HA is calling integration's async_setup_entry (__init__.py) to restore all components in 'storage' before calling components async_setup_platform (binary_sensor.py and switch.py) for yaml which is fine but effective processing of these tasks is taking place asynchronously and in random order while yaml should always the latest (it should overload storage). This is only an issue for integration supporting both configuration options simultaneously (yaml and configflow as it uses storage) which is the case here. Goal of the workaround is therefore to delay import from configuration.yaml until all entities in storage have been restored. Because async_setup_platform (yaml) is called after all sync_setup_entry calls from storage, a counter can be incremented for each such call and block the former until all sync_setup_entry complete and decrement the counter back to zero. This counter is implemented within a new SetupEntryStatus class used as a contextmanager guarding processing of each entry setup in async_setup_entry.
- Loading branch information
1 parent
de08c5a
commit 2197bf9
Showing
3 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters