Use a RGBW light as a light with color temperature control

TLDR
Use a RGBW light as a light with color temperature control.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

The theory: An RGBW light can also be used to shift the white light in the color spectrum.
With CT lights, the color spectrum can only be shifted in a pretty narrow spectrum. RGBW lights allow color temperatures from 1900 to 10000 kelvin. For a wide range of CT (color temperature) the use of RGBW lights allow high brightness and a very good CRI. (see color rendition index). The CRI of white LEDs used in the RGBW light should be above 90 to get natural colors of the illuminated objects. The CRI of a white produced by RGB is below 70, which looks really bad. Strong reds, orange tones and dark blue colors can get really funky.

I use this concept for many years, so far my homebrew SW ran on ESP8266 controllers. With the switch to esphome a new control is necessary, so far esphome can not control RGBW lights with color temperature.

With this template any RGWB light can be converted to a color temperature controlled light. As soon as the setpoint changes, the color temperature is adjusted without changing the brightness.

Calibration
Before an RGBW can be controlled with CT, it must be calibrated. Every light is different, even if it says the same thing.
I have made many attempts to calibrate automatically with RGB sensors. They have all failed. Pink turned green, orange turned turquoise, the whole spectrum. This is probably because the wavelengths of the LEDs do not match the wavelengths of the sensors. If you don’t have a full blown spectrometer there is only one possibility. Trust your eyes. In the end the light has to please your eyes, if it’s not perfect on scale, so what.
Calibration takes some time, but I have added sample data for a starting point.

Recommended calibration:
I use five calibration points. More could be overkill, however using only three limits the available CT spectrum or leads to interesting colors.
For calibration, I created another blueprint. With this you can easily adjust the values until you are satisfied.
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled. (Calibration helper)

  1. If you want to calibrate on five color temperatures, you start with the middle value. This is the native white of the white LED, all other RGB values are 0, the temperature of the light should be known.
  2. The second value is the value towards blue. Here you look for a known reference source like the white of a monitor, which usually has a color temperature of 6500 kelvin. Check for your model. Now set white to about 70% and add blue and green until the colors are very similar.
  3. The next point is extreme blue light like at blue hour with about 10000 kelvin. Set blue to 100 and reduce white so that only a small part is visible but still has an effect. Then green to taste. Don’t trust any sensor, only your eyes.
  4. Now the calibrations towards red are missing. A halogen lamp has a nice color and can be used as a reference if available. If your white is already a warm white, then move it with 100% red in the direction of warm. Reduce white a bit, add green to taste.
  5. The last point is extreme warm light. Here most of the brightness can no longer be achieved, but looks nice and who wants a super bright extremely warm light? For red 100% white with about 30% almost off. Green as it pleases, I take 50%.

Copy the obtained values into the blueprint for RGBW to CT.
All channels R,G,B,W must have the same number of values!
The blueprint has an optional MQTT topic. Debugging blueprints is hell. In some cases the cause can be found here.

This is how my calibration looks like:

Let there be light!

If something goes wrong:

  • In the developement homeassitant did not like me sometimes with automations staying in oblivion. Delete the automation from frontend and start over. Sometimes this does not help, then open automation.yaml (or wherever you store your automations) delete this automation (probably the last one) and reload automation.
    .

Versions:

  • 2022-01-1 Initial release.

More theory:


source: Wikipedia
If you take two white lights at very large distance fading from one to another will lead to pink colors. More on the topic here (German language) (not affiliated or whatever)
The blueprint uses mred internally, an inverse of CT in kelvin. This is way more linear on the usable and visible range.

6 Likes

Hey, thank you for the nice tutorial (even when I am using Fibaro Home Automation).
To be honest I was to lacy to do any kind of calibration, I just took your values and I am fine with them :smiley:

Thanks for the feedback.
I also find myself to tweak values on an active light into a direction I like. After the initial calibration of course :wink:

Hello @swifty1101

I’m having an issue that I hope you can help with. Any suggestions on the error below?

2022-07-28 23:48:13 DEBUG (MainThread) [homeassistant.components.automation.use_rgbw_as_ct_light] Automation triggered
2022-07-28 23:48:13 ERROR (MainThread) [homeassistant.components.automation.use_rgbw_as_ct_light] Error rendering variables: AttributeError: 'list' object has no attribute 'lower'

hi,
hard to tell, could you share your relevant automation as yaml? it is in the automation.yaml, you can find it by the name.

Hi @swifty1101

automations.yaml

- id: '1658928595792'
  alias: Use RGBW as CT Light
  description: ''
  use_blueprint:
    path: swifty99/RGBW2CTLight.yaml
    input:
      rgbw_2_ct_target_ct:
      - 2000
      - 2700
      - 3500
      - 4000
      - 6500
      rgbw_2_white_calibration:
      - 20
      - 60
      - 100
      - 100
      - 70
      rgbw_2_ct_requested_input: input_number.colour_temperature
      target_light:
        entity_id:
        - light.living_room_downlight_rear_left
      rgbw_2_blue_calibration:
      - 0
      - 0
      - 0
      - 0
      - 5
      rgbw_2_green_calibration:
      - 60
      - 60
      - 70
      - 0
      - 10
      rgbw_2_red_calibration:
      - 100
      - 100
      - 100
      - 0
      - 0

And attributes for the light. Note that this is physically a RBGW light, and I can send RGBW service commands, that work.

min_mireds: 153
max_mireds: 370
effect_list:
  - colorloop
supported_color_modes:
  - color_temp
  - xy
color_mode: color_temp
brightness: 129
hs_color:
  - 28.391
  - 65.659
rgb_color:
  - 255
  - 166
  - 87
xy_color:
  - 0.526
  - 0.387
off_with_transition: false
off_brightness: null
friendly_name: Living Room Downlight Rear Right
supported_features: 44
color_temp: 370

Hi,
the automation looks good so far. Debugging blueprints is outright ugly, so no guarantee I can help.
For me the light entity looks suspicious.
my RGBW light in the develper tools → states looks like this:

supported_color_modes: rgbw
color_mode: rgbw
brightness: 0
hs_color: 22.326, 19.283
rgb_color: 223, 196, 180
rgbw_color: 54, 21, 0, 223
xy_color: 0.373, 0.345
friendly_name: a_name
supported_features: 40

yours does not seem to support rgbw mode. I do not know what happens if you send RGBW commands to a light, that you state is a RGBW light, however does not state it in supported color modes.
My assuption would be, that your light is a color temp light, which somehow accepts RGBW commands.
As your light accepts color temp right away, why not use it directly?

cheers
Jan

@swifty1101 sorry for the late reply. If not an RGBW light, it definitely is an RGB - I can change it to all colours of the rainbow. The reason I don’t use it as a colour temp light is because of the limit on mireds being 370.

Hi, RGB lights are not supported and probably never will.
The “white” produced by RGB has serverely low CRI. The color of illuminated thing will be somewhat random. Therefore this blueprint is for RGBW only, hence the name.

Hi.
I have tried to use your blueprint but when i make an automation it is not showing up in my list of automations.
I have several times tried to delete the automation from the automation.yaml and made a new one without any luck.
The part in my automation.yaml look like this:

- id: '1672241584778'
  alias: Use RGBW as CT Light
  description: ''
  use_blueprint:
    path: swifty99/RGBW2CTLight.yaml
    input:
      rgbw_2_ct_requested_input: '2500'
      target_light:
        entity_id: light.shellyrgbw2_4bb960

Any suggestions what going wrong?

Hi there,
blueprints are a horror to debug. On first sight, I do not now if fixed color temperatures (here ‘2500’) are supported. my only difference is this:
rgbw_2_ct_requested_input: input_number.ct_myspaceship

So, would you try to create an input_number helper which carries the CT (here 2500)? This blueprint is also quite useless without a CT to follow.

hi - so i’m really interested in using this to try and control colour temperature on some WLEDs. i have set it up so i have a ‘live’ colour temperature value in the colour temperature target, and one WLED light as the one i’m trying to manipulate. the automation doesn’t run however. any clues as to what i’m doing wrong?

first to check: Are you sure to have RGBW lights? Most WLED strips use RGB. No way to use RGB for that.
Next for this to work, Home Assistant needs to find a light with RGBW feature. Check in the states developer tools tab.

supported_color_modes: rgbw

has to be available for the light to use.
There might be other ways, however this blueprint is made for rgbw lights only and that will not change.

good shout… the lights in question have this:

supported_color_modes: color_temp, rgbw

The blueprint should be possible here. However quite a bit useless, as the light supports color temperature right away. You should have a color temperature slider in the UI and accessible with automations. Why do you want to use the blueprint?

Nice work @swifty1101,

I work on something similar and will reference you where I take inspiration from you! :slight_smile: