Explorar el Código

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 hace 2 años
padre
commit
1c9fe245f9
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  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."""