Set light by time of day continuously. The color temperature and brightness are in a gradient across the day. Trigger when switched on or every 15 seconds while on. The start of the day is always at full bright blue toned white (6400K). The color temperature is softened till a fixed value at noon. From noon till the end of day color temperature is softened and the brightness lessened ending in a nightlight (2200K) or your minimum brightness.
The triggering while the light is already on, can be disabled between set hours. The suspension switch must be set for this.
- Every minute of the day has its own color and brightness
- Select when your day starts and end
- Disable withing selected time scale
- Select minimum brightness
blueprint:
name: Continuous Light by time of day (Gradient)
description:
Set light by time of day continuously. The color temperature and brightness are in a gradient across the day.
Trigger when switched on or every 15 seconds while on. The start of the day is always at full
bright blue toned white ( 6400 K). The color temperature is softened till a fixed value at noon.
From noon till the end of day color temperature is softened and the brightness lessened ending in
a nightlight ( 2200 K) or your minimum brightness.
The triggering while the light is already on, can be disabled between set hours. The suspension switch
must be set for this.
domain: automation
input:
light_entity:
name: Light entity
description: The light to control. Color temperature range is auto-detected.
selector:
entity:
domain: light
night_disable:
name: Suspend
description: Suspend continuous trigger between selected times
default: false
selector:
boolean:
start_disable:
name: Start disable time
description: Start time to disable continuous trigger
default: "17:00:00"
selector:
time:
end_disable:
name: End disable time
description: End time to disable continuous trigger
default: "01:00:00"
selector:
time:
minimum_brightness:
name: Minimum brightness
description: The brightness minimum. Some lights ignore very low values
and may turn on with full brightness instead!
default: 1
selector:
number:
min: 1.0
max: 255.0
step: 1.0
mode: slider
start_of_day:
name: Start of day
description: Moment in the morning the day starts (must be before noon)
default: "07:30:00"
selector:
time:
end_of_day:
name: End of day
description: Moment in the evening the day ends
default: "23:00:00"
selector:
time:
variables:
start_of_day: !input "start_of_day"
end_of_day: !input "end_of_day"
minimum_brightness: !input "minimum_brightness"
night_disable: !input "night_disable"
light_entity: !input "light_entity"
start_disable: !input "start_disable"
end_disable: !input "end_disable"
minutes_before_noon: "{{[(as_timestamp(today_at('12:00')) - as_timestamp(today_at(start_of_day)))/60, 0]|max|int}}"
minutes_after_noon: "{{[(as_timestamp(today_at(end_of_day)) - as_timestamp(today_at('12:00')))/60, 0]|max|int}}"
minutes_elasped_since_start: "{{[(as_timestamp(now()) - as_timestamp(today_at(start_of_day)))/60, 0]|max|int}}"
minutes_elasped_since_noon: "{{[(as_timestamp(now()) - as_timestamp(today_at('12:00')))/60, 0]|max|int}}"
color_temp_calc: >
{% if now() < today_at(start_of_day) %}
454
{% elif today_at(start_of_day) < now() <= today_at('12:00') %}
{{156 + ((minutes_elasped_since_start / minutes_before_noon) * 119)|int}}
{% elif today_at('12:00') < now() <= today_at(end_of_day) %}
{{275 + ((minutes_elasped_since_noon / minutes_after_noon) * 179)|int}}
{% else %}
454
{% endif %}
brightness_calc: >
{% if now() < today_at(start_of_day) %}
{{[1, minimum_brightness]|max}}
{% elif today_at(start_of_day) < now() <= today_at('12:00') %}
255
{% elif today_at('12:00') < now() <= today_at(end_of_day) %}
{{[255 - ((minutes_elasped_since_noon / minutes_after_noon) * 254), minimum_brightness]|max|int}}
{% else %}
{{[1, minimum_brightness]|max}}
{% endif %}
trigger:
- platform: time_pattern
seconds: "/15"
- platform: state
entity_id: !input "light_entity"
from: "off"
to: "on"
condition:
- condition: and
conditions:
- condition: state
entity_id: !input "light_entity"
state: "on"
- condition: or
conditions:
- condition: not
conditions:
- condition: template
value_template: "{{not night_disable}}"
- condition: time
after: !input "start_disable"
before: !input "end_disable"
- condition: template
value_template: "{{not night_disable}}"
action:
- service: light.turn_on
data:
brightness: "{{brightness_calc}}"
color_temp: "{{color_temp_calc}}"
transition: 5
entity_id: !input "light_entity"
mode: restart
max_exceeded: silent