From 1c9fe245f9eeeb86d6573ead7d0d2bbe592354da Mon Sep 17 00:00:00 2001 From: Jason Rumney Date: Wed, 9 Aug 2023 21:13:20 +0900 Subject: [PATCH] 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 --- custom_components/tuya_local/helpers/mixin.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/custom_components/tuya_local/helpers/mixin.py b/custom_components/tuya_local/helpers/mixin.py index 19c8b64efb..36f32ee44f 100644 --- a/custom_components/tuya_local/helpers/mixin.py +++ b/custom_components/tuya_local/helpers/mixin.py @@ -20,7 +20,6 @@ def _init_begin(self, device, config): 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 @@ def available(self): 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."""