TLDR
Use a RGBW light as a light with color temperature control.
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.
(Calibration helper)
- 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.
- 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.
- 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.
- 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.
- 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.