Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow translation key even when device class is overridden #234

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions zha/application/platforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,21 +340,19 @@ def _init_from_quirks_metadata(self, entity_metadata: EntityMetadata) -> None:
if entity_metadata.initially_disabled:
self._attr_entity_registry_enabled_default = False

has_device_class = hasattr(entity_metadata, "device_class")
has_attribute_name = hasattr(entity_metadata, "attribute_name")
has_command_name = hasattr(entity_metadata, "command_name")
has_fallback_name = hasattr(entity_metadata, "fallback_name")

if not has_device_class or entity_metadata.device_class is None:
if has_fallback_name:
self._attr_fallback_name = entity_metadata.fallback_name
if has_fallback_name:
self._attr_fallback_name = entity_metadata.fallback_name

if entity_metadata.translation_key:
self._attr_translation_key = entity_metadata.translation_key
elif has_attribute_name:
self._attr_translation_key = entity_metadata.attribute_name
elif has_command_name:
self._attr_translation_key = entity_metadata.command_name
if entity_metadata.translation_key:
self._attr_translation_key = entity_metadata.translation_key
elif has_attribute_name:
self._attr_translation_key = entity_metadata.attribute_name
elif has_command_name:
self._attr_translation_key = entity_metadata.command_name

if has_attribute_name:
self._unique_id_suffix = entity_metadata.attribute_name
Expand Down