-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dehumidifier sensor for notification light #842
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
from __future__ import annotations | ||
|
||
import logging | ||
|
||
from enum import Enum | ||
|
||
from ..backports.functools import cached_property | ||
|
@@ -28,6 +30,7 @@ | |
STATE_PM10 = ["SensorPM10", "airState.quality.PM10"] | ||
STATE_PM25 = ["SensorPM2", "airState.quality.PM2"] | ||
STATE_TANK_LIGHT = ["WatertankLight", "airState.miscFuncState.watertankLight"] | ||
STATE_NOTIFICATION_LIGHT = ["NotificationLight", "airState.notificationExt"] | ||
|
||
STATE_POWER = [STATE_POWER_V1, "airState.energy.onCurrent"] | ||
|
||
|
@@ -44,6 +47,8 @@ | |
|
||
ADD_FEAT_POLL_INTERVAL = 300 # 5 minutes | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class DHumOp(Enum): | ||
"""Whether a device is on or off.""" | ||
|
@@ -314,9 +319,36 @@ def water_tank_full(self): | |
return None | ||
return self._update_feature(DehumidifierFeatures.WATER_TANK_FULL, value) | ||
|
||
@property | ||
def notification_light(self) -> bool | None: | ||
"""Return notification light status.""" | ||
try: | ||
key = self._get_state_key(STATE_NOTIFICATION_LIGHT) | ||
except: | ||
key = None | ||
_LOGGER.exception("LGE ThinQ dehumidifier - unable to get Notification Light status") | ||
if key is None: | ||
ntf_real_value = None | ||
ntf_light_int_value = None | ||
ntf_light_bool_val = None | ||
Comment on lines
+325
to
+333
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will generate a lot of log exception for devices that do not support this feature. Please just return Nonw |
||
else: | ||
ntf_real_value = self.lookup_range(key) | ||
ntf_light_int_value = self.to_int_or_none(ntf_real_value) | ||
if ntf_light_int_value is None: | ||
ntf_light_bool_val = None | ||
_LOGGER.warning(f"LGE ThinQ dehumidifier Notification light is {ntf_real_value}. int {ntf_light_int_value}. bool {ntf_light_bool_val}") | ||
Comment on lines
+337
to
+339
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. If we don't have values, return None |
||
elif ntf_light_int_value > 0: | ||
ntf_light_bool_val = True | ||
else: | ||
ntf_light_bool_val = False | ||
if ntf_light_bool_val is not None: | ||
_LOGGER.debug(f"LGE ThinQ dehumidifier Notification light is {ntf_real_value}. int {ntf_light_int_value}. bool {ntf_light_bool_val}") | ||
return self._update_feature(DehumidifierFeatures.NOTIFICATION_LIGHT, ntf_light_bool_val) | ||
Comment on lines
+340
to
+346
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this point you can just simplify with
But are you sure that this is an int with value > 0 to define |
||
|
||
def _update_features(self): | ||
_ = [ | ||
self.current_humidity, | ||
self.target_humidity, | ||
self.water_tank_full, | ||
self.notification_light | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove if you don't use anymore