diff --git a/zha/application/platforms/__init__.py b/zha/application/platforms/__init__.py index c9525a33..06d30a23 100644 --- a/zha/application/platforms/__init__.py +++ b/zha/application/platforms/__init__.py @@ -56,6 +56,7 @@ class BaseEntityInfo: platform: str class_name: str translation_key: str | None + translation_placeholders: dict[str, str] | None device_class: str | None state_class: str | None entity_category: str | None @@ -117,6 +118,7 @@ class BaseEntity(LogMixin, EventBase): _attr_fallback_name: str | None = None _attr_icon: str | None = None _attr_translation_key: str | None = None + _attr_translation_placeholders: dict[str, str] | None = None _attr_entity_category: EntityCategory | None = None _attr_entity_registry_enabled_default: bool = True _attr_device_class: str | None = None @@ -205,6 +207,11 @@ def translation_key(self) -> str | None: return self._attr_translation_key return None + @property + def translation_placeholders(self) -> dict[str, str] | None: + """Return the translation placeholders.""" + return self._attr_translation_placeholders + @property def entity_category(self) -> EntityCategory | None: """Return the entity category.""" @@ -258,6 +265,7 @@ def info_object(self) -> BaseEntityInfo: class_name=self.__class__.__name__, fallback_name=self.fallback_name, translation_key=self.translation_key, + translation_placeholders=self.translation_placeholders, device_class=self.device_class, state_class=self.state_class, entity_category=self.entity_category, diff --git a/zha/zigbee/device.py b/zha/zigbee/device.py index c1fe21c7..037beabf 100644 --- a/zha/zigbee/device.py +++ b/zha/zigbee/device.py @@ -911,6 +911,11 @@ def _apply_entity_metadata_changes(self, entity: PlatformEntity) -> None: if meta.new_translation_key is not None: entity._attr_translation_key = meta.new_translation_key + if meta.new_translation_placeholders is not None: + entity._attr_translation_placeholders = ( + meta.new_translation_placeholders + ) + if meta.new_device_class is not None: entity._attr_device_class = meta.new_device_class