Update airvisual to set ConfigEntry version with async_update_entry (#110204)
* Update airvisual to set ConfigEntry version with async_update_entry * Update airvisual to set ConfigEntry version with async_update_entry
This commit is contained in:
parent
b3e46e3d64
commit
1e7cd7c0c6
1 changed files with 3 additions and 2 deletions
|
@ -242,7 +242,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
|
||||||
# 1 -> 2: One geography per config entry
|
# 1 -> 2: One geography per config entry
|
||||||
if version == 1:
|
if version == 1:
|
||||||
version = entry.version = 2
|
version = 2
|
||||||
|
|
||||||
# Update the config entry to only include the first geography (there is always
|
# Update the config entry to only include the first geography (there is always
|
||||||
# guaranteed to be at least one):
|
# guaranteed to be at least one):
|
||||||
|
@ -255,6 +255,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
unique_id=first_id,
|
unique_id=first_id,
|
||||||
title=f"Cloud API ({first_id})",
|
title=f"Cloud API ({first_id})",
|
||||||
data={CONF_API_KEY: entry.data[CONF_API_KEY], **first_geography},
|
data={CONF_API_KEY: entry.data[CONF_API_KEY], **first_geography},
|
||||||
|
version=version,
|
||||||
)
|
)
|
||||||
|
|
||||||
# For any geographies that remain, create a new config entry for each one:
|
# For any geographies that remain, create a new config entry for each one:
|
||||||
|
@ -379,7 +380,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
entry.version = version
|
hass.config_entries.async_update_entry(entry, version=version)
|
||||||
|
|
||||||
LOGGER.info("Migration to version %s successful", version)
|
LOGGER.info("Migration to version %s successful", version)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue