Skip to content

Add config_entries.async_wait_component#76980

Merged
frenck merged 6 commits into
devfrom
config_entry_wait
Nov 17, 2022
Merged

Add config_entries.async_wait_component#76980
frenck merged 6 commits into
devfrom
config_entry_wait

Conversation

@emontnemery
Copy link
Copy Markdown
Contributor

@emontnemery emontnemery commented Aug 18, 2022

Proposed change

Add config_entries.async_wait_component()

config_entries.async_wait_component() waits for an entry's component to load and returns a bool indicating if the entry is loaded or not.
This is primarily intended for existing config entries which are loaded at startup, awaiting this function will block until the component and all its config entries are loaded.

Config entries which are created after Home Assistant is started can't be waited for, the function will just return if the config entry is loaded or not.

The use case is to make it possible for integration functionality to wait for its config entry to be loaded to avoid implementing integration specific synchronizations such as #76084

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@emontnemery
Copy link
Copy Markdown
Contributor Author

@thecode Some shelly and webostv negative tests now fail because integrations' async_validate_trigger_config is no longer called if the config entry is not set up. It's not really clear to me if the tests are no longer needed with the changes in this PR or if the tests need to be adjusted to setup the config entry.

Copy link
Copy Markdown
Member

@thecode thecode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for Shelly & Webostv

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Nov 11, 2022

I didn't see this PR before, but just added something similar in #81771

It might make sense to refactor that now since it won't be a breaking change if we do it before 2022.12

@thecode thecode requested a review from bdraco as a code owner November 16, 2022 19:51
Comment thread homeassistant/config_entries.py Outdated
@emontnemery emontnemery changed the title Add config_entries.async_wait_entry Add config_entries.async_wait_component Nov 17, 2022
Copy link
Copy Markdown
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @emontnemery

@frenck frenck merged commit 1a274ad into dev Nov 17, 2022
@frenck frenck deleted the config_entry_wait branch November 17, 2022 20:52
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants