-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Add support for HS color to mqtt light #16958
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
Conversation
2ea0892
to
4ff98a2
Compare
_LOGGER.debug("Ignoring empty hs message from '%s'", topic) | ||
return | ||
|
||
hs_color = [float(val) for val in payload.split(',')][0:2] |
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.
We should catch ValueError
in case it's not valid data.
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.
Also make it .split(',', 2)
to capture more invalid data.
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.
Alright, something like below then?
try:
hs_color = [float(val) for val in payload.split(',', 2)][0:2]
self._hs = hs_color
self.async_schedule_update_ha_state()
except (ValueError):
_LOGGER.debug("Failed to parse hs state update: '%s'", payload)
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.
No need for [0:2]
but yeah.
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.
OK, fixed.
self._hs = hs_color | ||
self.async_schedule_update_ha_state() | ||
except (ValueError): | ||
_LOGGER.debug("Failed to parse hs state update: '%s'", payload) |
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.
line too long (80 > 79 characters)
005e4fa
to
5e68610
Compare
@balloob Are more changes required? |
Description:
Add support for HS color to mqtt light
Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#6377
Checklist:
tox
. Your PR cannot be merged unless tests pass