mirror of
https://github.com/home-assistant/core.git
synced 2026-06-01 13:14:35 +01:00
d766aae436
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: frenck <195327+frenck@users.noreply.github.com>
214 lines
7.2 KiB
Python
214 lines
7.2 KiB
Python
"""Binary sensors for the Seko PoolDose integration."""
|
|
|
|
import logging
|
|
from typing import TYPE_CHECKING, cast
|
|
|
|
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 AddConfigEntryEntitiesCallback
|
|
|
|
from . import PooldoseConfigEntry
|
|
from .entity import PooldoseEntity
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
PARALLEL_UPDATES = 0
|
|
|
|
|
|
BINARY_SENSOR_DESCRIPTIONS: tuple[BinarySensorEntityDescription, ...] = (
|
|
BinarySensorEntityDescription(
|
|
key="pump_alarm",
|
|
translation_key="pump_alarm",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="ph_level_alarm",
|
|
translation_key="ph_level_alarm",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="orp_level_alarm",
|
|
translation_key="orp_level_alarm",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="flow_rate_alarm",
|
|
translation_key="flow_rate_alarm",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_ofa_ph",
|
|
translation_key="alarm_ofa_ph",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_ofa_orp",
|
|
translation_key="alarm_ofa_orp",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_ofa_cl",
|
|
translation_key="alarm_ofa_cl",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="relay_alarm",
|
|
translation_key="relay_alarm",
|
|
device_class=BinarySensorDeviceClass.POWER,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="relay_aux1",
|
|
translation_key="relay_aux1",
|
|
device_class=BinarySensorDeviceClass.POWER,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
entity_registry_enabled_default=False,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="relay_aux2",
|
|
translation_key="relay_aux2",
|
|
device_class=BinarySensorDeviceClass.POWER,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
entity_registry_enabled_default=False,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="relay_aux3",
|
|
translation_key="relay_aux3",
|
|
device_class=BinarySensorDeviceClass.POWER,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
entity_registry_enabled_default=False,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_ofa2_ph",
|
|
translation_key="alarm_ofa_ph_alternative",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_ofa2_orp",
|
|
translation_key="alarm_ofa_orp_alternative",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_ofa2_cl",
|
|
translation_key="alarm_ofa_cl_alternative",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_water_too_cold",
|
|
translation_key="alarm_water_too_cold",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_water_too_hot",
|
|
translation_key="alarm_water_too_hot",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_ph_too_low",
|
|
translation_key="alarm_ph_too_low",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_ph_too_high",
|
|
translation_key="alarm_ph_too_high",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_cl_too_low_orp",
|
|
translation_key="alarm_cl_too_low_orp",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_cl_too_high_orp",
|
|
translation_key="alarm_cl_too_high_orp",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_cl_too_high",
|
|
translation_key="alarm_cl_too_high",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="alarm_system_standby",
|
|
translation_key="alarm_system_standby",
|
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="circulation_pump_status",
|
|
translation_key="circulation_pump_status",
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
entity_registry_enabled_default=False,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="power_on_delay_status",
|
|
translation_key="power_on_delay_status",
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
entity_registry_enabled_default=False,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="flow_delay_status",
|
|
translation_key="flow_delay_status",
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
entity_registry_enabled_default=False,
|
|
),
|
|
)
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant,
|
|
config_entry: PooldoseConfigEntry,
|
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
|
) -> None:
|
|
"""Set up PoolDose binary sensor entities from a config entry."""
|
|
if TYPE_CHECKING:
|
|
assert config_entry.unique_id is not None
|
|
|
|
coordinator = config_entry.runtime_data
|
|
binary_sensor_data = coordinator.data["binary_sensor"]
|
|
serial_number = config_entry.unique_id
|
|
|
|
async_add_entities(
|
|
PooldoseBinarySensor(
|
|
coordinator,
|
|
serial_number,
|
|
coordinator.device_info,
|
|
description,
|
|
"binary_sensor",
|
|
)
|
|
for description in BINARY_SENSOR_DESCRIPTIONS
|
|
if description.key in binary_sensor_data
|
|
)
|
|
|
|
|
|
class PooldoseBinarySensor(PooldoseEntity, BinarySensorEntity):
|
|
"""Binary sensor entity for the Seko PoolDose Python API."""
|
|
|
|
@property
|
|
def is_on(self) -> bool:
|
|
"""Return true if the binary sensor is on."""
|
|
data = cast(dict, self.get_data())
|
|
return cast(bool, data["value"])
|