mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Add Controller state sensor to screenlogic (#133827)
This commit is contained in:
parent
0dd9845501
commit
42532e9695
@ -9,7 +9,7 @@ from screenlogicpy.const.data import ATTR, DEVICE, GROUP, VALUE
|
||||
from screenlogicpy.const.msg import CODE
|
||||
from screenlogicpy.device_const.chemistry import DOSE_STATE
|
||||
from screenlogicpy.device_const.pump import PUMP_TYPE
|
||||
from screenlogicpy.device_const.system import EQUIPMENT_FLAG
|
||||
from screenlogicpy.device_const.system import CONTROLLER_STATE, EQUIPMENT_FLAG
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
DOMAIN as SENSOR_DOMAIN,
|
||||
@ -41,7 +41,7 @@ class ScreenLogicSensorDescription(
|
||||
):
|
||||
"""Describes a ScreenLogic sensor."""
|
||||
|
||||
value_mod: Callable[[int | str], int | str] | None = None
|
||||
value_mod: Callable[[int | str], int | str | None] | None = None
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True, kw_only=True)
|
||||
@ -60,6 +60,18 @@ SUPPORTED_CORE_SENSORS = [
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
translation_key="air_temperature",
|
||||
),
|
||||
ScreenLogicPushSensorDescription(
|
||||
subscription_code=CODE.STATUS_CHANGED,
|
||||
data_root=(DEVICE.CONTROLLER, GROUP.SENSOR),
|
||||
key=VALUE.STATE,
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=["ready", "sync", "service"],
|
||||
value_mod=lambda val: (
|
||||
CONTROLLER_STATE(val).name.lower() if val in [1, 2, 3] else None
|
||||
),
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
translation_key="controller_state",
|
||||
),
|
||||
]
|
||||
|
||||
SUPPORTED_PUMP_SENSORS = [
|
||||
@ -344,7 +356,7 @@ class ScreenLogicSensor(ScreenLogicEntity, SensorEntity):
|
||||
)
|
||||
|
||||
@property
|
||||
def native_value(self) -> str | int | float:
|
||||
def native_value(self) -> str | int | float | None:
|
||||
"""State of the sensor."""
|
||||
val = self.entity_data[ATTR.VALUE]
|
||||
value_mod = self.entity_description.value_mod
|
||||
|
@ -184,6 +184,14 @@
|
||||
"air_temperature": {
|
||||
"name": "Air temperature"
|
||||
},
|
||||
"controller_state": {
|
||||
"name": "Controller state",
|
||||
"state": {
|
||||
"ready": "Ready",
|
||||
"sync": "Sync",
|
||||
"service": "Service"
|
||||
}
|
||||
},
|
||||
"chem_now": {
|
||||
"name": "{chem} now"
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user