Browse Source

hotfix: apply migration consistently.

Previous migration had multiple issues:
 - migration was defined as 13_14, but was calling the 13_13 migration
 function instead. This was out of scope for some users so threw an
 error, but that did not happen for me for some reason.
 - version was upgraded to 13_14, but new configs were still created
 as 13_12.

Fixed for re-release of 2026.1.1

Issue #4308
Jason Rumney 1 month ago
parent
commit
a55edebf87

+ 5 - 4
custom_components/tuya_local/__init__.py

@@ -740,7 +740,8 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
         await async_migrate_entries(hass, entry.entry_id, update_unique_id13_13)
         hass.config_entries.async_update_entry(entry, minor_version=13)
 
-    if entry.version == 13 and entry.minor_version < 14:
+    # 13.14 was botched, so repeat as 13.15
+    if entry.version == 13 and entry.minor_version < 15:
         # Migrate unique ids of existing entities to new id taking into
         # account translation_key, and standardising naming
         device_id = get_device_unique_id(entry)
@@ -756,7 +757,7 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
             return False
 
         @callback
-        def update_unique_id13_14(entity_entry):
+        def update_unique_id13_15(entity_entry):
             """Update the unique id of an entity entry."""
             # Standardistion of entity naming to use translation_key
             replacements = {
@@ -784,8 +785,8 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
             }
             return replace_unique_ids(entity_entry, device_id, conf_file, replacements)
 
-        await async_migrate_entries(hass, entry.entry_id, update_unique_id13_13)
-        hass.config_entries.async_update_entry(entry, minor_version=14)
+        await async_migrate_entries(hass, entry.entry_id, update_unique_id13_15)
+        hass.config_entries.async_update_entry(entry, minor_version=15)
     return True
 
 

+ 1 - 1
custom_components/tuya_local/config_flow.py

@@ -47,7 +47,7 @@ _LOGGER = logging.getLogger(__name__)
 
 class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
     VERSION = 13
-    MINOR_VERSION = 12
+    MINOR_VERSION = 15
     CONNECTION_CLASS = CONN_CLASS_LOCAL_PUSH
     device = None
     data = {}