Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ankitmehtame
Copy link

Add sensor for dehumidifier notification light in HA. May also help with #778 if anyone wants to use the notification light as the water tank sensor status doesn't seem to change.

Use `airState.notificationExt` to get water tank status
* 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
@ankitmehtame ankitmehtame marked this pull request as ready for review December 16, 2024 05:46
Comment on lines +325 to +333
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
Copy link
Owner

Choose a reason for hiding this comment

The 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

Comment on lines +337 to +339
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}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. If we don't have values, return None

Comment on lines +340 to +346
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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point you can just simplify with

return self._update_feature(DehumidifierFeatures.NOTIFICATION_LIGHT, ntf_light_int_value > 0, False)

But are you sure that this is an int with value > 0 to define light on?

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

ADD_FEAT_POLL_INTERVAL = 300 # 5 minutes

_LOGGER = logging.getLogger(__name__)
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants