Correct way to set the light color using the 'rgb_color' attribute

I wanted to inquire about the rgb_color attribute available in the light component. In the docs it says

A list containing three integers between 0 and 255 representing the RGB color you want the light to be. ..."

However, in reality the numbers need to be between 0 and 100. This seems to be a recent modification as previously 0 - 255 worked perfectly.

The biggest problem, as far as I see, is that internally HA still stores rgb values between 0-255. So for instance when I get the current state using “state_attr(‘light.my_light’, ‘rgb_color’)” I get a list of values between 0-255, but when I need to set the same state, I need to convert it to 0-100.

So does anyone have any idea as to which is/will be the standard? Is it a bug and rgb_color will be reverted to the range of 0-255 or do the docs need to be updated and 0-100 is the new standard?

Ps. I have a script that randomly generates rgb values for my light. It’s more like a random walk around the color wheel, so the color change is not too jarring. Anyway in case anyone wishes to know how I did it, I’d be happy to share that later in this post.

Which type of light do you have that is using 0-100?

All mine still use 0-255 for RGB values.

So I just solved my issue. Yes, you’re right, nothing has changed. The ‘rgb_color’ attribute is still using 0-255 range.

However, when you set for instance [0, 50 ,100], that is not what the lights get set to. Internally, HA converts this so that the largest value is mapped to 255. So [0, 50, 100] would yield the color [0, 123, 255]
And [0, 1000, 1000] would yield [0, 255, 255].

My guess is that since actual rgb [100, 100, 100] is essentially a dim white/grey, and there is already a ‘brightness’ attribute to control the dim settings of lights, HA sets rgb_color to the brightest version of the color we chose - basically maintaining the original ratio of red, green and blue values. And if we want a dimmer version of this color, we need to set the ‘brightness’ attribute separately.

So yeah, in case that helps anyone who also gets confused like me with the rgb_color behavior…

I also tried setting negative values, which also worked. Although I don’t remember the exact behavior, but I believe the most negative number will get mapped to 0…

In my case, I want to set random colors of my light by walking randomly along the color wheel. So I get gradual random color changes. And so instead of using ‘rgb_color’, I will use the ‘xy_color’ attribute. As HA will not change those values before setting them to my light.

You are the first person to make this claim. I’ve never seen anyone else state they had to supply boosted RGB values because Home Assistant was reducing them.

Which version of Home Assistant are you using and which integration is used for your colored lights?

I’m using Hassio’s latest version [0.102.3].

I have Gledopto’s zigbee light. I have paired it with Smartthings. And Smartthings is paired with Home Assistant. I think it’s my light integration that is causing this problem.

Once I paired the Gledopto light to Smartthings, in the Smartthings IDE I had to chose the device option so that Smartthings is able to communicate with it. Both ‘ZLL RGBW Bulb’ and ‘Zigbee RGBW Bulb’ work and I can set the light color and brighness. And when I set the color through Home Assistant UI using the color wheel, it works fine. However setting color from the script or setting causes some problems…

However, based on your response, maybe the problem could be on the Smartthings side instead of Home Assistant…

Ps. My zigbee stick hasn’t arrived yet, after which I’ll just pair the lights directly to HA and bypass Smartthings altogether, so this problem won’t persist hopefully.