Просмотр исходного кода

Add support for specifying a translation key in entity config.

Issue #682
Jason Rumney 2 лет назад
Родитель
Сommit
1b776e62de

+ 5 - 0
custom_components/tuya_local/helpers/device_config.py

@@ -203,6 +203,11 @@ class TuyaEntityConfig:
         """The friendly name for this entity."""
         return self._config.get("name")
 
+    @property
+    def translation_key(self):
+        """The translation key for this entity."""
+        return self._config.get("translation_key")
+
     def unique_id(self, device_uid):
         """Return a suitable unique_id for this entity."""
         return f"{device_uid}-{slugify(self.config_id)}"

+ 5 - 0
custom_components/tuya_local/helpers/mixin.py

@@ -39,6 +39,11 @@ class TuyaLocalEntity:
         """Return the name for the UI."""
         return self._config.name
 
+    @property
+    def translation_key(self):
+        """Return the translation key."""
+        return self._config.translation_key
+
     @property
     def has_entity_name(self):
         return True