Skip to content

Config Entry migrations#20888

Merged
balloob merged 9 commits into
home-assistant:devfrom
andrewsayre:config_entry_migration
Feb 15, 2019
Merged

Config Entry migrations#20888
balloob merged 9 commits into
home-assistant:devfrom
andrewsayre:config_entry_migration

Conversation

@andrewsayre
Copy link
Copy Markdown
Member

@andrewsayre andrewsayre commented Feb 9, 2019

Description:

Implements basic Config Entry migration functionality:

  • Migration occurs during entry setup (prior to calling component.async_setup_entry)
  • Compares version of the entry to the version in the ConfigFlow and if they do not match determines migration is needed.
  • Components define async_migrate_entry(hass, entry) -> bool where the entry can be directly updated and will be saved. Return True if migration was successful or not needed.
  • New entry state ENTRY_STATE_MIGRATION_ERROR represents failure to migrate.
  • If user interaction is required (i.e. a new required field has been added) - remove the entry and start a new config flow.
  • If user action is required (but not in config flow), raise a persistent notification indicating what must be done

Comment thread homeassistant/config_entries.py Outdated
Comment thread homeassistant/config_entries.py Outdated
Comment thread homeassistant/config_entries.py Outdated
@balloob
Copy link
Copy Markdown
Member

balloob commented Feb 11, 2019

I think that if a new entry is needed, that can be implemented by initiating a new flow which, on completion, removes the old flow. That's how we do it for Hue if a new bridge is registered on a new IP, all other entries for that bridge are killed.

Comment thread homeassistant/components/smartthings/__init__.py Outdated
Comment thread homeassistant/components/smartthings/__init__.py Outdated
Comment thread homeassistant/config_entries.py Outdated
Comment thread homeassistant/components/smartthings/__init__.py Outdated
@balloob balloob mentioned this pull request Feb 12, 2019
5 tasks
@andrewsayre andrewsayre changed the title RFC: Config Entry migrations Config Entry migrations Feb 13, 2019
@andrewsayre
Copy link
Copy Markdown
Member Author

@balloob @MartinHjelmare This is ready for final review. Build is passing--it's seems to coveralls that's the issue. I have a pending SmartThings component improvement to get in before the next release so people don't have to re-authorize the SmartApp, which is dependent on this.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good! @balloob should merge.

@MartinHjelmare
Copy link
Copy Markdown
Member

You can try rebasing on latest dev. Coveralls seems flaky.

@andrewsayre
Copy link
Copy Markdown
Member Author

You can try rebasing on latest dev. Coveralls seems flaky.

I can try that tonight if not already merged. :) .

@balloob balloob merged commit 383813b into home-assistant:dev Feb 15, 2019
@ghost ghost removed the in progress label Feb 15, 2019
@andrewsayre andrewsayre deleted the config_entry_migration branch February 16, 2019 03:02
@balloob balloob mentioned this pull request Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants