diff --git a/custom_components/dwd_weather/__init__.py b/custom_components/dwd_weather/__init__.py index 590338e..79ee4f0 100644 --- a/custom_components/dwd_weather/__init__.py +++ b/custom_components/dwd_weather/__init__.py @@ -117,13 +117,11 @@ async def async_migrate_entry(hass, config_entry: ConfigEntry): if config_entry.version == 1: new = {**config_entry.data} new["weather_interval"] = 24 - config_entry.data = {**new} # type: ignore - config_entry.version = 2 + hass.config_entries.async_update_entry(config_entry, data=new, version=2) elif config_entry.version == 2: new = {**config_entry.data} new[CONF_WIND_DIRECTION_TYPE] = DEFAULT_WIND_DIRECTION_TYPE - config_entry.data = {**new} # type: ignore - config_entry.version = 3 + hass.config_entries.async_update_entry(config_entry, data=new, version=3) elif config_entry.version == 3: new = {} new[CONF_DATA_TYPE] = CONF_DATA_TYPE_FORECAST @@ -148,27 +146,23 @@ def update_unique_id(entity_entry): await async_migrate_entries(hass, config_entry.entry_id, update_unique_id) - config_entry.version = 4 - hass.config_entries.async_update_entry(config_entry, data=new) + hass.config_entries.async_update_entry(config_entry, data=new, version=4) _LOGGER.debug("New Config entry {}".format(config_entry.data)) elif config_entry.version == 4: new = {**config_entry.data} new[CONF_INTERPOLATE] = DEFAULT_INTERPOLATION - config_entry.data = {**new} # type: ignore - config_entry.version = 5 + hass.config_entries.async_update_entry(config_entry, data=new, version=5) elif config_entry.version == 5: new = {**config_entry.data} new[CONF_ENTITY_TYPE] = CONF_ENTITY_TYPE_STATION - config_entry.data = {**new} # type: ignore - config_entry.version = 6 + hass.config_entries.async_update_entry(config_entry, data=new, version=6) elif config_entry.version == 6: new = {**config_entry.data} new[CONF_MAP_MARKER] = True new[CONF_MAP_TIMESTAMP] = True new[CONF_MAP_LOOP_COUNT] = 6 new[CONF_MAP_LOOP_SPEED] = 0.5 - config_entry.data = {**new} # type: ignore - config_entry.version = 7 + hass.config_entries.async_update_entry(config_entry, data=new, version=7) _LOGGER.info("Migration to version %s successful", config_entry.version) return True