Fix OpenWeatherMap migration (#118428)

This commit is contained in:
Evgeny 2024-05-29 23:12:24 +02:00 committed by GitHub
parent a670169325
commit ab9581c617
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -72,14 +72,15 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Migrate old entry.""" """Migrate old entry."""
config_entries = hass.config_entries config_entries = hass.config_entries
data = entry.data data = entry.data
options = entry.options
version = entry.version version = entry.version
_LOGGER.debug("Migrating OpenWeatherMap entry from version %s", version) _LOGGER.debug("Migrating OpenWeatherMap entry from version %s", version)
if version < 3: if version < 4:
new_data = {**data, CONF_MODE: OWM_MODE_V25} new_data = {**data, **options, CONF_MODE: OWM_MODE_V25}
config_entries.async_update_entry( config_entries.async_update_entry(
entry, data=new_data, version=CONFIG_FLOW_VERSION entry, data=new_data, options={}, version=CONFIG_FLOW_VERSION
) )
_LOGGER.info("Migration to version %s successful", CONFIG_FLOW_VERSION) _LOGGER.info("Migration to version %s successful", CONFIG_FLOW_VERSION)

View File

@ -25,7 +25,7 @@ DEFAULT_NAME = "OpenWeatherMap"
DEFAULT_LANGUAGE = "en" DEFAULT_LANGUAGE = "en"
ATTRIBUTION = "Data provided by OpenWeatherMap" ATTRIBUTION = "Data provided by OpenWeatherMap"
MANUFACTURER = "OpenWeather" MANUFACTURER = "OpenWeather"
CONFIG_FLOW_VERSION = 3 CONFIG_FLOW_VERSION = 4
ATTR_API_PRECIPITATION = "precipitation" ATTR_API_PRECIPITATION = "precipitation"
ATTR_API_PRECIPITATION_KIND = "precipitation_kind" ATTR_API_PRECIPITATION_KIND = "precipitation_kind"
ATTR_API_DATETIME = "datetime" ATTR_API_DATETIME = "datetime"