Skip to content

Use hue/sat as internal light color interface#11288

Merged
balloob merged 20 commits intodevfrom
light-api-color-compatibility
Mar 18, 2018
Merged

Use hue/sat as internal light color interface#11288
balloob merged 20 commits intodevfrom
light-api-color-compatibility

Conversation

@emlove
Copy link
Copy Markdown
Contributor

@emlove emlove commented Dec 24, 2017

Description:

This PR converts hass to use hue/sat as the core interface for colors. Platforms will only receive turn_on calls with hue/sat, and only need to report their entity colors in hue/sat. The light component will convert incoming service calls in other formats to hue/sat, and will make the entity colors in hue/sat from the platforms available to clients in RGB and XY form as well.

The use-case I have in mind is that I've been digging into the ZHA platform, and it natively prefers to work with XY colors instead of RGB. I think it's best if we just let the light component do the translation, so that platforms don't need to worry about supporting multiple formats, and can implement their preferred method. Doing the conversion in one place should also help give consistent behavior on how brightness is handled.

Copy link
Copy Markdown
Member

@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

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

I think you should merge this into preprocess_turn_on_alternatives. This function is for handling stuff like this.

I like this.

@emlove
Copy link
Copy Markdown
Contributor Author

emlove commented Dec 24, 2017

That's what I was thinking, but preprocess_turn_on_alternatives runs once for the service call, and isn't aware of the entities capabilities.

Another alternative would be to always transform color requests to XY in preprocess_turn_on_alternatives before sending them to the platforms. RGB only platforms would still have to convert incoming requests, but at least then platforms wouldn't have to worry about supporting multiple color request types.

@ggravlingen ggravlingen mentioned this pull request Dec 24, 2017
@pvizeli
Copy link
Copy Markdown
Member

pvizeli commented Dec 24, 2017

The best would be, that home-assistant support only one color schema and all other need be converted. That what we have currently is bad by design. Anyway, I think we should convert it in any case like the others does.

@emlove
Copy link
Copy Markdown
Contributor Author

emlove commented Dec 24, 2017

👍 I think in an ideal world we'd only support XY color, since RGB has the confusing overlap with brightness. Unfortunately I don't think we can get away from RGB in the API since it's so ubiquitously understood, but we can at least limit the complexity of what is sent to platforms.

if ATTR_RGB_COLOR in params and \
entity.supported_features & SUPPORT_XY_COLOR and not \
entity.supported_features & SUPPORT_RGB_COLOR:
rgb = params.pop(ATTR_RGB_COLOR)
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.

You should make a copy before mutating

@emlove emlove changed the title Accept and report both xy and RGB color for lights [WIP] Accept and report both xy and RGB color for lights Dec 25, 2017
@amelchio
Copy link
Copy Markdown
Contributor

I will just remind that you advised against doing this in my old PR #6727 (comment)

I am not saying that this should exclude you from doing the change now, it is certainly acceptable to change your mind. However, I wonder whether your new use-case is perhaps blinding you from seeing the larger picture that you identified in my PR.

@emlove
Copy link
Copy Markdown
Contributor Author

emlove commented Dec 30, 2017

😆 Thanks for bringing that up! Those notes are some good context.

I think I've come to a better solution here thanks to this feedback, that hopefully keeps complexity limited.

@balloob
Copy link
Copy Markdown
Member

balloob commented Mar 18, 2018

I agree with @armills . The concerns by @amelchio are good but let's fix those in another PR. As is we're having a good foundation to build upon.

@balloob balloob merged commit 89c7c80 into dev Mar 18, 2018
@emlove emlove deleted the light-api-color-compatibility branch March 18, 2018 23:16
Copy link
Copy Markdown
Member

@OttoWinter OttoWinter left a comment

Choose a reason for hiding this comment

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

Light groups and all the MQTT platforms look good 👍

OttoWinter added a commit to esphome/esphome-core that referenced this pull request Mar 20, 2018
See home-assistant/core#11288; it doesn't do aynthing anymore
OttoWinter added a commit to esphome/esphome-core that referenced this pull request Mar 20, 2018
* Make device_class optional

* Improve WiFi debug logging

The arduino-esp32 project broke wifi ... again

* Remove erroneus assert

* Basic ESP8266 support

Mostly just disables lots of functionality for the ESP8266 that should eventually be re-implemented for this platform.

* Fix merge

* Fixes

* A bunch of changes

Couldn't be bothered to split them up in different PRs, sorry :/

* Remove Light XY support

See home-assistant/core#11288; it doesn't do aynthing anymore

* Masive Refactor

* Another huge refactor
@MartinHjelmare MartinHjelmare mentioned this pull request Mar 21, 2018
2 tasks
@amelchio amelchio mentioned this pull request Mar 24, 2018
2 tasks
@balloob balloob mentioned this pull request Mar 30, 2018
@moskovskiy82
Copy link
Copy Markdown

moskovskiy82 commented Mar 31, 2018

Is this the reason MQTT RGB broke up?

https://community.home-assistant.io/t/0-66-rgb-mqtt/48871

@armills @balloob can you help identify the root cause?

@jamesw4
Copy link
Copy Markdown

jamesw4 commented Apr 1, 2018

I think this might be related to my issue with tradfri bulbs paired with hue hub? #13614

@Arkadyf
Copy link
Copy Markdown

Arkadyf commented Apr 26, 2018

Since change 89c7c80 (on Mar 18) to tplink.py, my TP-Link lights stopped supporting color. Color used to work in HA (on the UI or by setting color using commands) before that change, and the lights support color when using the Kasa app.
Since the change (89c7c80), changing lights only adjusts the brightness. Color selector appears in the HA UI, but it only affects brightness. Same API calls / automations / Node-red. I tried the "rgb_color" and the "color_name" to try to set the color. Both worked before.
Color still works in the Kasa app.

I'm new to this, so I don't know what other info I could provide to troubleshoot this.

@amelchio
Copy link
Copy Markdown
Contributor

@Arkadyf No more information is needed but please create a separate GitHub issue. You can add a note that the problem probably is due to us no longer casting hsv to integers.

@home-assistant home-assistant locked as resolved and limited conversation to collaborators Apr 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.