Explorar o código

Device config: use translation_key for unique_id

When both name and class are missing, but translation_key is available,
use that for the unique_id before defaulting to the entity type only.

Preparation for wider use of translated names.

Issue #1579
Jason Rumney hai 1 ano
pai
achega
9cba602ece
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      custom_components/tuya_local/helpers/device_config.py

+ 2 - 1
custom_components/tuya_local/helpers/device_config.py

@@ -267,7 +267,8 @@ class TuyaEntityConfig:
         own_name = self._config.get("name", self.device_class)
         if own_name:
             return f"{self.entity}_{slugify(own_name)}"
-
+        if self.translation_key:
+            return f"{self.entity}_{self.translation_key}"
         return self.entity
 
     @property