2019-02-13 20:21:14 +00:00
|
|
|
"""Support for Velbus Binary Sensors."""
|
2020-04-23 19:57:07 +00:00
|
|
|
from homeassistant.components.binary_sensor import BinarySensorEntity
|
2019-03-21 05:56:46 +00:00
|
|
|
|
2019-07-29 07:21:26 +00:00
|
|
|
from . import VelbusEntity
|
2019-12-09 08:36:42 +00:00
|
|
|
from .const import DOMAIN
|
2017-07-26 12:03:29 +00:00
|
|
|
|
|
|
|
|
2019-07-29 07:21:26 +00:00
|
|
|
async def async_setup_entry(hass, entry, async_add_entities):
|
2021-09-13 06:22:46 +00:00
|
|
|
"""Set up Velbus switch based on config_entry."""
|
|
|
|
await hass.data[DOMAIN][entry.entry_id]["tsk"]
|
2019-07-31 19:25:30 +00:00
|
|
|
cntrl = hass.data[DOMAIN][entry.entry_id]["cntrl"]
|
2019-07-29 07:21:26 +00:00
|
|
|
entities = []
|
2021-09-13 06:22:46 +00:00
|
|
|
for channel in cntrl.get_all("binary_sensor"):
|
|
|
|
entities.append(VelbusBinarySensor(channel))
|
2019-07-29 07:21:26 +00:00
|
|
|
async_add_entities(entities)
|
2017-07-26 12:03:29 +00:00
|
|
|
|
|
|
|
|
2020-04-23 19:57:07 +00:00
|
|
|
class VelbusBinarySensor(VelbusEntity, BinarySensorEntity):
|
2017-07-26 12:03:29 +00:00
|
|
|
"""Representation of a Velbus Binary Sensor."""
|
|
|
|
|
|
|
|
@property
|
2021-09-13 06:22:46 +00:00
|
|
|
def is_on(self) -> bool:
|
2017-07-26 12:03:29 +00:00
|
|
|
"""Return true if the sensor is on."""
|
2021-09-13 06:22:46 +00:00
|
|
|
return self._channel.is_closed()
|