mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Create a binary sensor for each Duotecno virtual unit (#102347)
This commit is contained in:
parent
da653c36fd
commit
5e483c5573
@ -1,6 +1,6 @@
|
|||||||
"""Support for Duotecno binary sensors."""
|
"""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.components.binary_sensor import BinarySensorEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -19,14 +19,15 @@ async def async_setup_entry(
|
|||||||
"""Set up Duotecno binary sensor on config_entry."""
|
"""Set up Duotecno binary sensor on config_entry."""
|
||||||
cntrl = hass.data[DOMAIN][entry.entry_id]
|
cntrl = hass.data[DOMAIN][entry.entry_id]
|
||||||
async_add_entities(
|
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):
|
class DuotecnoBinarySensor(DuotecnoEntity, BinarySensorEntity):
|
||||||
"""Representation of a DuotecnoBinarySensor."""
|
"""Representation of a DuotecnoBinarySensor."""
|
||||||
|
|
||||||
_unit: ControlUnit
|
_unit: ControlUnit | VirtualUnit
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user