1
0
mirror of https://github.com/natekspencer/hacs-oasis_mini.git synced 2025-12-06 18:44:14 -05:00
Files
hacs-oasis_mini/custom_components/oasis_mini/binary_sensor.py
2025-11-22 04:40:58 +00:00

57 lines
1.7 KiB
Python

"""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
from .coordinator import OasisDeviceCoordinator
from .entity import OasisDeviceEntity
async def async_setup_entry(
hass: HomeAssistant,
entry: OasisDeviceConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Oasis device sensors using config entry."""
coordinator: OasisDeviceCoordinator = entry.runtime_data
async_add_entities(
OasisDeviceBinarySensorEntity(coordinator, device, descriptor)
for device in coordinator.data
for descriptor in DESCRIPTORS
)
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)