Explorar o código

Entity naming: use device name if translation_key is device class

translation_key uses device class as a fallback (to allow overriding
names/icons based on classes in the translation files).  But this means
we falsely detect unnamed switches with a device class as having a name.
Check if the translation_key is the same as device_class before telling
HA not to use the default name.

Issue #1856
Jason Rumney hai 1 ano
pai
achega
065ece9bb3
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      custom_components/tuya_local/helpers/mixin.py

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

@@ -55,7 +55,10 @@ class TuyaLocalEntity:
     @property
     def use_device_name(self):
         """Return whether to use the device name for the entity name"""
-        own_name = self._config.name or self._config.translation_key
+        alt_name = self._config.translation_key
+        if self._config.translation_key is self._config.device_class:
+            alt_name = None
+        own_name = self._config.name or alt_name
         return not own_name
 
     @property