Skip to content

Commit bdbdd8f

Browse files
authored
Dehumidifer water tank full (#1)
* Update water tank full sensor Updated to be based on airState.notificationExt and int rather than bool * Add separate field for notification light, defensive code with logging * Updated to lookup value * Improve logging * Always log notification light value * Keep notification light as integer * Make notification light int * Make the notification light bool again * Cleanup sensor, categorize notification light as problem
1 parent 2592ec7 commit bdbdd8f

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

custom_components/smartthinq_sensors/binary_sensor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ class ThinQBinarySensorEntityDescription(BinarySensorEntityDescription):
198198
key=DehumidifierFeatures.WATER_TANK_FULL,
199199
name="Water Tank Full",
200200
),
201+
ThinQBinarySensorEntityDescription(
202+
key=DehumidifierFeatures.NOTIFICATION_LIGHT,
203+
name="Notification Light",
204+
device_class=BinarySensorDeviceClass.PROBLEM,
205+
value_fn=lambda x: x.notification_light,
206+
),
201207
)
202208

203209
BINARY_SENSOR_ENTITIES = {

custom_components/smartthinq_sensors/wideq/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class DehumidifierFeatures(StrEnum):
8080
HUMIDITY = "humidity"
8181
TARGET_HUMIDITY = "target_humidity"
8282
WATER_TANK_FULL = "water_tank_full"
83+
NOTIFICATION_LIGHT = "notification_light"
8384

8485

8586
class RangeFeatures(StrEnum):

custom_components/smartthinq_sensors/wideq/devices/dehumidifier.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from __future__ import annotations
44

5+
import logging
6+
57
from enum import Enum
68

79
from ..backports.functools import cached_property
@@ -27,7 +29,8 @@
2729
STATE_PM1 = ["SensorPM1", "airState.quality.PM1"]
2830
STATE_PM10 = ["SensorPM10", "airState.quality.PM10"]
2931
STATE_PM25 = ["SensorPM2", "airState.quality.PM2"]
30-
STATE_TANK_LIGHT = ["WatertankLight", "airState.notificationExt"]
32+
STATE_TANK_LIGHT = ["WatertankLight", "airState.miscFuncState.watertankLight"]
33+
STATE_NOTIFICATION_LIGHT = ["NotificationLight", "airState.notificationExt"]
3134

3235
STATE_POWER = [STATE_POWER_V1, "airState.energy.onCurrent"]
3336

@@ -44,6 +47,8 @@
4447

4548
ADD_FEAT_POLL_INTERVAL = 300 # 5 minutes
4649

50+
_LOGGER = logging.getLogger(__name__)
51+
4752

4853
class DHumOp(Enum):
4954
"""Whether a device is on or off."""
@@ -314,9 +319,36 @@ def water_tank_full(self):
314319
return None
315320
return self._update_feature(DehumidifierFeatures.WATER_TANK_FULL, value)
316321

322+
@property
323+
def notification_light(self) -> bool | None:
324+
"""Return notification light status."""
325+
try:
326+
key = self._get_state_key(STATE_NOTIFICATION_LIGHT)
327+
except:
328+
key = None
329+
_LOGGER.exception("LGE ThinQ dehumidifier - unable to get Notification Light status")
330+
if key is None:
331+
ntf_real_value = None
332+
ntf_light_int_value = None
333+
ntf_light_bool_val = None
334+
else:
335+
ntf_real_value = self.lookup_range(key)
336+
ntf_light_int_value = self.to_int_or_none(ntf_real_value)
337+
if ntf_light_int_value is None:
338+
ntf_light_bool_val = None
339+
_LOGGER.warning(f"LGE ThinQ dehumidifier Notification light is {ntf_real_value}. int {ntf_light_int_value}. bool {ntf_light_bool_val}")
340+
elif ntf_light_int_value > 0:
341+
ntf_light_bool_val = True
342+
else:
343+
ntf_light_bool_val = False
344+
if ntf_light_bool_val is not None:
345+
_LOGGER.debug(f"LGE ThinQ dehumidifier Notification light is {ntf_real_value}. int {ntf_light_int_value}. bool {ntf_light_bool_val}")
346+
return self._update_feature(DehumidifierFeatures.NOTIFICATION_LIGHT, ntf_light_bool_val)
347+
317348
def _update_features(self):
318349
_ = [
319350
self.current_humidity,
320351
self.target_humidity,
321352
self.water_tank_full,
353+
self.notification_light
322354
]

0 commit comments

Comments
 (0)