From 2f0d294219282ae815e84beeab9cf11c53de705d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 12 Feb 2024 12:45:07 -0600 Subject: [PATCH] Migrate trafikverket_camera to use async_update_entry to alter config entries (#110393) --- homeassistant/components/trafikverket_camera/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/trafikverket_camera/__init__.py b/homeassistant/components/trafikverket_camera/__init__.py index f0f758272f7..7303ba6836b 100644 --- a/homeassistant/components/trafikverket_camera/__init__.py +++ b/homeassistant/components/trafikverket_camera/__init__.py @@ -58,10 +58,10 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return False if camera_id := camera_info.camera_id: - entry.version = 2 hass.config_entries.async_update_entry( entry, unique_id=f"{DOMAIN}-{camera_id}", + version=2, ) _LOGGER.debug( "Migrated Trafikverket Camera config entry unique id to %s", @@ -84,7 +84,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return False if camera_id := camera_info.camera_id: - entry.version = 3 _LOGGER.debug( "Migrate Trafikverket Camera config entry unique id to %s", camera_id, @@ -92,7 +91,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: new_data = entry.data.copy() new_data.pop(CONF_LOCATION) new_data[CONF_ID] = camera_id - hass.config_entries.async_update_entry(entry, data=new_data) + hass.config_entries.async_update_entry(entry, data=new_data, version=3) return True _LOGGER.error("Could not migrate the config entry. Camera has no id") return False