From 82f91bcd5feaacc6afb6f38d6bcfcbe6f89d513e Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 10 Jan 2022 09:34:22 +0100 Subject: [PATCH] Adjust migrate_entry in axis (#63779) Co-authored-by: epenet --- homeassistant/components/axis/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/axis/__init__.py b/homeassistant/components/axis/__init__.py index 68c656980dc..5e211c00028 100644 --- a/homeassistant/components/axis/__init__.py +++ b/homeassistant/components/axis/__init__.py @@ -39,7 +39,7 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> return await device.async_reset() -async def async_migrate_entry(hass, config_entry): +async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Migrate old entry.""" _LOGGER.debug("Migrating from version %s", config_entry.version) @@ -53,8 +53,7 @@ async def async_migrate_entry(hass, config_entry): config_entry.version = 2 # Normalise MAC address of device which also affects entity unique IDs - if config_entry.version == 2: - old_unique_id = config_entry.unique_id + if config_entry.version == 2 and (old_unique_id := config_entry.unique_id): new_unique_id = format_mac(old_unique_id) @callback