Add binary sensors for duotecno (#100844)
* Add binary sensors for duotecno * Add comments
This commit is contained in:
parent
77007ef091
commit
8a44adb447
3 changed files with 36 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -16,6 +16,7 @@ PLATFORMS: list[Platform] = [
|
|||
Platform.COVER,
|
||||
Platform.LIGHT,
|
||||
Platform.CLIMATE,
|
||||
Platform.BINARY_SENSOR,
|
||||
]
|
||||
|
||||
|
||||
|
|
34
homeassistant/components/duotecno/binary_sensor.py
Normal file
34
homeassistant/components/duotecno/binary_sensor.py
Normal 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()
|
Loading…
Add table
Reference in a new issue