From cb6cf3bedc0b609983778c99a6e3c37aa9da87be Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Sun, 25 Feb 2024 10:40:44 +0100 Subject: [PATCH] Add icon translations to Balboa (#111343) --- .../components/balboa/binary_sensor.py | 11 --------- homeassistant/components/balboa/icons.json | 24 +++++++++++++++++++ 2 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 homeassistant/components/balboa/icons.json diff --git a/homeassistant/components/balboa/binary_sensor.py b/homeassistant/components/balboa/binary_sensor.py index ec7a9fe484a..8584ed2783c 100644 --- a/homeassistant/components/balboa/binary_sensor.py +++ b/homeassistant/components/balboa/binary_sensor.py @@ -38,7 +38,6 @@ class BalboaBinarySensorEntityDescriptionMixin: """Mixin for required keys.""" is_on_fn: Callable[[SpaClient], bool] - on_off_icons: tuple[str, str] @dataclass(frozen=True) @@ -48,21 +47,18 @@ class BalboaBinarySensorEntityDescription( """A class that describes Balboa binary sensor entities.""" -FILTER_CYCLE_ICONS = ("mdi:sync", "mdi:sync-off") BINARY_SENSOR_DESCRIPTIONS = ( BalboaBinarySensorEntityDescription( key="Filter1", translation_key="filter_1", device_class=BinarySensorDeviceClass.RUNNING, is_on_fn=lambda spa: spa.filter_cycle_1_running, - on_off_icons=FILTER_CYCLE_ICONS, ), BalboaBinarySensorEntityDescription( key="Filter2", translation_key="filter_2", device_class=BinarySensorDeviceClass.RUNNING, is_on_fn=lambda spa: spa.filter_cycle_2_running, - on_off_icons=FILTER_CYCLE_ICONS, ), ) CIRCULATION_PUMP_DESCRIPTION = BalboaBinarySensorEntityDescription( @@ -70,7 +66,6 @@ CIRCULATION_PUMP_DESCRIPTION = BalboaBinarySensorEntityDescription( translation_key="circ_pump", device_class=BinarySensorDeviceClass.RUNNING, is_on_fn=lambda spa: (pump := spa.circulation_pump) is not None and pump.state > 0, - on_off_icons=("mdi:pump", "mdi:pump-off"), ) @@ -90,9 +85,3 @@ class BalboaBinarySensorEntity(BalboaEntity, BinarySensorEntity): def is_on(self) -> bool: """Return true if the binary sensor is on.""" return self.entity_description.is_on_fn(self._client) - - @property - def icon(self) -> str | None: - """Return the icon to use in the frontend, if any.""" - icons = self.entity_description.on_off_icons - return icons[0] if self.is_on else icons[1] diff --git a/homeassistant/components/balboa/icons.json b/homeassistant/components/balboa/icons.json new file mode 100644 index 00000000000..49e2545f10d --- /dev/null +++ b/homeassistant/components/balboa/icons.json @@ -0,0 +1,24 @@ +{ + "entity": { + "binary_sensor": { + "filter_1": { + "default": "mdi:sync-off", + "state": { + "on": "mdi:sync" + } + }, + "filter_2": { + "default": "mdi:sync-off", + "state": { + "on": "mdi:sync" + } + }, + "circ_pump": { + "default": "mdi:pump-off", + "state": { + "on": "mdi:pump" + } + } + } + } +}