DIY Circadian Lighting. no flux and no custom components

You’re welcome. I recall the discussion but I’m surprised that you chose to create Template Sensors that use a long-winded if-else structure. In the original discussion, the suggestion was to use a list (to store the times and values) thereby making the template more compact. For example, here are the Circadian Brightness and Color Temperature sensors:

      cl_brightness:
        friendly_name: 'Circadian Brightness'
        value_template: >
          {% set hours = [[0,1],[500,25],[600,85],[630,105],[700,125],[730,190],
                          [800,210],[900,255],[1630,255],[1700,240],[1730,235],
                          [1800,225],[1830,200],[1900,175],[1930,125],[2000,115],
                          [2030,110],[2100,100],[2200,85],[2230,25],[2300,1]] %}
          {% set t = states('sensor.time').replace(':','')|int %}
          {% set ns = namespace(level = 0) %}
          {% for h in hours if t >= h[0] %}
            {% set ns.level = h[1] %}
          {% endfor %}
          {{ ns.level }}

      cl_color_temp:
        friendly_name: 'Circadian Color Temperature'
        value_template: >
          {% set hours = [[0,1],[500,500],[600,450],[630,400],[700,350],[730,350],
                          [800,325],[900,300],[1630,350],[1700,360],[1730,370],
                          [1800,375],[1830,400],[1900,425],[1930,450],[2000,465],
                          [2030,475],[2100,500],[2200,500],[2230,500],[2300,500]] %}
          {% set t = states('sensor.time').replace(':','')|int %}
          {% set ns = namespace(level = 0) %}
          {% for h in hours if t >= h[0] %}
            {% set ns.level = h[1] %}
          {% endfor %}
          {{ ns.level }}

Anyway, it’s your choice.

BTW, in your Circadian Color Temperature sensor, the final else provides this [255, 125, 0] for color_temp instead of an integer value.

Service data attribute Optional Description
color_temp yes An integer in mireds representing the color temperature you want the light to be.
1 Like