Add tolo binary_sensor platform (#60365)
This commit is contained in:
parent
ba7b5681e6
commit
db0104c2c9
3 changed files with 74 additions and 1 deletions
|
@ -1094,6 +1094,7 @@ omit =
|
|||
homeassistant/components/todoist/const.py
|
||||
homeassistant/components/tof/sensor.py
|
||||
homeassistant/components/tolo/__init__.py
|
||||
homeassistant/components/tolo/binary_sensor.py
|
||||
homeassistant/components/tolo/button.py
|
||||
homeassistant/components/tolo/climate.py
|
||||
homeassistant/components/tolo/light.py
|
||||
|
|
|
@ -22,7 +22,7 @@ from homeassistant.helpers.update_coordinator import (
|
|||
|
||||
from .const import DEFAULT_RETRY_COUNT, DEFAULT_RETRY_TIMEOUT, DOMAIN
|
||||
|
||||
PLATFORMS = ["button", "climate", "light", "select", "sensor"]
|
||||
PLATFORMS = ["binary_sensor", "button", "climate", "light", "select", "sensor"]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
72
homeassistant/components/tolo/binary_sensor.py
Normal file
72
homeassistant/components/tolo/binary_sensor.py
Normal file
|
@ -0,0 +1,72 @@
|
|||
"""TOLO Sauna binary sensors."""
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_OPENING,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
entry: ConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up binary sensors for TOLO Sauna."""
|
||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
async_add_entities(
|
||||
[
|
||||
ToloFlowInBinarySensor(coordinator, entry),
|
||||
ToloFlowOutBinarySensor(coordinator, entry),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class ToloFlowInBinarySensor(ToloSaunaCoordinatorEntity, BinarySensorEntity):
|
||||
"""Water In Valve Sensor."""
|
||||
|
||||
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
||||
_attr_name = "Water In Valve"
|
||||
_attr_device_class = DEVICE_CLASS_OPENING
|
||||
_attr_icon = "mdi:water-plus-outline"
|
||||
|
||||
def __init__(
|
||||
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry
|
||||
) -> None:
|
||||
"""Initialize TOLO Water In Valve entity."""
|
||||
super().__init__(coordinator, entry)
|
||||
|
||||
self._attr_unique_id = f"{entry.entry_id}_flow_in"
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return if flow in valve is open."""
|
||||
return self.coordinator.data.status.flow_in
|
||||
|
||||
|
||||
class ToloFlowOutBinarySensor(ToloSaunaCoordinatorEntity, BinarySensorEntity):
|
||||
"""Water Out Valve Sensor."""
|
||||
|
||||
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
||||
_attr_name = "Water Out Valve"
|
||||
_attr_device_class = DEVICE_CLASS_OPENING
|
||||
_attr_icon = "mdi:water-minus-outline"
|
||||
|
||||
def __init__(
|
||||
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry
|
||||
) -> None:
|
||||
"""Initialize TOLO Water Out Valve entity."""
|
||||
super().__init__(coordinator, entry)
|
||||
|
||||
self._attr_unique_id = f"{entry.entry_id}_flow_out"
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return if flow out valve is open."""
|
||||
return self.coordinator.data.status.flow_out
|
Loading…
Add table
Reference in a new issue