"""Support for Velbus Binary Sensors.""" from velbusaio.channels import Button as VelbusButton 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 VelbusEntity async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: """Set up Velbus switch based on config_entry.""" await hass.data[DOMAIN][entry.entry_id]["tsk"] cntrl = hass.data[DOMAIN][entry.entry_id]["cntrl"] async_add_entities( VelbusBinarySensor(channel) for channel in cntrl.get_all("binary_sensor") ) class VelbusBinarySensor(VelbusEntity, BinarySensorEntity): """Representation of a Velbus Binary Sensor.""" _channel: VelbusButton @property def is_on(self) -> bool: """Return true if the sensor is on.""" return self._channel.is_closed()