mirror of
https://github.com/natekspencer/hacs-oasis_mini.git
synced 2025-11-08 05:03:52 -05:00
Switch busy and wifi_connected sensors to binary sensors
This commit is contained in:
@@ -19,6 +19,7 @@ type OasisMiniConfigEntry = ConfigEntry[OasisMiniCoordinator]
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.BUTTON,
|
||||
Platform.IMAGE,
|
||||
Platform.LIGHT,
|
||||
|
||||
55
custom_components/oasis_mini/binary_sensor.py
Normal file
55
custom_components/oasis_mini/binary_sensor.py
Normal 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)
|
||||
@@ -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 = (
|
||||
|
||||
Reference in New Issue
Block a user