INNER CODE UNIT · Python
async_migrate_entry
dummylabs/thewatchman · custom_components/watchman/__init__.py:211
async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Migrate ConfigEntry persistent data to a new version."""
if config_entry.version > CONFIG_ENTRY_VERSION:
# the user has downgraded from a future version
_LOGGER.error(
"Unable to migrate Watchman entry from version %d.%d. If integration version was downgraded, either reinstall or use backup to restore its data.",
config_entry.version,
config_entry.minor_version,
)
return False
if config_entry.version == 1:
# migrate from ConfigEntry.options to ConfigEntry.data
_LOGGER.info(
"Start Watchman configuration entry migration to version 2. Source data: %s",
config_entry.options,
)
data = deepcopy(DEFAULT_OPTIONS)