From 065ece9bb3537eba71111ad33f290054cd3bfa80 Mon Sep 17 00:00:00 2001 From: Jason Rumney Date: Wed, 29 May 2024 22:35:11 +0900 Subject: [PATCH] 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 --- custom_components/tuya_local/helpers/mixin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/custom_components/tuya_local/helpers/mixin.py b/custom_components/tuya_local/helpers/mixin.py index 24f4da7a9c..577152f451 100644 --- a/custom_components/tuya_local/helpers/mixin.py +++ b/custom_components/tuya_local/helpers/mixin.py @@ -55,7 +55,10 @@ def name(self): @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