"""Oasis device binary sensor entity.""" from __future__ import annotations from homeassistant.components.binary_sensor import ( BinarySensorDeviceClass, BinarySensorEntity, BinarySensorEntityDescription, ) from homeassistant.const import EntityCategory from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import OasisDeviceConfigEntry, setup_platform_from_coordinator from .entity import OasisDeviceEntity from .pyoasiscontrol import OasisDevice async def async_setup_entry( hass: HomeAssistant, entry: OasisDeviceConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: """Set up Oasis device sensors using config entry.""" def make_entities(new_devices: list[OasisDevice]): return [ OasisDeviceBinarySensorEntity(entry.runtime_data, device, descriptor) for device in new_devices for descriptor in DESCRIPTORS ] setup_platform_from_coordinator(entry, async_add_entities, make_entities) DESCRIPTORS = { BinarySensorEntityDescription( key="busy", translation_key="busy", entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=False, ), BinarySensorEntityDescription( key="wifi_connected", translation_key="wifi_status", device_class=BinarySensorDeviceClass.CONNECTIVITY, entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=False, ), } class OasisDeviceBinarySensorEntity(OasisDeviceEntity, BinarySensorEntity): """Oasis device binary sensor entity.""" @property def is_on(self) -> bool: """Return true if the binary sensor is on.""" return getattr(self.device, self.entity_description.key)