Skip to content

Commit

Permalink
Revert to overriding entity name property
Browse files Browse the repository at this point in the history
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
  • Loading branch information
make-all committed Aug 9, 2023
1 parent 25fb43a commit 1c9fe24
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion custom_components/tuya_local/helpers/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Expand All @@ -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."""
Expand Down

0 comments on commit 1c9fe24

Please sign in to comment.