Get correct color temperature from CCT LED-Controller

Hey guys,

I just wanted to get the most out of circadian lighting so I installed some Gledopto GL-C-006P CCT LED-Controller together with 2200K-4000K WW/CW LED-Strips in my kitchen.

Here’s my Problem: If I look at the Gledopto’s State attributes it reads min_mireds 158 (6300K) and max_mireds 495 (2000K).
While the attached lightstrip is only 2200K min and 4000K max I can’t pair them with e.g. hue bulbs (2200K-6500K) because the temperature is way off.

At 166 mireds (6000K) set with light.turn_on the hue bulbs are at exact that value but the lightstrip doesn’t even hit it’s max of 4000K because the lowest value on the controller is 158.

Then I thought I could simply customize the controller entity so that min_mireds is 254 (4000K) and max_mireds is 454 (2200K). The customization works but then with light.turn_on set to 254 the controller doesn’t translate that to “go to the maximum on the colder end” and instead sets itself to what it’s told: 254.
So I have the same issue like before but am unable to get to the ends of the controller’s spectrum.

I hope it’s not too confusing to understand and hopefully someone can help me how to tell the controller that full brightness on the cw-channel represents 4000K and full brightness on the ww-channel is 2200K.

Regards
Stephan

Stephan,
I ran into this same problem. I had to write a script that computed the correct (closest) setting for the strip. Then instead of calling light.turn_on with that temperature, I have to call the script. I solved this by having a script that sets the color temperature for all lights except lights that end in “_no_ct”. Those ones get handled differently, and, in the case of my GL-C-006P, the script does the computation and sets the appropriate temperature.

Here’s the core of the script I used:

    - service: light.turn_on
      data:
        entity_id: light.living_room_white_led_strip_no_ct
        color_temp: >
          {% set req=states('input_select.global_color_temp_k')|int %}
          {% set min_req=2700 %}
          {% set max_req=4000 %}   
          {% set min_needed=2020 %}
          {% set max_needed=2995 %}
          {% set per_K = (max_needed-min_needed)/(max_req-min_req) %}
          {% set scaled = (req-min_req)*per_K+min_needed %}
          {{(1000000/scaled)|int}}
        transition: 10

Hi David,

thanks for your help, I really appreciate that! Could you explain to me, how exactly the core of your script works? I can’t figure that out.

And would it be possible to create a dummy-light with Template Light that has the range from 2200-4000K and triggers the original light with computed values?

That would be helpful, because I could use that dummy in adaptive lighting custom component.

If you mean the script above (as opposed to the main script that sets the color temperature for all lights) it works as follows:

{% set req=states('input_select.global_color_temp_k')|int %}

This makes a variable called req that is equal to an input_select (a pop-up menu in the GUI) called “global_color_temp_k” converted to an integer “|int”. This variable is used later in the computation.

The next four lines set some variables. The idea is to do a linear scaling between the input range and the output range with an offset (min_needed) for the minimum value. This is a mess because I tried to do it based on first principles, but the calibration is wrong so I had to address min_needed and max_needed to make the ranges look good.

The sixth line is computing a scale factor “per_K”
The seventh line is applying the scale factor and the offset to the input value “req” to get the final Kelvin value “scaled”.
The last line:

{{(1000000/scaled)|int}}

Is returning the color temperature in mireds. (I wrote this script before HA supported Kelvin directly.

I’m sorry that’s not very clean. To use the formula you put in the min/max values for min_req and max_req from your strip and then you adjust the min_needed and max_needed so the colors look right. (Or at least that’s what I did. :slight_smile:

-David

1 Like