فهرست منبع

Revert to overriding entity name property

Although the logic to use translated entity names is in the superclass
name implementation, setting _attr_name to None results in
use_device_name returning true, as that is the first condition
checked, and the device name is used instead of the default entity
name.  This is probably an HA bug, as it becomes quite complex to use
default name translations as a result, and certainly isn't per the
documentation.

Issue #871
Jason Rumney 2 سال پیش
والد
کامیت
1c9fe245f9
1فایلهای تغییر یافته به همراه6 افزوده شده و 1 حذف شده
  1. 6 1
      custom_components/tuya_local/helpers/mixin.py

+ 6 - 1
custom_components/tuya_local/helpers/mixin.py

@@ -20,7 +20,6 @@ class TuyaLocalEntity:
         self._device = device
         self._config = config
         self._attr_dps = []
-        self._attr_name = config.name
         self._attr_translation_key = config.translation_key
 
         return {c.name: c for c in config.dps()}
@@ -42,6 +41,12 @@ class TuyaLocalEntity:
     def has_entity_name(self):
         return True
 
+    @property
+    def name(self):
+        """Return the name for the UI."""
+        super_name = getattr(super(), 'name')
+        return self._config.name or super_name
+
     @property
     def unique_id(self):
         """Return the unique id for this entity."""