Create a binary sensor for each Duotecno virtual unit (#102347)

pull/102014/head^2
Maikel Punie 2023-10-20 16:02:56 +02:00 committed by GitHub
parent da653c36fd
commit 5e483c5573
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,6 @@
"""Support for Duotecno binary sensors."""
from duotecno.unit import ControlUnit
from duotecno.unit import ControlUnit, VirtualUnit
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.config_entries import ConfigEntry
@ -19,14 +19,15 @@ async def async_setup_entry(
"""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")
DuotecnoBinarySensor(channel)
for channel in cntrl.get_units(["ControlUnit", "VirtualUnit"])
)
class DuotecnoBinarySensor(DuotecnoEntity, BinarySensorEntity):
"""Representation of a DuotecnoBinarySensor."""
_unit: ControlUnit
_unit: ControlUnit | VirtualUnit
@property
def is_on(self) -> bool: