Selaa lähdekoodia

slugify name when migrating.

Names are slugified when making the unique_id, make sure it is done when
migrating too.

Without this, unique_ids are generally not matched, as the case is different.
Jason Rumney 3 vuotta sitten
vanhempi
commit
7766461f16
1 muutettua tiedostoa jossa 3 lisäystä ja 2 poistoa
  1. 3 2
      custom_components/tuya_local/__init__.py

+ 3 - 2
custom_components/tuya_local/__init__.py

@@ -12,6 +12,7 @@ from homeassistant.config_entries import ConfigEntry
 from homeassistant.const import CONF_HOST
 from homeassistant.core import HomeAssistant, callback
 from homeassistant.helpers.entity_registry import async_migrate_entries
+from homeassistant.util import slugify
 
 from .const import (
     CONF_DEVICE_ID,
@@ -194,13 +195,13 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
             platform = entity_entry.entity_id.split(".", 1)[0]
             e = conf_file.primary_entity
             if e.name:
-                expect_id = f"{device_id}-{e.name}"
+                expect_id = f"{device_id}-{slugify(e.name)}"
             else:
                 expect_id = device_id
             if e.entity != platform or expect_id != old_id:
                 for e in conf_file.secondary_entities():
                     if e.name:
-                        expect_id = f"{device_id}-{e.name}"
+                        expect_id = f"{device_id}-{slugify(e.name)}"
                     else:
                         expect_id = device_id
                     if e.entity == platform and expect_id == old_id: