Add binary sensors for duotecno (#100844)

* Add binary sensors for duotecno

* Add comments
This commit is contained in:
Maikel Punie 2023-09-25 13:34:39 +02:00 committed by GitHub
parent 77007ef091
commit 8a44adb447
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 0 deletions

View file

@ -247,6 +247,7 @@ omit =
homeassistant/components/duotecno/cover.py
homeassistant/components/duotecno/light.py
homeassistant/components/duotecno/climate.py
homeassistant/components/duotecno/binary_sensor.py
homeassistant/components/dwd_weather_warnings/const.py
homeassistant/components/dwd_weather_warnings/coordinator.py
homeassistant/components/dwd_weather_warnings/sensor.py

View file

@ -16,6 +16,7 @@ PLATFORMS: list[Platform] = [
Platform.COVER,
Platform.LIGHT,
Platform.CLIMATE,
Platform.BINARY_SENSOR,
]

View file

@ -0,0 +1,34 @@
"""Support for Duotecno binary sensors."""
from duotecno.unit import ControlUnit
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN
from .entity import DuotecnoEntity
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Duotecno binary sensor on config_entry."""
cntrl = hass.data[DOMAIN][entry.entry_id]
async_add_entities(
DuotecnoBinarySensor(channel) for channel in cntrl.get_units("ControlUnit")
)
class DuotecnoBinarySensor(DuotecnoEntity, BinarySensorEntity):
"""Representation of a DuotecnoBinarySensor."""
_unit: ControlUnit
@property
def is_on(self) -> bool:
"""Return true if the binary sensor is on."""
return self._unit.is_on()