Skip to content

Commit

Permalink
Entity naming: use device name if translation_key is device class
Browse files Browse the repository at this point in the history
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
  • Loading branch information
make-all committed May 29, 2024
1 parent 0dcade8 commit 065ece9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion custom_components/tuya_local/helpers/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 065ece9

Please sign in to comment.