Add color modes for light entities #519
-
SuggestionAdd attribute
|
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 23 replies
-
I honestly think we should add For example, This would not only solve the above problem, we can also stop calculating everything from Home Assistants general color format ( I've been playing/thinking about this a couple of times now, since I have the same issue with WLED. WLED can support multiple types of LED strips, which Home Assistant can't support at this point. And resulting in these horrible constructs right now: |
Beta Was this translation helpful? Give feedback.
-
As per comment above by @emontnemery: color_mode is added to light in home-assistant/core#47720 |
Beta Was this translation helpful? Give feedback.
-
I'm not sure if I should add a new topic or just comment on this one. Why is the brightness information removed from RGB? I'm asking because in RGB mode the front end offers a color selector and brightness slider. If the slider is moved it sends the change in brightness which can then be used by the integration to adjust the light. If an RGB is selected then it sends the normalized RGB data. The integration can use that in conjunction with the current brightness to set the light correctly. Everything is fine but, this is where things get weird. At least to me. The integration can send back brightness and it will show correctly on the slider. The integration can also send back a non-normalized RGB which will change the slider on the brightness (I didn't test to see if its' correct but, I think it is. I'll double check next time I'm testing). If you send BOTH the brightness and the non-normalized RGB it will move the slider to what I'm assuming is the brightness of the RGB scaled further down by the brightness level. It seems like it would be better for the RGB to send a non-normalized and receive a non-normalized. Or, when a non-normalized RGB is sent from the integration convert it into a normalized RGB and depend on the brightness to dictate the slider lever. As a side note, what is the purpose of having "supported color modes" and "color modes" The light can only be in one color mode so what is the need for the list? Also, if its RGBWW then it can be assumed that it can handle COLOR_TEMP, COLOR_RGB, COLOR_RGBW, and COLOR_RGBWW. It's all inherited unless I'm looking at it from the wrong point of view. |
Beta Was this translation helpful? Give feedback.
-
Home Assistant itself can both send and receive non-normalized colors. However, when color is changed from the frontend it will always send a normalized color.
The purposes are:
|
Beta Was this translation helpful? Give feedback.
-
We need to separate between what the frontend sends (normalized RGB) and how the light entity should interpret the colors (non normalized RGB).
Which table do you refer to?
Unlike RGB, HS and XY pairs don't hold any brightness information, it's just a color. Hence, this is not possible.
Right, this is why RGB is combined with a master brightness.
What's DEV, are you referring to the frontend? It's a bit hard to follow exactly what your concern is, can you give some concrete examples on how you propose that it should work instead, for example a sequence of user actions, service calls, state updates and UI updates? |
Beta Was this translation helpful? Give feedback.
-
OK, now I get it, thanks for the patience. What we try to convey is that the hs and xy representations of the RGB color do not have the full information of the RGB tuple. As an example, RGB = (255,0,0) and RGB = (1,0,0) will both be represented as hs = (0,100). Can you suggest a clearer way to explain it? Maybe something like:
I'm still unsure what you mean when you say:
Is your concern that the frontend will always send normalized RGB values, for example, if the light is currently in state: `{"brightness": 100, "rgb_color": (128,0,0)}" |
Beta Was this translation helpful? Give feedback.
-
This is absolutely not the case, if color_mode is rgb, the brightness information of the RGB tuple is retained. Please note that in color modes rgb, rgbw and rgbww the state is define by the color tuple AND the brightness. In the RGB example:
Why do you say the data sent to integration is normalized? The user change (255,30,0) is already at full brightness so the value before and after normalization would be the same. In the RGBW example:
This looks very strange, can you double check please, you're mixing "rgb_color" and "rgbw_color"? Also, let me ask again: Are you talking about the behavior of the frontend (the Web UI) or are you talking about service calls? |
Beta Was this translation helpful? Give feedback.
-
@icemanch what @emontnemery means is: Try to do the same test using a service call and not from the frontend: |
Beta Was this translation helpful? Give feedback.
-
Thanks @thecode 👍 @icemanch It was really helpful with the screenshots, thanks again for your patience. I think I understand the problem now: You write:
At this point, what is the light's state? |
Beta Was this translation helpful? Give feedback.
-
No, it's precisely the opposite.
No, this is a misunderstanding on your side. The light's This is explained in the documentation:
PR on the documentation to make it clearer: home-assistant/developers.home-assistant#960 If your underlying light hardware does not support both setting an RGB color and a master brightness, you need to manage that in the integration. |
Beta Was this translation helpful? Give feedback.
-
Exactly, and this is why the frontend always sends a normalized color.
Yes, that's right!
I don't see the benefit of such a change, can you explain the use case? |
Beta Was this translation helpful? Give feedback.
As per comment above by @emontnemery:
color_mode is added to light in home-assistant/core#47720