mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Add icon translations to Balboa (#111343)
This commit is contained in:
parent
496339773b
commit
cb6cf3bedc
@ -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]
|
||||
|
24
homeassistant/components/balboa/icons.json
Normal file
24
homeassistant/components/balboa/icons.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user