Skip to content

Add unique ID to config entries#29806

Merged
balloob merged 10 commits into
devfrom
abort-exception
Dec 16, 2019
Merged

Add unique ID to config entries#29806
balloob merged 10 commits into
devfrom
abort-exception

Conversation

@balloob
Copy link
Copy Markdown
Member

@balloob balloob commented Dec 9, 2019

Description:

  • Add a new AbortFlow exception to allow aborting config flows via an exception
  • Add a new async_set_unique_id function to ConfigFlow. This will automatically check if an entry with same unique ID is already in progress and abort if so.
  • If flow with unique ID is finished, unload existing entry with same unique ID and remove it.

To do: update Hue to add unique ID.

Marked as WIP because the current checks by async_set_unique_id do not work well. Example where it's not useful: Hue bridges can remove auth credentials for Home Assistant. The Hue config entry will detect this while being set up and open a new config flow to authorize. Now during authorization, setting the unique ID will abort the flow because the bridge is already configured (but with no longer valid auth). We can't just go ahead and delete the entry, because that will remove all customization, instead of the current approach where the new config entry takes over the old devices/entities. Will need some more thought.

This is a first step in allowing config entries to be ignored for home-assistant/architecture#250. The next step will be to allow ignoring config flows that have a unique ID set.

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@balloob balloob marked this pull request as ready for review December 10, 2019 22:26
@balloob balloob requested a review from a team as a code owner December 10, 2019 22:26
@balloob balloob changed the title WIP: Add unique ID to config entries Add unique ID to config entries Dec 10, 2019
Comment thread homeassistant/data_entry_flow.py Outdated
@balloob balloob merged commit d851cb6 into dev Dec 16, 2019
@delete-merged-branch delete-merged-branch Bot deleted the abort-exception branch December 16, 2019 11:27
@balloob balloob mentioned this pull request Dec 16, 2019
5 tasks
@balloob balloob mentioned this pull request Dec 16, 2019
5 tasks
@Kane610 Kane610 mentioned this pull request Dec 17, 2019
9 tasks
@lock lock Bot locked and limited conversation to collaborators Dec 17, 2019
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.

4 participants