Skip to content

Improve precision of Hue color state#14113

Merged
pvizeli merged 1 commit intohome-assistant:devfrom
amelchio:hue-xy-state
Apr 27, 2018
Merged

Improve precision of Hue color state#14113
pvizeli merged 1 commit intohome-assistant:devfrom
amelchio:hue-xy-state

Conversation

@amelchio
Copy link
Copy Markdown
Contributor

Description:

We are currently setting colors using the xy API of Hue and getting HS values, converting each as necessary.

However, xy<->HS conversions are bulb dependent so we cannot match the conversion done in-bulb.

This PR changes to read out the true xy value that was set. We will still do some conversions but the errors should cancel out because it's now all done inside HA.

The change had some testing in the linked issue though I do not have Hue bulbs myself.

(Note that this PR only makes each separate attribute consistent between write-read. Conversions are still unpredictable across color models. Setting xy, reading HS and then setting that HS will not give the original xy value.)

Related issue (if applicable): fixes #13944

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox.

@pvizeli pvizeli merged commit 0b35099 into home-assistant:dev Apr 27, 2018
@amelchio amelchio added this to the 0.68.1 milestone Apr 29, 2018
balloob pushed a commit that referenced this pull request Apr 30, 2018
@balloob balloob mentioned this pull request Apr 30, 2018
@lvlie
Copy link
Copy Markdown

lvlie commented May 1, 2018

Unfortunately this results in the following periodic error for me:

018-05-01 22:17:58 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 316, in _async_add_entity
    await entity.async_update_ha_state()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 222, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/src/app/homeassistant/components/light/__init__.py", line 506, in state_attributes
    value = getattr(self, prop)
  File "/usr/src/app/homeassistant/components/light/hue.py", line 249, in hs_color
    return color.color_xy_to_hs(*source['xy'])
KeyError: 'xy'

Anything I can do to fix this?

@amelchio amelchio mentioned this pull request May 1, 2018
3 tasks
@amelchio
Copy link
Copy Markdown
Contributor Author

amelchio commented May 1, 2018

Thanks for reporting, I think #14230 should fix that.

BTW please do not comment in closed tickets but rather create a new issue when you find a new bug 👍

@lvlie
Copy link
Copy Markdown

lvlie commented May 1, 2018

Cool, thanks. You are of course right about the issue, apologies :-)

@home-assistant home-assistant locked and limited conversation to collaborators Sep 5, 2018
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.

Philips Hue XY Colour not matching input values

5 participants