Skip to content

Add support for HS color to mqtt light#16958

Merged
balloob merged 2 commits intohome-assistant:devfrom
emontnemery:mqtt_light_hs
Oct 8, 2018
Merged

Add support for HS color to mqtt light#16958
balloob merged 2 commits intohome-assistant:devfrom
emontnemery:mqtt_light_hs

Conversation

@emontnemery
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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)
Copy link
Copy Markdown

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
Copy Markdown
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