INNER CODE UNIT · Python
async_migrate_entry
3dg1luk43/ha_washdata · custom_components/ha_washdata/__init__.py:158
async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Migrate config entry to the latest version while preserving settings."""
_log = DeviceLoggerAdapter(_LOGGER, entry.title)
version = entry.version or 1
minor_version = entry.minor_version or 1
if version > CONFIG_ENTRY_VERSION:
_log.error(
"Refusing to migrate unsupported future schema %s.%s", version, minor_version
)
return False
if version == CONFIG_ENTRY_VERSION and minor_version >= CONFIG_ENTRY_MINOR_VERSION:
return True
# 3.6 → 3.7: remove initial_profile stub key from entry.data.
if version == 3 and minor_version == 6:
new_data = {k: v for k, v in entry.data.items() if k != "initial_profile"}