1
0
mirror of https://github.com/natekspencer/hacs-oasis_mini.git synced 2025-11-08 05:03:52 -05:00

Merge pull request #50 from natekspencer/binary-sensors

Switch busy and wifi_connected sensors to binary sensors
This commit is contained in:
Nathan Spencer
2025-01-10 15:17:02 -07:00
committed by GitHub
3 changed files with 57 additions and 7 deletions

View File

@@ -19,6 +19,7 @@ type OasisMiniConfigEntry = ConfigEntry[OasisMiniCoordinator]
_LOGGER = logging.getLogger(__name__)
PLATFORMS = [
Platform.BINARY_SENSOR,
Platform.BUTTON,
Platform.IMAGE,
Platform.LIGHT,

View File

@@ -0,0 +1,55 @@
"""Oasis Mini 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 OasisMiniConfigEntry
from .coordinator import OasisMiniCoordinator
from .entity import OasisMiniEntity
async def async_setup_entry(
hass: HomeAssistant,
entry: OasisMiniConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Oasis Mini sensors using config entry."""
coordinator: OasisMiniCoordinator = entry.runtime_data
async_add_entities(
OasisMiniBinarySensorEntity(coordinator, descriptor)
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 OasisMiniBinarySensorEntity(OasisMiniEntity, BinarySensorEntity):
"""Oasis Mini 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)

View File

@@ -52,13 +52,7 @@ DESCRIPTORS = {
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
)
for key in (
"busy",
"error",
"led_color_id",
"status",
"wifi_connected",
)
for key in ("error", "led_color_id", "status")
}
CLOUD_DESCRIPTORS = (