Fix Verisure config entry migration (#98546)

This commit is contained in:
G Johansson 2023-08-17 08:51:59 +02:00 committed by GitHub
parent fde498586e
commit 6faa9abc75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,7 +83,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
LOGGER.debug("Migrating from version %s", entry.version)
if entry.version == 1:
config_entry_default_code = entry.options.get(CONF_LOCK_DEFAULT_CODE)
if config_entry_default_code := entry.options.get(CONF_LOCK_DEFAULT_CODE):
entity_reg = er.async_get(hass)
entries = er.async_entries_for_config_entry(entity_reg, entry.entry_id)
for entity in entries:
@ -96,9 +96,10 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
new_options = entry.options.copy()
del new_options[CONF_LOCK_DEFAULT_CODE]
entry.version = 2
hass.config_entries.async_update_entry(entry, options=new_options)
entry.version = 2
LOGGER.info("Migration to version %s successful", entry.version)
return True