Skip to content

Commit

Permalink
update/add PH sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
jkhalil committed Oct 31, 2023
1 parent 7c7ff3f commit 5d39a58
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/eheim_digital/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class EheimBinarySensorDescription(
# Heater Binary Sensors
EheimBinarySensorDescription(
key="heater_is_heating",
device_class=BinarySensorDeviceClass.RUNNING,
device_class=BinarySensorDeviceClass.HEAT,
name="Heater Is Heating",
entity_registry_enabled_default=True,
value_fn=lambda data: data.get("isHeating"),
Expand Down Expand Up @@ -95,9 +95,9 @@ class EheimBinarySensorDescription(
EheimBinarySensorDescription(
key="filter_is_active",
device_class=BinarySensorDeviceClass.RUNNING,
name="Filter State",
name="Filter Is Active",
entity_registry_enabled_default=True,
value_fn=lambda data: data.get("FilterActive"),
value_fn=lambda data: data.get("filterActive"),
),
)

Expand Down
24 changes: 24 additions & 0 deletions custom_components/eheim_digital/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,32 +158,54 @@ class EheimSensorDescription(SensorEntityDescription, EheimSensorDescriptionMixi
# PH Control Sensors
EheimSensorDescription(
key="ph_current_ph",
icon="mdi:pH",
device_class=SensorDeviceClass.PH,
name="Current PH",
entity_registry_enabled_default=True,
value_fn=lambda data: round((int(data["isPH"]) / 10), 1),
),
EheimSensorDescription(
key="ph_target_ph",
icon="mdi:pH",
device_class=SensorDeviceClass.PH,
name="Target PH",
entity_registry_enabled_default=True,
value_fn=lambda data: round((int(data["sollPH"]) / 10), 1),
),
EheimSensorDescription(
key="ph_dayStart_time",
mdi_icon="mdi:clock-time-six",
device_class=SensorDeviceClass.TIMESTAMP,
name="Day Start Time",
entity_registry_enabled_default=True,
value_fn=lambda data: data.get("dayStartT"),
),
EheimSensorDescription(
key="ph_nightStart_time",
mdi_icon="mdi:clock-time-eight",
device_class=SensorDeviceClass.TIMESTAMP,
name="Night Start Time",
entity_registry_enabled_default=True,
value_fn=lambda data: data.get("nightStartT"),
),
EheimSensorDescription(
key="kH_valve",
mdi_icon="mdi:water-thermometer",
device_class=SensorDeviceClass.CO2,
name="kH Value",
entity_registry_enabled_default=True,
value_fn=lambda data: round(data.get("kH")),
),
EheimSensorDescription(
key="next_ph_service",
device_class=SensorDeviceClass.TIMESTAMP,
icon="mdi:wrench-clock",
name="Next PH Service",
entity_registry_enabled_default=True,
value_fn=lambda data: (
dt_util.utcnow() + timedelta(days=data.get("serviceTime", 0))
),
),
)

SENSOR_GROUPS = {
Expand All @@ -208,6 +230,8 @@ class EheimSensorDescription(SensorEntityDescription, EheimSensorDescriptionMixi
"ph_target_ph",
"ph_dayStart_time",
"ph_nightStart_time",
"kH_valve",
"next_ph_service",
],
"other": [],
}
Expand Down

0 comments on commit 5d39a58

Please sign in to comment.