Add Screenlogic IntelliChem and SCG data (#49689)
This commit is contained in:
parent
4b74c57285
commit
41c6474249
4 changed files with 175 additions and 22 deletions
|
@ -1,7 +1,7 @@
|
|||
"""Support for a ScreenLogic Binary Sensor."""
|
||||
import logging
|
||||
|
||||
from screenlogicpy.const import DATA as SL_DATA, DEVICE_TYPE, ON_OFF
|
||||
from screenlogicpy.const import DATA as SL_DATA, DEVICE_TYPE, EQUIPMENT, ON_OFF
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_PROBLEM,
|
||||
|
@ -24,6 +24,37 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
# Generic binary sensor
|
||||
entities.append(ScreenLogicBinarySensor(coordinator, "chem_alarm"))
|
||||
|
||||
if (
|
||||
coordinator.data[SL_DATA.KEY_CONFIG]["equipment_flags"]
|
||||
& EQUIPMENT.FLAG_INTELLICHEM
|
||||
):
|
||||
# IntelliChem alarm sensors
|
||||
entities.extend(
|
||||
[
|
||||
ScreenlogicChemistryAlarmBinarySensor(coordinator, chem_alarm)
|
||||
for chem_alarm in coordinator.data[SL_DATA.KEY_CHEMISTRY][
|
||||
SL_DATA.KEY_ALERTS
|
||||
]
|
||||
]
|
||||
)
|
||||
|
||||
# Intellichem notification sensors
|
||||
entities.extend(
|
||||
[
|
||||
ScreenlogicChemistryNotificationBinarySensor(coordinator, chem_notif)
|
||||
for chem_notif in coordinator.data[SL_DATA.KEY_CHEMISTRY][
|
||||
SL_DATA.KEY_NOTIFICATIONS
|
||||
]
|
||||
]
|
||||
)
|
||||
|
||||
if (
|
||||
coordinator.data[SL_DATA.KEY_CONFIG]["equipment_flags"]
|
||||
& EQUIPMENT.FLAG_CHLORINATOR
|
||||
):
|
||||
# SCG binary sensor
|
||||
entities.append(ScreenlogicSCGBinarySensor(coordinator, "scg_status"))
|
||||
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -38,8 +69,8 @@ class ScreenLogicBinarySensor(ScreenlogicEntity, BinarySensorEntity):
|
|||
@property
|
||||
def device_class(self):
|
||||
"""Return the device class."""
|
||||
device_class = self.sensor.get("device_type")
|
||||
return SL_DEVICE_TYPE_TO_HA_DEVICE_CLASS.get(device_class)
|
||||
device_type = self.sensor.get("device_type")
|
||||
return SL_DEVICE_TYPE_TO_HA_DEVICE_CLASS.get(device_type)
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
|
@ -50,3 +81,34 @@ class ScreenLogicBinarySensor(ScreenlogicEntity, BinarySensorEntity):
|
|||
def sensor(self):
|
||||
"""Shortcut to access the sensor data."""
|
||||
return self.coordinator.data[SL_DATA.KEY_SENSORS][self._data_key]
|
||||
|
||||
|
||||
class ScreenlogicChemistryAlarmBinarySensor(ScreenLogicBinarySensor):
|
||||
"""Representation of a ScreenLogic IntelliChem alarm binary sensor entity."""
|
||||
|
||||
@property
|
||||
def sensor(self):
|
||||
"""Shortcut to access the sensor data."""
|
||||
return self.coordinator.data[SL_DATA.KEY_CHEMISTRY][SL_DATA.KEY_ALERTS][
|
||||
self._data_key
|
||||
]
|
||||
|
||||
|
||||
class ScreenlogicChemistryNotificationBinarySensor(ScreenLogicBinarySensor):
|
||||
"""Representation of a ScreenLogic IntelliChem notification binary sensor entity."""
|
||||
|
||||
@property
|
||||
def sensor(self):
|
||||
"""Shortcut to access the sensor data."""
|
||||
return self.coordinator.data[SL_DATA.KEY_CHEMISTRY][SL_DATA.KEY_NOTIFICATIONS][
|
||||
self._data_key
|
||||
]
|
||||
|
||||
|
||||
class ScreenlogicSCGBinarySensor(ScreenLogicBinarySensor):
|
||||
"""Representation of a ScreenLogic SCG binary sensor entity."""
|
||||
|
||||
@property
|
||||
def sensor(self):
|
||||
"""Shortcut to access the sensor data."""
|
||||
return self.coordinator.data[SL_DATA.KEY_SCG][self._data_key]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue