Add icon translations to Plugwise (#108498)

This commit is contained in:
Franck Nijhof 2024-01-20 20:15:53 +01:00 committed by GitHub
parent e71efa0e2b
commit 19bf8970d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 102 additions and 33 deletions

View file

@ -28,64 +28,48 @@ class PlugwiseBinarySensorEntityDescription(BinarySensorEntityDescription):
"""Describes a Plugwise binary sensor entity."""
key: BinarySensorType
icon_off: str | None = None
BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = (
PlugwiseBinarySensorEntityDescription(
key="compressor_state",
translation_key="compressor_state",
icon="mdi:hvac",
icon_off="mdi:hvac-off",
entity_category=EntityCategory.DIAGNOSTIC,
),
PlugwiseBinarySensorEntityDescription(
key="cooling_enabled",
translation_key="cooling_enabled",
icon="mdi:snowflake-thermometer",
entity_category=EntityCategory.DIAGNOSTIC,
),
PlugwiseBinarySensorEntityDescription(
key="dhw_state",
translation_key="dhw_state",
icon="mdi:water-pump",
icon_off="mdi:water-pump-off",
entity_category=EntityCategory.DIAGNOSTIC,
),
PlugwiseBinarySensorEntityDescription(
key="flame_state",
translation_key="flame_state",
name="Flame state",
icon="mdi:fire",
icon_off="mdi:fire-off",
entity_category=EntityCategory.DIAGNOSTIC,
),
PlugwiseBinarySensorEntityDescription(
key="heating_state",
translation_key="heating_state",
icon="mdi:radiator",
icon_off="mdi:radiator-off",
entity_category=EntityCategory.DIAGNOSTIC,
),
PlugwiseBinarySensorEntityDescription(
key="cooling_state",
translation_key="cooling_state",
icon="mdi:snowflake",
icon_off="mdi:snowflake-off",
entity_category=EntityCategory.DIAGNOSTIC,
),
PlugwiseBinarySensorEntityDescription(
key="slave_boiler_state",
translation_key="slave_boiler_state",
icon="mdi:fire",
icon_off="mdi:circle-off-outline",
entity_category=EntityCategory.DIAGNOSTIC,
),
PlugwiseBinarySensorEntityDescription(
key="plugwise_notification",
translation_key="plugwise_notification",
icon="mdi:mailbox-up-outline",
icon_off="mdi:mailbox-outline",
entity_category=EntityCategory.DIAGNOSTIC,
),
)
@ -140,13 +124,6 @@ class PlugwiseBinarySensorEntity(PlugwiseEntity, BinarySensorEntity):
"""Return true if the binary sensor is on."""
return self.device["binary_sensors"][self.entity_description.key]
@property
def icon(self) -> str | None:
"""Return the icon to use in the frontend, if any."""
if (icon_off := self.entity_description.icon_off) and self.is_on is False:
return icon_off
return self.entity_description.icon
@property
def extra_state_attributes(self) -> Mapping[str, Any] | None:
"""Return entity specific state attributes."""