diff --git a/homeassistant/components/airvisual/__init__.py b/homeassistant/components/airvisual/__init__.py index 1d5babee6d7..42cc1e1fade 100644 --- a/homeassistant/components/airvisual/__init__.py +++ b/homeassistant/components/airvisual/__init__.py @@ -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)