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:
J. Nick Koston 2024-02-10 12:57:53 -06:00 committed by GitHub
parent b3e46e3d64
commit 1e7cd7c0c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -242,7 +242,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# 1 -> 2: One geography per config entry
if version == 1:
version = entry.version = 2
version = 2
# Update the config entry to only include the first geography (there is always
# guaranteed to be at least one):
@ -255,6 +255,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
unique_id=first_id,
title=f"Cloud API ({first_id})",
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:
@ -379,7 +380,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
},
)
else:
entry.version = version
hass.config_entries.async_update_entry(entry, version=version)
LOGGER.info("Migration to version %s successful", version)