8000 Add support for HS color to mqtt light by emontnemery · Pull Request #16958 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 2 commits into from
Oct 8, 2018

Conversation

emontnemery
Copy link
Contributor
@emontnemery emontnemery commented Sep 29, 2018

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:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • Documentation added/updated in home-assistant.io
  • Tests have been added to verify that the new code works.

_LOGGER.debug("Ignoring empty hs message from '%s'", topic)
return

hs_color = [float(val) for val in payload.split(',')][0:2]
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author
@emontnemery emontnemery Oct 1, 2018

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)

Copy link
Member

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.

Copy link
Contributor Author

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)

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)

@emontnemery
Copy link
Contributor Author

@balloob Are more changes required?

@balloob balloob merged commit 42fb886 into home-assistant:dev Oct 8, 2018
@ghost ghost removed the in progress label Oct 8, 2018
@emontnemery emontnemery deleted the mqtt_light_hs branch October 12, 2018 13:10
@balloob balloob mentioned this pull request Oct 26, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0