Skip to content

Update tradfri v5#11187

Merged
balloob merged 53 commits intodevfrom
update_tradfri_5
Mar 28, 2018
Merged

Update tradfri v5#11187
balloob merged 53 commits intodevfrom
update_tradfri_5

Conversation

@lwis
Copy link
Copy Markdown
Member

@lwis lwis commented Dec 17, 2017

Description:

Improved colour handling from library.

@NovapaX
Copy link
Copy Markdown
Contributor

NovapaX commented Dec 18, 2017

That weird UI behaviour is not new. I believe it's been there all the time, but with the new color wheel it's way more obvious.
(with the old color picker it just looked like you tapped wrong)

I think it has something to do with the color roundtrip from hass update -> gateway change -> hass updating based on gateway info -> color reflecting in UI.
I haven't had time to debug it to see where it goes wrong.
I've noticed the issue only once because our color light is in the kids room (they like to pick a color before going to sleep) and we use the tradfri remote/switch mostly for that.
And when they are sleeping it's not really desirable to play around with that light 😃

@lwis
Copy link
Copy Markdown
Member Author

lwis commented Dec 18, 2017

@NovapaX I think @ggravlingen and I have found the issue with the strange behaviour we were saying.

Do you know where this logic comes from? We end up with rounding errors going back and forth between the gateway, and I was wondering where the normalisation math comes from?


def denormalize_xy(argx, argy, brightness=None):
"""Denormalise XY from Tradfri scaling."""
return (int(argx/65535-0.5), int(argy/65535-0.5))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This must return a float

@NovapaX
Copy link
Copy Markdown
Contributor

NovapaX commented Dec 18, 2017

I have really no idea where that comes from. As far as I can see (git blame) you put it in there with this PR 😜
I know what it does: convert between two different XY coordinate systems.
Looking to the state of things (literally) from UI to light we go from: Hue/saturation -> RGB -> XY -> Tradfri-specific-XY and all the way back before it is reflected in the UI again. Some small rounding errors are expected
But indeed it looks like that should return a float. :)

I've only done some work on the platform and on the color wheel UI. Nothing specific to trafdri lights.

On should wonder: Why can't all these vendors just settle on some uniform inplementation and interpretation of standards? 🤔

@ggravlingen
Copy link
Copy Markdown
Contributor

@NovapaX @lwis when I poked around with colors in pytradfri, I noticed that that it seems you set hex values in the app. The gateway then sets the correct color of the bulb and converts hex->xy. Ideal would be to send hex from Home Assistant. Unfortunately, the gateway only accepts a predefined list of hex colors. I guess we could replicate this in Home Assistant (only a predefined set of colors), even though I suspect that users would not appreciate that.

The transformation mentioned by @NovapaX involves linear algebra and transformation matrices (https://github.com/home-assistant/home-assistant/blob/8742ce035a36b3a4a176123b620fe82e55d5a4e2/homeassistant/util/color.py#L201) and given that they are rounded floats, I suspect that they will contribute to the behaviour we see in Home Assistant.

@NovapaX
Copy link
Copy Markdown
Contributor

NovapaX commented Mar 24, 2018

Can I make a unique_id PR against this branch?

@NovapaX
Copy link
Copy Markdown
Contributor

NovapaX commented Mar 24, 2018

@lwis I just created a PR (#13439) against this branch to add unique_id's and support for color temperature on color bulbs. I think if you approve we can just merge it into this one and make it easy for other to test some more.
Would be nice if we could get this into the next release cycle.

@MartinHjelmare
Copy link
Copy Markdown
Member

Please don't add more features to this PR.

@NovapaX
Copy link
Copy Markdown
Contributor

NovapaX commented Mar 25, 2018

Ok. I’ll rebase and re-PR when this is merged. 👍
This PR on itself looks almost good to me.
Edit: oh it’s fine. I had a little remark to the code but that’s not from this pull request.
I can confirm this works for white spectrum and color bulbs, without a change to configuration or re-pairing with the gateway.

@lwis
Copy link
Copy Markdown
Member Author

lwis commented Mar 28, 2018

Any objections to this being merged?

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

LGTM!

@balloob balloob merged commit b3b7cf3 into dev Mar 28, 2018
@balloob balloob deleted the update_tradfri_5 branch March 28, 2018 22:50
@ggravlingen
Copy link
Copy Markdown
Contributor

Any chance of cherry picking this into the 0.66 beta?

@NovapaX
Copy link
Copy Markdown
Contributor

NovapaX commented Mar 29, 2018

Why? Current implementation is not badly broken right?
Okay: we would trade two flaws. Currently color setting on an colorbulb is a bit broken. In this PR setting color_temp on an colorbulb is not possible.
Or am I missing something?

@lwis
Copy link
Copy Markdown
Member Author

lwis commented Mar 29, 2018

I think we should wait, given that we're half way (?) through the beta phase.

@ggravlingen
Copy link
Copy Markdown
Contributor

No, you’re right, let's wait.

@balloob
Copy link
Copy Markdown
Member

balloob commented Mar 30, 2018

During the beta phase we should only cherry pick bug fixes. New features will have to wait.

@balloob balloob mentioned this pull request Apr 13, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 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.

9 participants