Skip to content

Instantly share code, notes, and snippets.

@sbyx
Last active October 29, 2025 19:14
Show Gist options
  • Save sbyx/96c43b13b90ae1c35b872313ba1d2d2d to your computer and use it in GitHub Desktop.
Save sbyx/96c43b13b90ae1c35b872313ba1d2d2d to your computer and use it in GitHub Desktop.

Revisions

  1. sbyx revised this gist Nov 8, 2021. 1 changed file with 17 additions and 14 deletions.
    31 changes: 17 additions & 14 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -102,22 +102,22 @@ variables:
    seconds: '{{float(sunrise_duration) * 60}}'
    min_mired: !input 'min_mired'
    start_mired: '{{state_attr(light_entity, ''max_mireds'')}}'
    end_mired: '{{[state_attr(light_entity, ''min_mireds'')|int, min_mired|int]|max}}'
    end_mired: '{{[state_attr(light_entity, ''min_mireds'')|int(0), min_mired|int(0)]|max}}'
    tick_time: '{{float(seconds) / float(range_brightness)}}'
    check_entity: !input 'check_entity'
    trigger:
    - platform: time_pattern
    minutes: '*'
    condition: []
    action:
    - wait_template: '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    - wait_template: '{{sensor == ''none'' or as_timestamp(states(sensor), None) != None}}'
    - wait_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) <= float(seconds)
    and states(check_entity) in [''unknown'', ''on'', ''home'']}}'
    - choose: []
    default: !input 'pre_sunrise_actions'
    - condition: template
    value_template: '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    value_template: '{{sensor == ''none'' or as_timestamp(states(sensor), None) != None}}'
    - condition: template
    value_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now()) <= float(seconds) and states(check_entity)
    @@ -138,17 +138,18 @@ action:
    entity_id: !input 'light_entity'
    - repeat:
    while:
    - '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    - '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else
    states(''sensor.date'') ~ '' '' ~ manual_time) - as_timestamp(now()) <= float(seconds)}}'
    - '{{sensor == ''none'' or as_timestamp(states(sensor), None) != None}}'
    - '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now()) <= float(seconds)}}'
    sequence:
    - delay: '{{tick_time}}'
    - choose:
    - conditions:
    - '{{0 < state_attr(light_entity, ''brightness'') | int < end_brightness | int}}'
    - '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    - '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else
    states(''sensor.date'') ~ '' '' ~ manual_time) - as_timestamp(now()) <= float(seconds)}}'
    - '{{0 < state_attr(light_entity, ''brightness'') | int(0) < end_brightness |
    int}}'
    - '{{sensor == ''none'' or as_timestamp(states(sensor), None) != None}}'
    - '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now()) <= float(seconds)}}'
    sequence:
    - choose:
    - conditions:
    @@ -158,19 +159,21 @@ action:
    data:
    brightness: '{{(float(end_brightness) - (float(range_brightness) *
    (as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int}}'
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds)))
    | int(0)}}'
    color_temp: '{{(float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int}}'
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds)))
    | int(0)}}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness: '{{(float(end_brightness) - (float(range_brightness) * (as_timestamp(states(sensor)
    if sensor != ''none'' else states(''sensor.date'') ~ '' '' ~ manual_time)
    - as_timestamp(now())) / float(seconds))) | int}}'
    - as_timestamp(now())) / float(seconds))) | int(0)}}'
    entity_id: !input 'light_entity'
    - choose: []
    default: !input 'post_sunrise_actions'
    mode: single
    max_exceeded: silent
    max_exceeded: silent
  2. sbyx revised this gist Jan 13, 2021. 1 changed file with 93 additions and 119 deletions.
    212 changes: 93 additions & 119 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -1,46 +1,41 @@
    blueprint:
    name: Wake-up light alarm with sunrise effect
    description:
    "A wake-up light alarm with a brightness and color temperature sunrise
    effect. Note: Requires date_time_iso sensor in configuration, not manually executable!"
    description: 'A wake-up light alarm with a brightness and color temperature sunrise
    effect. Note: Requires date_time_iso sensor in configuration, not manually executable!'
    domain: automation
    input:
    light_entity:
    name: Wake-up light entity
    description:
    The light to control. Turning it off during the sunrise will keep
    description: The light to control. Turning it off during the sunrise will keep
    it off. Color temperature range is auto-detected.
    selector:
    entity:
    domain: light
    timestamp_sensor:
    name: Alarm timestamp sensor
    description:
    "Sensor with timestamp of next alarm with device_class: timestamp
    (set to 'none' for manual alarm time)"
    description: 'Sensor with timestamp of next alarm with device_class: timestamp
    (set to ''none'' for manual alarm time)'
    default: none
    selector:
    entity:
    device_class: timestamp
    manual_time:
    name: Manual alarm time
    description:
    Time to trigger alarm every day if timestamp sensor is not set.
    description: Time to trigger alarm every day if timestamp sensor is not set.
    Settings at or shortly after midnight will not work as expected!
    default: "7:00:00"
    default: '7:00:00'
    selector:
    time: {}
    check_entity:
    name: Additional entity to check before sunrise is triggered
    description: "If set, checks if entity is 'on' or 'home' before triggering.
    Use e.g. a (workday) sensor, device_tracker or person entity."
    description: If set, checks if entity is 'on' or 'home' before triggering. Use
    e.g. a (workday) sensor, device_tracker or person entity.
    default: none
    selector:
    entity:
    entity: {}
    sunrise_duration:
    name: Sunrise duration
    description:
    The sunrise will start the configured number of minutes before
    description: The sunrise will start the configured number of minutes before
    the timestamp.
    default: 25
    selector:
    @@ -52,9 +47,9 @@ blueprint:
    mode: slider
    start_brightness:
    name: Minimum brightness
    description: The brightness to start with. Some lights ignore very low
    values and may turn on with full brightness instead!
    default: 2
    description: The brightness to start with. Some lights ignore very low values
    and may turn on with full brightness instead!
    default: 1
    selector:
    number:
    min: 1.0
    @@ -63,19 +58,18 @@ blueprint:
    mode: slider
    end_brightness:
    name: Maximum brightness
    description:
    The brightness will be transitioned from the minimum to the configured
    description: The brightness will be transitioned from the minimum to the configured
    value.
    default: 255
    default: 254
    selector:
    number:
    min: 5.0
    max: 255.0
    step: 5.0
    step: 1.0
    mode: slider
    min_mired:
    name: Minimum color temperature
    description: "The minimum color temperature to use. (0: lowest supported)"
    description: 'The minimum color temperature to use. (0: lowest supported)'
    default: 0
    selector:
    number:
    @@ -86,117 +80,97 @@ blueprint:
    unit_of_measurement: mired
    pre_sunrise_actions:
    name: Pre-sunrise actions
    description:
    Optional actions to run before sunrise starts.
    description: Optional actions to run before sunrise starts.
    default: []
    selector:
    action: {}
    post_sunrise_actions:
    name: Post-sunrise actions
    description:
    Optional actions to run after sunrise ends (around the alarm time).
    description: Optional actions to run after sunrise ends (around the alarm time).
    default: []
    selector:
    action: {}
    source_url: https://gist.github.com/sbyx/96c43b13b90ae1c35b872313ba1d2d2d
    variables:
    light_entity: !input "light_entity"
    sensor: !input "timestamp_sensor"
    sunrise_duration: !input "sunrise_duration"
    start_brightness: !input "start_brightness"
    end_brightness: !input "end_brightness"
    range_brightness: "{{float(end_brightness)-float(start_brightness)}}"
    manual_time: !input "manual_time"
    seconds: "{{float(sunrise_duration) * 60}}"
    min_mired: !input "min_mired"
    start_mired: "{{state_attr(light_entity, 'max_mireds')}}"
    end_mired: "{{[state_attr(light_entity, 'min_mireds') | int, min_mired | int] | max}}"
    tick_time: "{{float(seconds) / float(range_brightness)}}"
    check_entity: !input "check_entity"
    light_entity: !input 'light_entity'
    sensor: !input 'timestamp_sensor'
    sunrise_duration: !input 'sunrise_duration'
    start_brightness: !input 'start_brightness'
    end_brightness: !input 'end_brightness'
    range_brightness: '{{float(end_brightness)-float(start_brightness)}}'
    manual_time: !input 'manual_time'
    seconds: '{{float(sunrise_duration) * 60}}'
    min_mired: !input 'min_mired'
    start_mired: '{{state_attr(light_entity, ''max_mireds'')}}'
    end_mired: '{{[state_attr(light_entity, ''min_mireds'')|int, min_mired|int]|max}}'
    tick_time: '{{float(seconds) / float(range_brightness)}}'
    check_entity: !input 'check_entity'
    trigger:
    - platform: time_pattern
    minutes: "*"
    - platform: time_pattern
    minutes: '*'
    condition: []
    action:
    - wait_template: "{{sensor == 'none' or as_timestamp(states(sensor)) != None}}"
    - wait_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) < float(seconds)
    and states(check_entity) in [''unknown'', ''on'', ''home'']}}'
    - choose: []
    default: !input "pre_sunrise_actions"
    - condition: template
    value_template: "{{sensor == 'none' or as_timestamp(states(sensor)) != None}}"
    - condition: template
    value_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now()) < float(seconds)
    and states(check_entity) in [''unknown'', ''on'', ''home'']}}'
    - choose:
    - wait_template: '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    - wait_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) <= float(seconds)
    and states(check_entity) in [''unknown'', ''on'', ''home'']}}'
    - choose: []
    default: !input 'pre_sunrise_actions'
    - condition: template
    value_template: '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    - condition: template
    value_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now()) <= float(seconds) and states(check_entity)
    in [''unknown'', ''on'', ''home'']}}'
    - choose:
    - conditions:
    - '{{state_attr(light_entity, ''min_mireds'') != None}}'
    sequence:
    - service: light.turn_on
    data:
    brightness: '{{start_brightness}}'
    color_temp: '{{start_mired}}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness: '{{start_brightness}}'
    entity_id: !input 'light_entity'
    - repeat:
    while:
    - '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    - '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else
    states(''sensor.date'') ~ '' '' ~ manual_time) - as_timestamp(now()) <= float(seconds)}}'
    sequence:
    - delay: '{{tick_time}}'
    - choose:
    - conditions:
    - condition: template
    value_template: "{{state_attr(light_entity, 'min_mireds') != None}}"
    - '{{0 < state_attr(light_entity, ''brightness'') | int < end_brightness | int}}'
    - '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    - '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else
    states(''sensor.date'') ~ '' '' ~ manual_time) - as_timestamp(now()) <= float(seconds)}}'
    sequence:
    - choose:
    - conditions:
    - '{{state_attr(light_entity, ''min_mireds'') != None}}'
    sequence:
    - service: light.turn_on
    data:
    brightness: '{{(float(end_brightness) - (float(range_brightness) *
    (as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int}}'
    color_temp: '{{(float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int}}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness: "{{start_brightness}}"
    color_temp: "{{start_mired}}"
    entity_id: !input "light_entity"
    default:
    - service: light.turn_on
    data:
    brightness: "{{start_brightness}}"
    entity_id: !input "light_entity"
    - repeat:
    while:
    - condition: template
    value_template: "{{sensor == 'none' or as_timestamp(states(sensor)) != None}}"
    - condition: template
    value_template:
    "{{0 < as_timestamp(states(sensor) if sensor != 'none' else
    states('sensor.date') ~ ' ' ~ manual_time) - as_timestamp(now()) < float(seconds)}}"
    sequence:
    - delay: "{{tick_time}}"
    - choose:
    - conditions:
    - condition: state
    entity_id: !input "light_entity"
    state: "on"
    - condition: template
    value_template:
    "{{sensor == 'none' or as_timestamp(states(sensor)) !=
    None}}"
    - condition: template
    value_template:
    "{{0 < as_timestamp(states(sensor) if sensor != 'none'
    else states('sensor.date') ~ ' ' ~ manual_time) - as_timestamp(now())
    < float(seconds)}}"
    sequence:
    - choose:
    - conditions:
    - condition: template
    value_template: "{{state_attr(light_entity, 'min_mireds') != None}}"
    sequence:
    - service: light.turn_on
    data:
    brightness:
    "{{(float(end_brightness) - (float(range_brightness) *
    (as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date')
    ~ ' ' ~ manual_time) - as_timestamp(now())) / float(seconds)))
    | int}}"
    color_temp:
    "{{(float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date')
    ~ ' ' ~ manual_time) - as_timestamp(now())) / float(seconds)))
    | int}}"
    entity_id: !input "light_entity"
    default:
    - service: light.turn_on
    data:
    brightness:
    "{{(float(end_brightness) - (float(range_brightness) * (as_timestamp(states(sensor)
    if sensor != 'none' else states('sensor.date') ~ ' ' ~ manual_time)
    - as_timestamp(now())) / float(seconds))) | int}}"
    entity_id: !input "light_entity"
    - choose: []
    default: !input "post_sunrise_actions"
    brightness: '{{(float(end_brightness) - (float(range_brightness) * (as_timestamp(states(sensor)
    if sensor != ''none'' else states(''sensor.date'') ~ '' '' ~ manual_time)
    - as_timestamp(now())) / float(seconds))) | int}}'
    entity_id: !input 'light_entity'
    - choose: []
    default: !input 'post_sunrise_actions'
    mode: single
    max_exceeded: silent
  3. sbyx revised this gist Jan 12, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -197,6 +197,6 @@ action:
    - as_timestamp(now())) / float(seconds))) | int}}"
    entity_id: !input "light_entity"
    - choose: []
    default: !input "pre_sunrise_actions"
    default: !input "post_sunrise_actions"
    mode: single
    max_exceeded: silent
  4. sbyx revised this gist Jan 12, 2021. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -91,6 +91,13 @@ blueprint:
    default: []
    selector:
    action: {}
    post_sunrise_actions:
    name: Post-sunrise actions
    description:
    Optional actions to run after sunrise ends (around the alarm time).
    default: []
    selector:
    action: {}
    source_url: https://gist.github.com/sbyx/96c43b13b90ae1c35b872313ba1d2d2d
    variables:
    light_entity: !input "light_entity"
    @@ -189,5 +196,7 @@ action:
    if sensor != 'none' else states('sensor.date') ~ ' ' ~ manual_time)
    - as_timestamp(now())) / float(seconds))) | int}}"
    entity_id: !input "light_entity"
    - choose: []
    default: !input "pre_sunrise_actions"
    mode: single
    max_exceeded: silent
  5. sbyx revised this gist Jan 10, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -32,8 +32,8 @@ blueprint:
    time: {}
    check_entity:
    name: Additional entity to check before sunrise is triggered
    description: "If set, checks if entity is 'on' or 'home' before triggering
    to use e.g. with (workday) sensor, device_tracker or person."
    description: "If set, checks if entity is 'on' or 'home' before triggering.
    Use e.g. a (workday) sensor, device_tracker or person entity."
    default: none
    selector:
    entity:
  6. sbyx revised this gist Jan 10, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -113,8 +113,8 @@ condition: []
    action:
    - wait_template: "{{sensor == 'none' or as_timestamp(states(sensor)) != None}}"
    - wait_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) < float(seconds)
    and states(check_entity) in [''unknown'', ''on'', ''home'']}}'
    ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) < float(seconds)
    and states(check_entity) in [''unknown'', ''on'', ''home'']}}'
    - choose: []
    default: !input "pre_sunrise_actions"
    - condition: template
  7. sbyx revised this gist Jan 10, 2021. 1 changed file with 15 additions and 8 deletions.
    23 changes: 15 additions & 8 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -30,6 +30,13 @@ blueprint:
    default: "7:00:00"
    selector:
    time: {}
    check_entity:
    name: Additional entity to check before sunrise is triggered
    description: "If set, checks if entity is 'on' or 'home' before triggering
    to use e.g. with (workday) sensor, device_tracker or person."
    default: none
    selector:
    entity:
    sunrise_duration:
    name: Sunrise duration
    description:
    @@ -80,8 +87,7 @@ blueprint:
    pre_sunrise_actions:
    name: Pre-sunrise actions
    description:
    Optional actions to run before sunrise starts. Wait-Actions may
    be used to define additional alarm conditions.
    Optional actions to run before sunrise starts.
    default: []
    selector:
    action: {}
    @@ -99,23 +105,24 @@ variables:
    start_mired: "{{state_attr(light_entity, 'max_mireds')}}"
    end_mired: "{{[state_attr(light_entity, 'min_mireds') | int, min_mired | int] | max}}"
    tick_time: "{{float(seconds) / float(range_brightness)}}"
    check_entity: !input "check_entity"
    trigger:
    - platform: time_pattern
    minutes: "*"
    condition: []
    action:
    - wait_template: "{{sensor == 'none' or as_timestamp(states(sensor)) != None}}"
    - wait_template:
    "{{0 < as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date')
    ~ ' ' ~ manual_time) - as_timestamp(states('sensor.date_time_iso')) < float(seconds)}}"
    - wait_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) < float(seconds)
    and states(check_entity) in [''unknown'', ''on'', ''home'']}}'
    - choose: []
    default: !input "pre_sunrise_actions"
    - condition: template
    value_template: "{{sensor == 'none' or as_timestamp(states(sensor)) != None}}"
    - condition: template
    value_template:
    "{{0 < as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date')
    ~ ' ' ~ manual_time) - as_timestamp(now()) < float(seconds)}}"
    value_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now()) < float(seconds)
    and states(check_entity) in [''unknown'', ''on'', ''home'']}}'
    - choose:
    - conditions:
    - condition: template
  8. sbyx revised this gist Jan 8, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -97,7 +97,7 @@ variables:
    seconds: "{{float(sunrise_duration) * 60}}"
    min_mired: !input "min_mired"
    start_mired: "{{state_attr(light_entity, 'max_mireds')}}"
    end_mired: "{{[state_attr(light_entity, 'min_mireds'), min_mired | int] | max}}"
    end_mired: "{{[state_attr(light_entity, 'min_mireds') | int, min_mired | int] | max}}"
    tick_time: "{{float(seconds) / float(range_brightness)}}"
    trigger:
    - platform: time_pattern
  9. sbyx revised this gist Jan 6, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -98,7 +98,7 @@ variables:
    min_mired: !input "min_mired"
    start_mired: "{{state_attr(light_entity, 'max_mireds')}}"
    end_mired: "{{[state_attr(light_entity, 'min_mireds'), min_mired | int] | max}}"
    tick_time: "{{(float(seconds) / 255) * (255 / float(end_brightness))}}"
    tick_time: "{{float(seconds) / float(range_brightness)}}"
    trigger:
    - platform: time_pattern
    minutes: "*"
  10. sbyx revised this gist Jan 6, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -46,7 +46,7 @@ blueprint:
    start_brightness:
    name: Minimum brightness
    description: The brightness to start with. Some lights ignore very low
    brightness values and may turn on with full brightness instead!
    values and may turn on with full brightness instead!
    default: 2
    selector:
    number:
  11. sbyx revised this gist Jan 6, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -45,8 +45,8 @@ blueprint:
    mode: slider
    start_brightness:
    name: Minimum brightness
    description: The brightness to start with. Note that some lights ignore
    very low brightness values and may turn on with full brightness instead.
    description: The brightness to start with. Some lights ignore very low
    brightness values and may turn on with full brightness instead!
    default: 2
    selector:
    number:
  12. sbyx revised this gist Jan 6, 2021. 1 changed file with 113 additions and 95 deletions.
    208 changes: 113 additions & 95 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -1,34 +1,39 @@
    blueprint:
    name: Wake-up light alarm with sunrise effect
    description: 'A wake-up light alarm with a brightness and color temperature sunrise
    effect. Note: Requires date_time_iso sensor in configuration, not manually executable!'
    description:
    "A wake-up light alarm with a brightness and color temperature sunrise
    effect. Note: Requires date_time_iso sensor in configuration, not manually executable!"
    domain: automation
    input:
    light_entity:
    name: Wake-up light entity
    description: The light to control. Turning it off during the sunrise will keep
    description:
    The light to control. Turning it off during the sunrise will keep
    it off. Color temperature range is auto-detected.
    selector:
    entity:
    domain: light
    timestamp_sensor:
    name: Alarm timestamp sensor
    description: 'Sensor with timestamp of next alarm with device_class: timestamp
    (set to ''none'' for manual alarm time)'
    description:
    "Sensor with timestamp of next alarm with device_class: timestamp
    (set to 'none' for manual alarm time)"
    default: none
    selector:
    entity:
    device_class: timestamp
    manual_time:
    name: Manual alarm time
    description: Time to trigger alarm every day if timestamp sensor is not set.
    description:
    Time to trigger alarm every day if timestamp sensor is not set.
    Settings at or shortly after midnight will not work as expected!
    default: '7:00:00'
    default: "7:00:00"
    selector:
    time: {}
    sunrise_duration:
    name: Sunrise duration
    description: The sunrise will start the configured number of minutes before
    description:
    The sunrise will start the configured number of minutes before
    the timestamp.
    default: 25
    selector:
    @@ -40,7 +45,8 @@ blueprint:
    mode: slider
    start_brightness:
    name: Minimum brightness
    description: The brightness to start with.
    description: The brightness to start with. Note that some lights ignore
    very low brightness values and may turn on with full brightness instead.
    default: 2
    selector:
    number:
    @@ -50,7 +56,9 @@ blueprint:
    mode: slider
    end_brightness:
    name: Maximum brightness
    description: The brightness will be transitioned from the minimum to the configured value.
    description:
    The brightness will be transitioned from the minimum to the configured
    value.
    default: 255
    selector:
    number:
    @@ -60,109 +68,119 @@ blueprint:
    mode: slider
    min_mired:
    name: Minimum color temperature
    description: 'The minimum color temperature to use. (0: lowest supported)'
    description: "The minimum color temperature to use. (0: lowest supported)"
    default: 0
    selector:
    number:
    min: 0
    max: 500
    step: 5
    min: 0.0
    max: 500.0
    step: 5.0
    mode: slider
    unit_of_measurement: mired
    pre_sunrise_actions:
    name: Pre-sunrise actions
    description: Optional actions to run before sunrise starts. Wait-Actions may
    description:
    Optional actions to run before sunrise starts. Wait-Actions may
    be used to define additional alarm conditions.
    default: []
    selector:
    action: {}
    source_url: https://gist.github.com/sbyx/96c43b13b90ae1c35b872313ba1d2d2d/
    source_url: https://gist.github.com/sbyx/96c43b13b90ae1c35b872313ba1d2d2d
    variables:
    light_entity: !input 'light_entity'
    sensor: !input 'timestamp_sensor'
    sunrise_duration: !input 'sunrise_duration'
    start_brightness: !input 'start_brightness'
    end_brightness: !input 'end_brightness'
    range_brightness: '{{float(end_brightness)-float(start_brightness)}}'
    manual_time: !input 'manual_time'
    seconds: '{{float(sunrise_duration) * 60}}'
    min_mired: !input 'min_mired'
    start_mired: '{{state_attr(light_entity, ''max_mireds'')}}'
    end_mired: '{{[state_attr(light_entity, ''min_mireds''), min_mired | int] | max}}'
    tick_time: '{{(float(seconds) / 255) * (255 / float(end_brightness))}}'
    light_entity: !input "light_entity"
    sensor: !input "timestamp_sensor"
    sunrise_duration: !input "sunrise_duration"
    start_brightness: !input "start_brightness"
    end_brightness: !input "end_brightness"
    range_brightness: "{{float(end_brightness)-float(start_brightness)}}"
    manual_time: !input "manual_time"
    seconds: "{{float(sunrise_duration) * 60}}"
    min_mired: !input "min_mired"
    start_mired: "{{state_attr(light_entity, 'max_mireds')}}"
    end_mired: "{{[state_attr(light_entity, 'min_mireds'), min_mired | int] | max}}"
    tick_time: "{{(float(seconds) / 255) * (255 / float(end_brightness))}}"
    trigger:
    - platform: time_pattern
    minutes: '*'
    - platform: time_pattern
    minutes: "*"
    condition: []
    action:
    - wait_template: '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    - wait_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none''
    else states(''sensor.date'') ~ '' '' ~ manual_time)
    - as_timestamp(states(''sensor.date_time_iso'')) < float(seconds)}}'
    - choose: []
    default: !input 'pre_sunrise_actions'
    - condition: template
    value_template: '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    - condition: template
    value_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none''
    else states(''sensor.date'') ~ '' '' ~ manual_time)
    - as_timestamp(now()) < float(seconds)}}'
    - choose:
    - conditions:
    - condition: template
    value_template: '{{state_attr(light_entity, ''min_mireds'') != None}}'
    sequence:
    - service: light.turn_on
    data:
    brightness: '{{start_brightness}}'
    color_temp: '{{start_mired}}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness: '{{start_brightness}}'
    entity_id: !input 'light_entity'
    - repeat:
    while:
    - condition: template
    value_template: '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    - condition: template
    value_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else
    states(''sensor.date'') ~ '' '' ~ manual_time) - as_timestamp(now()) < float(seconds)}}'
    sequence:
    - delay: '{{tick_time}}'
    - choose:
    - wait_template: "{{sensor == 'none' or as_timestamp(states(sensor)) != None}}"
    - wait_template:
    "{{0 < as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date')
    ~ ' ' ~ manual_time) - as_timestamp(states('sensor.date_time_iso')) < float(seconds)}}"
    - choose: []
    default: !input "pre_sunrise_actions"
    - condition: template
    value_template: "{{sensor == 'none' or as_timestamp(states(sensor)) != None}}"
    - condition: template
    value_template:
    "{{0 < as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date')
    ~ ' ' ~ manual_time) - as_timestamp(now()) < float(seconds)}}"
    - choose:
    - conditions:
    - condition: state
    entity_id: !input 'light_entity'
    state: 'on'
    - condition: template
    value_template: '{{sensor == ''none'' or as_timestamp(states(sensor)) !=
    None}}'
    - condition: template
    value_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else
    states(''sensor.date'') ~ '' '' ~ manual_time) - as_timestamp(now()) < float(seconds)}}'
    - condition: template
    value_template: "{{state_attr(light_entity, 'min_mireds') != None}}"
    sequence:
    - choose:
    - conditions:
    - condition: template
    value_template: '{{state_attr(light_entity, ''min_mireds'') != None}}'
    sequence:
    - service: light.turn_on
    data:
    brightness: '{{(float(end_brightness) - (float(range_brightness) *
    (as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int}}'
    color_temp: '{{(float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int}}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness: '{{(float(end_brightness) - (float(range_brightness) *
    (as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int}}'
    entity_id: !input 'light_entity'
    brightness: "{{start_brightness}}"
    color_temp: "{{start_mired}}"
    entity_id: !input "light_entity"
    default:
    - service: light.turn_on
    data:
    brightness: "{{start_brightness}}"
    entity_id: !input "light_entity"
    - repeat:
    while:
    - condition: template
    value_template: "{{sensor == 'none' or as_timestamp(states(sensor)) != None}}"
    - condition: template
    value_template:
    "{{0 < as_timestamp(states(sensor) if sensor != 'none' else
    states('sensor.date') ~ ' ' ~ manual_time) - as_timestamp(now()) < float(seconds)}}"
    sequence:
    - delay: "{{tick_time}}"
    - choose:
    - conditions:
    - condition: state
    entity_id: !input "light_entity"
    state: "on"
    - condition: template
    value_template:
    "{{sensor == 'none' or as_timestamp(states(sensor)) !=
    None}}"
    - condition: template
    value_template:
    "{{0 < as_timestamp(states(sensor) if sensor != 'none'
    else states('sensor.date') ~ ' ' ~ manual_time) - as_timestamp(now())
    < float(seconds)}}"
    sequence:
    - choose:
    - conditions:
    - condition: template
    value_template: "{{state_attr(light_entity, 'min_mireds') != None}}"
    sequence:
    - service: light.turn_on
    data:
    brightness:
    "{{(float(end_brightness) - (float(range_brightness) *
    (as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date')
    ~ ' ' ~ manual_time) - as_timestamp(now())) / float(seconds)))
    | int}}"
    color_temp:
    "{{(float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date')
    ~ ' ' ~ manual_time) - as_timestamp(now())) / float(seconds)))
    | int}}"
    entity_id: !input "light_entity"
    default:
    - service: light.turn_on
    data:
    brightness:
    "{{(float(end_brightness) - (float(range_brightness) * (as_timestamp(states(sensor)
    if sensor != 'none' else states('sensor.date') ~ ' ' ~ manual_time)
    - as_timestamp(now())) / float(seconds))) | int}}"
    entity_id: !input "light_entity"
    mode: single
    max_exceeded: silent
  13. sbyx revised this gist Jan 6, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -88,7 +88,7 @@ variables:
    seconds: '{{float(sunrise_duration) * 60}}'
    min_mired: !input 'min_mired'
    start_mired: '{{state_attr(light_entity, ''max_mireds'')}}'
    end_mired: '{{[state_attr(light_entity, ''min_mireds''), min_mired] | max}}'
    end_mired: '{{[state_attr(light_entity, ''min_mireds''), min_mired | int] | max}}'
    tick_time: '{{(float(seconds) / 255) * (255 / float(end_brightness))}}'
    trigger:
    - platform: time_pattern
  14. sbyx revised this gist Jan 6, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -50,7 +50,7 @@ blueprint:
    mode: slider
    end_brightness:
    name: Maximum brightness
    description: The brightness will be transitioned from 1 to the configured value.
    description: The brightness will be transitioned from the minimum to the configured value.
    default: 255
    selector:
    number:
  15. sbyx revised this gist Jan 6, 2021. 1 changed file with 29 additions and 5 deletions.
    34 changes: 29 additions & 5 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -38,6 +38,16 @@ blueprint:
    step: 5.0
    unit_of_measurement: min
    mode: slider
    start_brightness:
    name: Minimum brightness
    description: The brightness to start with.
    default: 2
    selector:
    number:
    min: 1.0
    max: 255.0
    step: 1.0
    mode: slider
    end_brightness:
    name: Maximum brightness
    description: The brightness will be transitioned from 1 to the configured value.
    @@ -48,6 +58,17 @@ blueprint:
    max: 255.0
    step: 5.0
    mode: slider
    min_mired:
    name: Minimum color temperature
    description: 'The minimum color temperature to use. (0: lowest supported)'
    default: 0
    selector:
    number:
    min: 0
    max: 500
    step: 5
    mode: slider
    unit_of_measurement: mired
    pre_sunrise_actions:
    name: Pre-sunrise actions
    description: Optional actions to run before sunrise starts. Wait-Actions may
    @@ -60,11 +81,14 @@ variables:
    light_entity: !input 'light_entity'
    sensor: !input 'timestamp_sensor'
    sunrise_duration: !input 'sunrise_duration'
    start_brightness: !input 'start_brightness'
    end_brightness: !input 'end_brightness'
    range_brightness: '{{float(end_brightness)-float(start_brightness)}}'
    manual_time: !input 'manual_time'
    seconds: '{{float(sunrise_duration) * 60}}'
    min_mired: !input 'min_mired'
    start_mired: '{{state_attr(light_entity, ''max_mireds'')}}'
    end_mired: '{{state_attr(light_entity, ''min_mireds'')}}'
    end_mired: '{{[state_attr(light_entity, ''min_mireds''), min_mired] | max}}'
    tick_time: '{{(float(seconds) / 255) * (255 / float(end_brightness))}}'
    trigger:
    - platform: time_pattern
    @@ -90,13 +114,13 @@ action:
    sequence:
    - service: light.turn_on
    data:
    brightness: 1
    brightness: '{{start_brightness}}'
    color_temp: '{{start_mired}}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness: 1
    brightness: '{{start_brightness}}'
    entity_id: !input 'light_entity'
    - repeat:
    while:
    @@ -126,7 +150,7 @@ action:
    sequence:
    - service: light.turn_on
    data:
    brightness: '{{(float(end_brightness) - (float(end_brightness) *
    brightness: '{{(float(end_brightness) - (float(range_brightness) *
    (as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int}}'
    color_temp: '{{(float(end_mired) + (float(start_mired) - float(end_mired))
    @@ -136,7 +160,7 @@ action:
    default:
    - service: light.turn_on
    data:
    brightness: '{{(float(end_brightness) - (float(end_brightness) *
    brightness: '{{(float(end_brightness) - (float(range_brightness) *
    (as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int}}'
    entity_id: !input 'light_entity'
  16. sbyx revised this gist Jan 1, 2021. 1 changed file with 86 additions and 99 deletions.
    185 changes: 86 additions & 99 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -1,39 +1,34 @@
    blueprint:
    name: Wake-up light alarm with sunrise effect
    description:
    "A wake-up light alarm with a brightness and color temperature sunrise
    effect. Note: Requires date_time_iso sensor in configuration, not manually executable!"
    description: 'A wake-up light alarm with a brightness and color temperature sunrise
    effect. Note: Requires date_time_iso sensor in configuration, not manually executable!'
    domain: automation
    input:
    light_entity:
    name: Wake-up light entity
    description:
    The light to control. Turning it off during the sunrise will keep
    description: The light to control. Turning it off during the sunrise will keep
    it off. Color temperature range is auto-detected.
    selector:
    entity:
    domain: light
    timestamp_sensor:
    name: Alarm timestamp sensor
    description:
    "Sensor with timestamp of next alarm with device_class: timestamp
    (set to 'none' for manual alarm time)"
    description: 'Sensor with timestamp of next alarm with device_class: timestamp
    (set to ''none'' for manual alarm time)'
    default: none
    selector:
    entity:
    device_class: timestamp
    manual_time:
    name: Manual alarm time
    description:
    Time to trigger alarm every day if timestamp sensor is not set.
    description: Time to trigger alarm every day if timestamp sensor is not set.
    Settings at or shortly after midnight will not work as expected!
    default: "7:00:00"
    default: '7:00:00'
    selector:
    time: {}
    sunrise_duration:
    name: Sunrise duration
    description:
    The sunrise will start the configured number of minutes before
    description: The sunrise will start the configured number of minutes before
    the timestamp.
    default: 25
    selector:
    @@ -55,103 +50,95 @@ blueprint:
    mode: slider
    pre_sunrise_actions:
    name: Pre-sunrise actions
    description:
    Optional actions to run before sunrise starts. Wait-Actions may
    description: Optional actions to run before sunrise starts. Wait-Actions may
    be used to define additional alarm conditions.
    default: []
    selector:
    action: {}
    source_url: https://gist.github.com/sbyx/96c43b13b90ae1c35b872313ba1d2d2d
    source_url: https://gist.github.com/sbyx/96c43b13b90ae1c35b872313ba1d2d2d/
    variables:
    light_entity: !input "light_entity"
    sensor: !input "timestamp_sensor"
    sunrise_duration: !input "sunrise_duration"
    end_brightness: !input "end_brightness"
    manual_time: !input "manual_time"
    seconds: "{{ float(sunrise_duration) * 60 }}"
    start_mired: "{{ state_attr(light_entity, 'max_mireds') }}"
    end_mired: "{{ state_attr(light_entity, 'min_mireds') }}"
    tick_time: "{{ (float(seconds) / 255) * (255 / float(end_brightness)) }}"
    light_entity: !input 'light_entity'
    sensor: !input 'timestamp_sensor'
    sunrise_duration: !input 'sunrise_duration'
    end_brightness: !input 'end_brightness'
    manual_time: !input 'manual_time'
    seconds: '{{float(sunrise_duration) * 60}}'
    start_mired: '{{state_attr(light_entity, ''max_mireds'')}}'
    end_mired: '{{state_attr(light_entity, ''min_mireds'')}}'
    tick_time: '{{(float(seconds) / 255) * (255 / float(end_brightness))}}'
    trigger:
    - platform: time_pattern
    minutes: "*"
    - platform: time_pattern
    minutes: '*'
    condition: []
    action:
    - wait_template: "{{ sensor == 'none' or as_timestamp(states(sensor)) != None }}"
    - wait_template:
    "{{ 0 < as_timestamp(states(sensor) if sensor != 'none' else now().date()
    ~ ' ' ~ manual_time) - as_timestamp(states('sensor.date_time_iso')) < float(seconds) }}"
    - choose: []
    default: !input "pre_sunrise_actions"
    - condition: template
    value_template: "{{ sensor == 'none' or as_timestamp(states(sensor)) != None }}"
    - condition: template
    value_template:
    "{{ 0 < as_timestamp(states(sensor) if sensor != 'none' else now().date()
    ~ ' ' ~ manual_time) - as_timestamp(now()) < float(seconds) }}"
    - choose:
    - wait_template: '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    - wait_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none''
    else states(''sensor.date'') ~ '' '' ~ manual_time)
    - as_timestamp(states(''sensor.date_time_iso'')) < float(seconds)}}'
    - choose: []
    default: !input 'pre_sunrise_actions'
    - condition: template
    value_template: '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    - condition: template
    value_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none''
    else states(''sensor.date'') ~ '' '' ~ manual_time)
    - as_timestamp(now()) < float(seconds)}}'
    - choose:
    - conditions:
    - condition: template
    value_template: '{{state_attr(light_entity, ''min_mireds'') != None}}'
    sequence:
    - service: light.turn_on
    data:
    brightness: 1
    color_temp: '{{start_mired}}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness: 1
    entity_id: !input 'light_entity'
    - repeat:
    while:
    - condition: template
    value_template: '{{sensor == ''none'' or as_timestamp(states(sensor)) != None}}'
    - condition: template
    value_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else
    states(''sensor.date'') ~ '' '' ~ manual_time) - as_timestamp(now()) < float(seconds)}}'
    sequence:
    - delay: '{{tick_time}}'
    - choose:
    - conditions:
    - condition: template
    value_template: "{{ state_attr(light_entity, 'min_mireds') != None }}"
    sequence:
    - service: light.turn_on
    data:
    brightness: 1
    color_temp: "{{ start_mired }}"
    entity_id: !input "light_entity"
    default:
    - service: light.turn_on
    data:
    brightness: 1
    entity_id: !input "light_entity"
    - repeat:
    while:
    - condition: state
    entity_id: !input 'light_entity'
    state: 'on'
    - condition: template
    value_template: "{{ sensor == 'none' or as_timestamp(states(sensor)) != None }}"
    value_template: '{{sensor == ''none'' or as_timestamp(states(sensor)) !=
    None}}'
    - condition: template
    value_template:
    "{{ 0 < as_timestamp(states(sensor) if sensor != 'none' else
    now().date() ~ ' ' ~ manual_time) - as_timestamp(now()) < float(seconds)
    }}"
    sequence:
    - delay: "{{ tick_time }}"
    value_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else
    states(''sensor.date'') ~ '' '' ~ manual_time) - as_timestamp(now()) < float(seconds)}}'
    sequence:
    - choose:
    - conditions:
    - condition: state
    entity_id: !input "light_entity"
    state: "on"
    - condition: template
    value_template: "{{ sensor == 'none' or as_timestamp(states(sensor)) != None }}"
    - condition: template
    value_template:
    "{{ 0 < as_timestamp(states(sensor) if sensor != 'none'
    else now().date() ~ ' ' ~ manual_time) - as_timestamp(now()) < float(seconds) }}"
    sequence:
    - choose:
    - conditions:
    - condition: template
    value_template: "{{ state_attr(light_entity, 'min_mireds') != None }}"
    sequence:
    - service: light.turn_on
    data:
    brightness:
    "{{ (float(end_brightness) - (float(end_brightness) *
    (as_timestamp(states(sensor) if sensor != 'none' else now().date()
    ~ ' ' ~ manual_time) - as_timestamp(now())) / float(seconds)))
    | int }}"
    color_temp:
    "{{ (float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(sensor) if sensor != 'none' else now().date()
    ~ ' ' ~ manual_time) - as_timestamp(now())) / float(seconds)))
    | int }}"
    entity_id: !input "light_entity"
    default:
    - service: light.turn_on
    data:
    brightness:
    "{{ (float(end_brightness) - (float(end_brightness) * (as_timestamp(states(sensor)
    if sensor != 'none' else now().date() ~ ' ' ~ manual_time) - as_timestamp(now()))
    / float(seconds))) | int }}"
    entity_id: !input "light_entity"
    - conditions:
    - condition: template
    value_template: '{{state_attr(light_entity, ''min_mireds'') != None}}'
    sequence:
    - service: light.turn_on
    data:
    brightness: '{{(float(end_brightness) - (float(end_brightness) *
    (as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int}}'
    color_temp: '{{(float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int}}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness: '{{(float(end_brightness) - (float(end_brightness) *
    (as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int}}'
    entity_id: !input 'light_entity'
    mode: single
    max_exceeded: silent
  17. sbyx revised this gist Dec 31, 2020. 1 changed file with 99 additions and 87 deletions.
    186 changes: 99 additions & 87 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -1,34 +1,39 @@
    blueprint:
    name: Wake-up light alarm with sunrise effect
    description: 'A wake-up light alarm with a brightness and color temperature sunrise
    effect. Note: Requires date_time_iso sensor in configuration, not manually executable!'
    description:
    "A wake-up light alarm with a brightness and color temperature sunrise
    effect. Note: Requires date_time_iso sensor in configuration, not manually executable!"
    domain: automation
    input:
    light_entity:
    name: Wake-up light entity
    description: The light to control. Turning it off during the sunrise will keep
    description:
    The light to control. Turning it off during the sunrise will keep
    it off. Color temperature range is auto-detected.
    selector:
    entity:
    domain: light
    timestamp_sensor:
    name: Alarm timestamp sensor
    description: 'Sensor with timestamp of next alarm with device_class: timestamp
    (set to ''none'' for manual alarm time)'
    description:
    "Sensor with timestamp of next alarm with device_class: timestamp
    (set to 'none' for manual alarm time)"
    default: none
    selector:
    entity:
    device_class: timestamp
    manual_time:
    name: Manual alarm time
    description: Time to trigger alarm every day if timestamp sensor is not set.
    description:
    Time to trigger alarm every day if timestamp sensor is not set.
    Settings at or shortly after midnight will not work as expected!
    default: '7:00:00'
    default: "7:00:00"
    selector:
    time: {}
    sunrise_duration:
    name: Sunrise duration
    description: The sunrise will start the configured number of minutes before
    description:
    The sunrise will start the configured number of minutes before
    the timestamp.
    default: 25
    selector:
    @@ -50,96 +55,103 @@ blueprint:
    mode: slider
    pre_sunrise_actions:
    name: Pre-sunrise actions
    description: Optional actions to run before sunrise starts. Wait-Actions may be
    used to define additional alarm conditions.
    description:
    Optional actions to run before sunrise starts. Wait-Actions may
    be used to define additional alarm conditions.
    default: []
    selector:
    action: {}
    source_url: https://gist.github.com/sbyx/96c43b13b90ae1c35b872313ba1d2d2d
    variables:
    light_entity: !input 'light_entity'
    sensor: !input 'timestamp_sensor'
    sunrise_duration: !input 'sunrise_duration'
    end_brightness: !input 'end_brightness'
    manual_time: !input 'manual_time'
    seconds: '{{ float(sunrise_duration) * 60 }}'
    start_mired: '{{ state_attr(light_entity, ''max_mireds'') }}'
    end_mired: '{{ state_attr(light_entity, ''min_mireds'') }}'
    tick_time: '{{ (float(seconds) / 255) * (255 / float(end_brightness)) }}'
    light_entity: !input "light_entity"
    sensor: !input "timestamp_sensor"
    sunrise_duration: !input "sunrise_duration"
    end_brightness: !input "end_brightness"
    manual_time: !input "manual_time"
    seconds: "{{ float(sunrise_duration) * 60 }}"
    start_mired: "{{ state_attr(light_entity, 'max_mireds') }}"
    end_mired: "{{ state_attr(light_entity, 'min_mireds') }}"
    tick_time: "{{ (float(seconds) / 255) * (255 / float(end_brightness)) }}"
    trigger:
    - platform: time_pattern
    minutes: '*'
    - platform: time_pattern
    minutes: "*"
    condition: []
    action:
    - wait_template: '{{ sensor == ''none'' or as_timestamp(states(sensor)) != None }}'
    - wait_template: '{{ 0 < as_timestamp(states(sensor) if sensor != ''none''
    else now().date() ~ '' '' ~ manual_time)
    - as_timestamp(states(''sensor.date_time_iso'')) < float(seconds) }}'
    - choose: []
    default: !input 'pre_sunrise_actions'
    - condition: template
    value_template: '{{ sensor == ''none'' or as_timestamp(states(sensor)) != None }}'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(sensor) if sensor != ''none''
    else now().date() ~ '' '' ~ manual_time) - as_timestamp(now()) < float(seconds) }}'
    - choose:
    - conditions:
    - condition: template
    value_template: '{{ state_attr(light_entity, ''min_mireds'') != None }}'
    sequence:
    - service: light.turn_on
    data:
    brightness: 1
    color_temp: '{{ start_mired }}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness_pct: 1
    entity_id: !input 'light_entity'
    - repeat:
    while:
    - condition: template
    value_template: '{{ sensor == ''none'' or as_timestamp(states(sensor)) != None }}'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(sensor) if sensor != ''none''
    else now().date() ~ '' '' ~ manual_time) - as_timestamp(now()) < float(seconds) }}'
    sequence:
    - delay: '{{ tick_time }}'
    - choose:
    - wait_template: "{{ sensor == 'none' or as_timestamp(states(sensor)) != None }}"
    - wait_template:
    "{{ 0 < as_timestamp(states(sensor) if sensor != 'none' else now().date()
    ~ ' ' ~ manual_time) - as_timestamp(states('sensor.date_time_iso')) < float(seconds) }}"
    - choose: []
    default: !input "pre_sunrise_actions"
    - condition: template
    value_template: "{{ sensor == 'none' or as_timestamp(states(sensor)) != None }}"
    - condition: template
    value_template:
    "{{ 0 < as_timestamp(states(sensor) if sensor != 'none' else now().date()
    ~ ' ' ~ manual_time) - as_timestamp(now()) < float(seconds) }}"
    - choose:
    - conditions:
    - condition: state
    entity_id: !input 'light_entity'
    state: 'on'
    - condition: template
    value_template: '{{ sensor == ''none'' or as_timestamp(states(sensor)) != None }}'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(sensor) if sensor != ''none''
    else now().date() ~ '' '' ~ manual_time) - as_timestamp(now()) < float(seconds) }}'
    - condition: template
    value_template: "{{ state_attr(light_entity, 'min_mireds') != None }}"
    sequence:
    - choose:
    - conditions:
    - condition: template
    value_template: '{{ state_attr(light_entity, ''min_mireds'') != None }}'
    sequence:
    - service: light.turn_on
    data:
    brightness: '{{ (float(end_brightness) - (float(end_brightness)
    * (as_timestamp(states(sensor) if sensor != ''none''
    else now().date() ~ '' '' ~ manual_time)
    - as_timestamp(now())) / float(seconds))) | int }}'
    color_temp: '{{ (float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(sensor) if sensor != ''none'' else
    now().date() ~ '' '' ~ manual_time)
    - as_timestamp(now())) / float(seconds))) | int }}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness: '{{ (float(end_brightness) - (float(end_brightness)
    * (as_timestamp(states(sensor) if sensor != ''none''
    else now().date() ~ '' '' ~ manual_time)
    - as_timestamp(now())) / float(seconds))) | int }}'
    entity_id: !input 'light_entity'
    brightness: 1
    color_temp: "{{ start_mired }}"
    entity_id: !input "light_entity"
    default:
    - service: light.turn_on
    data:
    brightness: 1
    entity_id: !input "light_entity"
    - repeat:
    while:
    - condition: template
    value_template: "{{ sensor == 'none' or as_timestamp(states(sensor)) != None }}"
    - condition: template
    value_template:
    "{{ 0 < as_timestamp(states(sensor) if sensor != 'none' else
    now().date() ~ ' ' ~ manual_time) - as_timestamp(now()) < float(seconds)
    }}"
    sequence:
    - delay: "{{ tick_time }}"
    - choose:
    - conditions:
    - condition: state
    entity_id: !input "light_entity"
    state: "on"
    - condition: template
    value_template: "{{ sensor == 'none' or as_timestamp(states(sensor)) != None }}"
    - condition: template
    value_template:
    "{{ 0 < as_timestamp(states(sensor) if sensor != 'none'
    else now().date() ~ ' ' ~ manual_time) - as_timestamp(now()) < float(seconds) }}"
    sequence:
    - choose:
    - conditions:
    - condition: template
    value_template: "{{ state_attr(light_entity, 'min_mireds') != None }}"
    sequence:
    - service: light.turn_on
    data:
    brightness:
    "{{ (float(end_brightness) - (float(end_brightness) *
    (as_timestamp(states(sensor) if sensor != 'none' else now().date()
    ~ ' ' ~ manual_time) - as_timestamp(now())) / float(seconds)))
    | int }}"
    color_temp:
    "{{ (float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(sensor) if sensor != 'none' else now().date()
    ~ ' ' ~ manual_time) - as_timestamp(now())) / float(seconds)))
    | int }}"
    entity_id: !input "light_entity"
    default:
    - service: light.turn_on
    data:
    brightness:
    "{{ (float(end_brightness) - (float(end_brightness) * (as_timestamp(states(sensor)
    if sensor != 'none' else now().date() ~ ' ' ~ manual_time) - as_timestamp(now()))
    / float(seconds))) | int }}"
    entity_id: !input "light_entity"
    mode: single
    max_exceeded: silent
  18. sbyx revised this gist Dec 28, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ blueprint:
    name: Manual alarm time
    description: Time to trigger alarm every day if timestamp sensor is not set.
    Settings at or shortly after midnight will not work as expected!
    default: 7:00:00
    default: '7:00:00'
    selector:
    time: {}
    sunrise_duration:
  19. sbyx revised this gist Dec 19, 2020. 1 changed file with 42 additions and 59 deletions.
    101 changes: 42 additions & 59 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,7 @@
    blueprint:
    name: Wake-up light alarm with sunrise effect
    description: A wake-up light alarm with a brightness and color temperature sunrise
    effect using an existing timestamp sensor as source. Requires date_time_iso sensor
    in configuration!
    description: 'A wake-up light alarm with a brightness and color temperature sunrise
    effect. Note: Requires date_time_iso sensor in configuration, not manually executable!'
    domain: automation
    input:
    light_entity:
    @@ -22,8 +21,9 @@ blueprint:
    device_class: timestamp
    manual_time:
    name: Manual alarm time
    description: Manual alarm time. (ignored if alarm timestamp sensor is set)
    default: 0:00:00
    description: Time to trigger alarm every day if timestamp sensor is not set.
    Settings at or shortly after midnight will not work as expected!
    default: 7:00:00
    selector:
    time: {}
    sunrise_duration:
    @@ -38,63 +38,58 @@ blueprint:
    step: 5.0
    unit_of_measurement: min
    mode: slider
    max_brightness:
    end_brightness:
    name: Maximum brightness
    description: The brightness will be transitioned from 1% to the configured percentage.
    default: 100
    description: The brightness will be transitioned from 1 to the configured value.
    default: 255
    selector:
    number:
    min: 5.0
    max: 100.0
    step: 1.0
    unit_of_measurement: '%'
    max: 255.0
    step: 5.0
    mode: slider
    pre_sunrise_actions:
    name: Pre-sunrise actions
    description: Optional actions to run before sunrise starts. (use 'wait' for
    additional conditions)
    description: Optional actions to run before sunrise starts. Wait-Actions may be
    used to define additional alarm conditions.
    default: []
    selector:
    action: {}
    source_url: https://gist.github.com/sbyx/96c43b13b90ae1c35b872313ba1d2d2d
    variables:
    light_entity: !input 'light_entity'
    timestamp_sensor: !input 'timestamp_sensor'
    sensor: !input 'timestamp_sensor'
    sunrise_duration: !input 'sunrise_duration'
    max_brightness: !input 'max_brightness'
    end_brightness: !input 'end_brightness'
    manual_time: !input 'manual_time'
    seconds: '{{ float(sunrise_duration) * 60 }}'
    start_mired: '{{ state_attr(light_entity, ''max_mireds'') }}'
    end_mired: '{{ state_attr(light_entity, ''min_mireds'') }}'
    tick_time: '{{ float(sunrise_duration) * 0.6 * (100 / float(max_brightness)) }}'
    tick_time: '{{ (float(seconds) / 255) * (255 / float(end_brightness)) }}'
    trigger:
    - platform: time_pattern
    minutes: '*'
    condition: []
    action:
    - wait_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor))
    != None }}'
    - wait_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor
    != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' ''
    ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) < 60 * float(sunrise_duration)
    }}'
    - wait_template: '{{ sensor == ''none'' or as_timestamp(states(sensor)) != None }}'
    - wait_template: '{{ 0 < as_timestamp(states(sensor) if sensor != ''none''
    else now().date() ~ '' '' ~ manual_time)
    - as_timestamp(states(''sensor.date_time_iso'')) < float(seconds) }}'
    - choose: []
    default: !input 'pre_sunrise_actions'
    - condition: template
    value_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor))
    != None }}'
    value_template: '{{ sensor == ''none'' or as_timestamp(states(sensor)) != None }}'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor
    != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' ''
    ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) < 60 * float(sunrise_duration)
    }}'
    value_template: '{{ 0 < as_timestamp(states(sensor) if sensor != ''none''
    else now().date() ~ '' '' ~ manual_time) - as_timestamp(now()) < float(seconds) }}'
    - choose:
    - conditions:
    - condition: template
    value_template: '{{ state_attr(light_entity, ''min_mireds'') != None }}'
    sequence:
    - service: light.turn_on
    data:
    brightness_pct: 1
    brightness: 1
    color_temp: '{{ start_mired }}'
    entity_id: !input 'light_entity'
    default:
    @@ -105,13 +100,10 @@ action:
    - repeat:
    while:
    - condition: template
    value_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor))
    != None }}'
    value_template: '{{ sensor == ''none'' or as_timestamp(states(sensor)) != None }}'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor
    != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ ''
    '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) < 60 *
    float(sunrise_duration) }}'
    value_template: '{{ 0 < as_timestamp(states(sensor) if sensor != ''none''
    else now().date() ~ '' '' ~ manual_time) - as_timestamp(now()) < float(seconds) }}'
    sequence:
    - delay: '{{ tick_time }}'
    - choose:
    @@ -120,43 +112,34 @@ action:
    entity_id: !input 'light_entity'
    state: 'on'
    - condition: template
    value_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor))
    != None }}'
    value_template: '{{ sensor == ''none'' or as_timestamp(states(sensor)) != None }}'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor
    != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day
    ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso''))
    < 60 * float(sunrise_duration) }}'
    value_template: '{{ 0 < as_timestamp(states(sensor) if sensor != ''none''
    else now().date() ~ '' '' ~ manual_time) - as_timestamp(now()) < float(seconds) }}'
    sequence:
    - choose:
    - conditions:
    - condition: template
    value_template: '{{ state_attr(light_entity, ''min_mireds'') != None
    }}'
    value_template: '{{ state_attr(light_entity, ''min_mireds'') != None }}'
    sequence:
    - service: light.turn_on
    data:
    brightness_pct: '{{ (float(max_brightness) - (float(max_brightness)
    * (as_timestamp(states(timestamp_sensor) if timestamp_sensor !=
    ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day
    ~ '' '' ~ manual_time) - as_timestamp(now())) / (float(sunrise_duration)
    * 60))) | int }}'
    brightness: '{{ (float(end_brightness) - (float(end_brightness)
    * (as_timestamp(states(sensor) if sensor != ''none''
    else now().date() ~ '' '' ~ manual_time)
    - as_timestamp(now())) / float(seconds))) | int }}'
    color_temp: '{{ (float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(timestamp_sensor) if timestamp_sensor !=
    ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day
    ~ '' '' ~ manual_time) - as_timestamp(now())) / (float(sunrise_duration)
    * 60))) | int }}'
    transition: '{{ tick_time | int }}'
    * ((as_timestamp(states(sensor) if sensor != ''none'' else
    now().date() ~ '' '' ~ manual_time)
    - as_timestamp(now())) / float(seconds))) | int }}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness_pct: '{{ (float(max_brightness) - (float(max_brightness)
    * (as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none''
    else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' ''
    ~ manual_time) - as_timestamp(now())) / (float(sunrise_duration) *
    60))) | int }}'
    transition: '{{ tick_time | int }}'
    brightness: '{{ (float(end_brightness) - (float(end_brightness)
    * (as_timestamp(states(sensor) if sensor != ''none''
    else now().date() ~ '' '' ~ manual_time)
    - as_timestamp(now())) / float(seconds))) | int }}'
    entity_id: !input 'light_entity'
    mode: single
    max_exceeded: silent
  20. sbyx revised this gist Dec 18, 2020. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -22,8 +22,7 @@ blueprint:
    device_class: timestamp
    manual_time:
    name: Manual alarm time
    description: Manual alarm time. (ignored if alarm timestamp sensor is set, requires
    'date' sensor in config)
    description: Manual alarm time. (ignored if alarm timestamp sensor is set)
    default: 0:00:00
    selector:
    time: {}
  21. sbyx revised this gist Dec 18, 2020. 1 changed file with 45 additions and 19 deletions.
    64 changes: 45 additions & 19 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -14,17 +14,19 @@ blueprint:
    domain: light
    timestamp_sensor:
    name: Alarm timestamp sensor
    description: 'Sensor with timestamp of next alarm with device_class: timestamp (set to ''none'' for manual alarm time)'
    description: 'Sensor with timestamp of next alarm with device_class: timestamp
    (set to ''none'' for manual alarm time)'
    default: none
    selector:
    entity:
    device_class: timestamp
    manual_time:
    name: Manual alarm time
    description: 'Manual alarm time. (ignored if alarm timestamp sensor is set, requires ''date'' sensor in config)'
    default: '0:00:00'
    description: Manual alarm time. (ignored if alarm timestamp sensor is set, requires
    'date' sensor in config)
    default: 0:00:00
    selector:
    time:
    time: {}
    sunrise_duration:
    name: Sunrise duration
    description: The sunrise will start the configured number of minutes before
    @@ -50,7 +52,8 @@ blueprint:
    mode: slider
    pre_sunrise_actions:
    name: Pre-sunrise actions
    description: 'Optional actions to run before sunrise starts. (use ''wait'' for additional conditions)'
    description: Optional actions to run before sunrise starts. (use 'wait' for
    additional conditions)
    default: []
    selector:
    action: {}
    @@ -69,11 +72,22 @@ trigger:
    minutes: '*'
    condition: []
    action:
    - wait_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor)) != None }}'
    - wait_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso''))
    < 60 * float(sunrise_duration) }}'
    - wait_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor))
    != None }}'
    - wait_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor
    != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' ''
    ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) < 60 * float(sunrise_duration)
    }}'
    - choose: []
    default: !input 'pre_sunrise_actions'
    - condition: template
    value_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor))
    != None }}'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor
    != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' ''
    ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) < 60 * float(sunrise_duration)
    }}'
    - choose:
    - conditions:
    - condition: template
    @@ -92,10 +106,13 @@ action:
    - repeat:
    while:
    - condition: template
    value_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor)) != None }}'
    value_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor))
    != None }}'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso''))
    < 60 * float(sunrise_duration) }}'
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor
    != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ ''
    '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) < 60 *
    float(sunrise_duration) }}'
    sequence:
    - delay: '{{ tick_time }}'
    - choose:
    @@ -104,9 +121,12 @@ action:
    entity_id: !input 'light_entity'
    state: 'on'
    - condition: template
    value_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor)) != None }}'
    value_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor))
    != None }}'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso''))
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor
    != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day
    ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso''))
    < 60 * float(sunrise_duration) }}'
    sequence:
    - choose:
    @@ -118,19 +138,25 @@ action:
    - service: light.turn_on
    data:
    brightness_pct: '{{ (float(max_brightness) - (float(max_brightness)
    * (as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' '' ~ manual_time) - as_timestamp(now()))
    / (float(sunrise_duration) * 60))) | int }}'
    * (as_timestamp(states(timestamp_sensor) if timestamp_sensor !=
    ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day
    ~ '' '' ~ manual_time) - as_timestamp(now())) / (float(sunrise_duration)
    * 60))) | int }}'
    color_temp: '{{ (float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' '' ~ manual_time) - as_timestamp(now()))
    / (float(sunrise_duration) * 60))) | int }}'
    * ((as_timestamp(states(timestamp_sensor) if timestamp_sensor !=
    ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day
    ~ '' '' ~ manual_time) - as_timestamp(now())) / (float(sunrise_duration)
    * 60))) | int }}'
    transition: '{{ tick_time | int }}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness_pct: '{{ (float(max_brightness) - (float(max_brightness)
    * (as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' '' ~ manual_time) - as_timestamp(now())) /
    (float(sunrise_duration) * 60))) | int }}'
    * (as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none''
    else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' ''
    ~ manual_time) - as_timestamp(now())) / (float(sunrise_duration) *
    60))) | int }}'
    transition: '{{ tick_time | int }}'
    entity_id: !input 'light_entity'
    mode: single
  22. sbyx revised this gist Dec 17, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ blueprint:
    device_class: timestamp
    manual_time:
    name: Manual alarm time
    description: 'Manual alarm time. (ignored if alarm timestamp sensor is set)'
    description: 'Manual alarm time. (ignored if alarm timestamp sensor is set, requires ''date'' sensor in config)'
    default: '0:00:00'
    selector:
    time:
  23. sbyx revised this gist Dec 17, 2020. 1 changed file with 27 additions and 19 deletions.
    46 changes: 27 additions & 19 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -14,11 +14,17 @@ blueprint:
    domain: light
    timestamp_sensor:
    name: Alarm timestamp sensor
    description: 'Sensor with timestamp of next alarm (e.g. _next_alarm from companion
    app). Requires device_class: timestamp!'
    description: 'Sensor with timestamp of next alarm with device_class: timestamp (set to ''none'' for manual alarm time)'
    default: none
    selector:
    entity:
    device_class: timestamp
    manual_time:
    name: Manual alarm time
    description: 'Manual alarm time. (ignored if alarm timestamp sensor is set)'
    default: '0:00:00'
    selector:
    time:
    sunrise_duration:
    name: Sunrise duration
    description: The sunrise will start the configured number of minutes before
    @@ -44,7 +50,7 @@ blueprint:
    mode: slider
    pre_sunrise_actions:
    name: Pre-sunrise actions
    description: Actions to run before sunrise starts. (optional)
    description: 'Optional actions to run before sunrise starts. (use ''wait'' for additional conditions)'
    default: []
    selector:
    action: {}
    @@ -54,6 +60,7 @@ variables:
    timestamp_sensor: !input 'timestamp_sensor'
    sunrise_duration: !input 'sunrise_duration'
    max_brightness: !input 'max_brightness'
    manual_time: !input 'manual_time'
    start_mired: '{{ state_attr(light_entity, ''max_mireds'') }}'
    end_mired: '{{ state_attr(light_entity, ''min_mireds'') }}'
    tick_time: '{{ float(sunrise_duration) * 0.6 * (100 / float(max_brightness)) }}'
    @@ -62,8 +69,8 @@ trigger:
    minutes: '*'
    condition: []
    action:
    - wait_template: '{{ as_timestamp(states(timestamp_sensor)) != None }}'
    - wait_template: '{{ 0 < as_timestamp(states(timestamp_sensor)) - as_timestamp(states(''sensor.date_time_iso''))
    - wait_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor)) != None }}'
    - wait_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso''))
    < 60 * float(sunrise_duration) }}'
    - choose: []
    default: !input 'pre_sunrise_actions'
    @@ -85,9 +92,9 @@ action:
    - repeat:
    while:
    - condition: template
    value_template: '{{ as_timestamp(states(timestamp_sensor)) != None }}'
    value_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor)) != None }}'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor)) - as_timestamp(states(''sensor.date_time_iso''))
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso''))
    < 60 * float(sunrise_duration) }}'
    sequence:
    - delay: '{{ tick_time }}'
    @@ -97,32 +104,33 @@ action:
    entity_id: !input 'light_entity'
    state: 'on'
    - condition: template
    value_template: '{{ as_timestamp(states(timestamp_sensor)) != None }}'
    value_template: '{{ timestamp_sensor == ''none'' or as_timestamp(states(timestamp_sensor)) != None }}'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor)) - as_timestamp(states(''sensor.date_time_iso''))
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso''))
    < 60 * float(sunrise_duration) }}'
    sequence:
    - choose:
    - conditions:
    - condition: template
    value_template: '{{ state_attr(light_entity, ''min_mireds'') != None }}'
    sequence:
    value_template: '{{ state_attr(light_entity, ''min_mireds'') != None
    }}'
    sequence:
    - service: light.turn_on
    data:
    brightness_pct: '{{ (float(max_brightness) - (float(max_brightness) *
    (as_timestamp(states(timestamp_sensor)) - as_timestamp(now())) / (float(sunrise_duration)
    * 60))) | int }}'
    brightness_pct: '{{ (float(max_brightness) - (float(max_brightness)
    * (as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' '' ~ manual_time) - as_timestamp(now()))
    / (float(sunrise_duration) * 60))) | int }}'
    color_temp: '{{ (float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(timestamp_sensor)) - as_timestamp(now())) /
    (float(sunrise_duration) * 60))) | int }}'
    * ((as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' '' ~ manual_time) - as_timestamp(now()))
    / (float(sunrise_duration) * 60))) | int }}'
    transition: '{{ tick_time | int }}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness_pct: '{{ (float(max_brightness) - (float(max_brightness) *
    (as_timestamp(states(timestamp_sensor)) - as_timestamp(now())) / (float(sunrise_duration)
    * 60))) | int }}'
    brightness_pct: '{{ (float(max_brightness) - (float(max_brightness)
    * (as_timestamp(states(timestamp_sensor) if timestamp_sensor != ''none'' else now().year ~ ''-'' ~ now().month ~ ''-'' ~ now().day ~ '' '' ~ manual_time) - as_timestamp(now())) /
    (float(sunrise_duration) * 60))) | int }}'
    transition: '{{ tick_time | int }}'
    entity_id: !input 'light_entity'
    mode: single
  24. sbyx revised this gist Dec 16, 2020. 1 changed file with 43 additions and 18 deletions.
    61 changes: 43 additions & 18 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -44,8 +44,8 @@ blueprint:
    mode: slider
    pre_sunrise_actions:
    name: Pre-sunrise actions
    description: Actions to run before sunrise starts (set e.g. a Delay with value
    00:00:00 if you don't want to do anything)
    description: Actions to run before sunrise starts. (optional)
    default: []
    selector:
    action: {}
    source_url: https://gist.github.com/sbyx/96c43b13b90ae1c35b872313ba1d2d2d
    @@ -67,11 +67,21 @@ action:
    < 60 * float(sunrise_duration) }}'
    - choose: []
    default: !input 'pre_sunrise_actions'
    - service: light.turn_on
    data:
    brightness_pct: 1
    color_temp: '{{ start_mired }}'
    entity_id: !input 'light_entity'
    - choose:
    - conditions:
    - condition: template
    value_template: '{{ state_attr(light_entity, ''min_mireds'') != None }}'
    sequence:
    - service: light.turn_on
    data:
    brightness_pct: 1
    color_temp: '{{ start_mired }}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness_pct: 1
    entity_id: !input 'light_entity'
    - repeat:
    while:
    - condition: template
    @@ -86,19 +96,34 @@ action:
    - condition: state
    entity_id: !input 'light_entity'
    state: 'on'
    - condition: template
    value_template: '{{ as_timestamp(states(timestamp_sensor)) != None }}'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor)) - as_timestamp(states(''sensor.date_time_iso''))
    < 60 * float(sunrise_duration) }}'
    sequence:
    - service: light.turn_on
    data:
    brightness_pct: '{{ (float(max_brightness) - (float(max_brightness) *
    (as_timestamp(states(timestamp_sensor)) - as_timestamp(now())) / (float(sunrise_duration)
    * 60))) | int }}'
    color_temp: '{{ (float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(timestamp_sensor)) - as_timestamp(now())) /
    (float(sunrise_duration) * 60))) | int }}'
    transition: '{{ tick_time | int }}'
    entity_id: !input 'light_entity'
    - choose:
    - conditions:
    - condition: template
    value_template: '{{ state_attr(light_entity, ''min_mireds'') != None }}'
    sequence:
    - service: light.turn_on
    data:
    brightness_pct: '{{ (float(max_brightness) - (float(max_brightness) *
    (as_timestamp(states(timestamp_sensor)) - as_timestamp(now())) / (float(sunrise_duration)
    * 60))) | int }}'
    color_temp: '{{ (float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(timestamp_sensor)) - as_timestamp(now())) /
    (float(sunrise_duration) * 60))) | int }}'
    transition: '{{ tick_time | int }}'
    entity_id: !input 'light_entity'
    default:
    - service: light.turn_on
    data:
    brightness_pct: '{{ (float(max_brightness) - (float(max_brightness) *
    (as_timestamp(states(timestamp_sensor)) - as_timestamp(now())) / (float(sunrise_duration)
    * 60))) | int }}'
    transition: '{{ tick_time | int }}'
    entity_id: !input 'light_entity'
    mode: single
    max_exceeded: silent
    max_exceeded: silent
  25. sbyx revised this gist Dec 16, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -101,4 +101,4 @@ action:
    transition: '{{ tick_time | int }}'
    entity_id: !input 'light_entity'
    mode: single
    max_exceeded: silent
    max_exceeded: silent
  26. sbyx revised this gist Dec 16, 2020. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -21,8 +21,8 @@ blueprint:
    device_class: timestamp
    sunrise_duration:
    name: Sunrise duration
    description: 'The sunrise will start the configured number of minutes before
    the timestamp.'
    description: The sunrise will start the configured number of minutes before
    the timestamp.
    default: 25
    selector:
    number:
    @@ -33,8 +33,7 @@ blueprint:
    mode: slider
    max_brightness:
    name: Maximum brightness
    description: 'The brightness will be transitioned from 1% to the configured
    percentage.'
    description: The brightness will be transitioned from 1% to the configured percentage.
    default: 100
    selector:
    number:
    @@ -87,6 +86,9 @@ action:
    - condition: state
    entity_id: !input 'light_entity'
    state: 'on'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor)) - as_timestamp(states(''sensor.date_time_iso''))
    < 60 * float(sunrise_duration) }}'
    sequence:
    - service: light.turn_on
    data:
    @@ -99,4 +101,4 @@ action:
    transition: '{{ tick_time | int }}'
    entity_id: !input 'light_entity'
    mode: single
    max_exceeded: silent
    max_exceeded: silent
  27. sbyx revised this gist Dec 16, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -81,7 +81,7 @@ action:
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor)) - as_timestamp(states(''sensor.date_time_iso''))
    < 60 * float(sunrise_duration) }}'
    sequence:
    - delay: '{{ tick_time | int }}'
    - delay: '{{ tick_time }}'
    - choose:
    - conditions:
    - condition: state
  28. sbyx revised this gist Dec 15, 2020. 1 changed file with 68 additions and 64 deletions.
    132 changes: 68 additions & 64 deletions wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -1,98 +1,102 @@
    blueprint:
    name: Wake-up light alarm with sunrise effect
    description: "A wake-up light alarm with a brightness and color temperature sunrise effect using an existing timestamp sensor as source. Requires date_time_iso sensor in configuration!"
    description: A wake-up light alarm with a brightness and color temperature sunrise
    effect using an existing timestamp sensor as source. Requires date_time_iso sensor
    in configuration!
    domain: automation
    input:
    light_entity:
    name: Wake-up light entity
    description: 'The light to control. Turning it off during the sunrise will keep it off. Color temperature range is auto-detected.'
    description: The light to control. Turning it off during the sunrise will keep
    it off. Color temperature range is auto-detected.
    selector:
    entity:
    domain: light
    timestamp_sensor:
    name: Alarm timestamp sensor
    description: 'Sensor with timestamp of next alarm (e.g. _next_alarm from companion app). Requires device_class: timestamp!'
    description: 'Sensor with timestamp of next alarm (e.g. _next_alarm from companion
    app). Requires device_class: timestamp!'
    selector:
    entity:
    device_class: timestamp
    sunrise_duration:
    name: Sunrise duration
    description: 'The sunrise will start the configured number of minutes before the timestamp. (suggestion: 25)'
    description: 'The sunrise will start the configured number of minutes before
    the timestamp.'
    default: 25
    selector:
    number:
    min: 5
    max: 60
    step: 5
    min: 5.0
    max: 60.0
    step: 5.0
    unit_of_measurement: min
    mode: slider
    max_brightness:
    name: Maximum brightness
    description: 'The brightness will be transitioned from 1% to the configured percentage. (suggestion: 100)'
    description: 'The brightness will be transitioned from 1% to the configured
    percentage.'
    default: 100
    selector:
    number:
    min: 5
    max: 100
    step: 1
    min: 5.0
    max: 100.0
    step: 1.0
    unit_of_measurement: '%'
    mode: slider
    pre_sunrise_actions:
    name: Pre-sunrise actions
    description: "Actions to run before sunrise starts (set e.g. a Delay with value 00:00:00 if you don't want to do anything)"
    description: Actions to run before sunrise starts (set e.g. a Delay with value
    00:00:00 if you don't want to do anything)
    selector:
    action: {}
    source_url: https://gist.github.com/sbyx/96c43b13b90ae1c35b872313ba1d2d2d
    variables:
    light_entity: !input light_entity
    timestamp_sensor: !input timestamp_sensor
    sunrise_duration: !input sunrise_duration
    max_brightness: !input max_brightness
    start_mired: "{{ state_attr(light_entity, 'max_mireds') }}"
    end_mired: "{{ state_attr(light_entity, 'min_mireds') }}"
    light_entity: !input 'light_entity'
    timestamp_sensor: !input 'timestamp_sensor'
    sunrise_duration: !input 'sunrise_duration'
    max_brightness: !input 'max_brightness'
    start_mired: '{{ state_attr(light_entity, ''max_mireds'') }}'
    end_mired: '{{ state_attr(light_entity, ''min_mireds'') }}'
    tick_time: '{{ float(sunrise_duration) * 0.6 * (100 / float(max_brightness)) }}'
    trigger:
    - platform: time_pattern
    minutes: "*"
    - platform: time_pattern
    minutes: '*'
    condition: []
    action:
    - wait_template: '{{ as_timestamp(states(timestamp_sensor)) != None }}'
    - wait_template: >-
    {{ 0 < as_timestamp(states(timestamp_sensor)) -
    as_timestamp(states('sensor.date_time_iso')) < 60 *
    float(sunrise_duration) }}
    - choose: []
    default: !input pre_sunrise_actions
    - service: light.turn_on
    data:
    brightness_pct: 1
    color_temp: '{{ start_mired }}'
    entity_id: !input light_entity
    - repeat:
    while:
    - condition: template
    value_template: '{{ as_timestamp(states(timestamp_sensor)) != None }}'
    - condition: template
    value_template: >-
    {{ 0 < as_timestamp(states(timestamp_sensor)) -
    as_timestamp(states('sensor.date_time_iso')) < 60 *
    float(sunrise_duration) }}
    sequence:
    - delay: '00:00:05'
    - choose:
    - conditions:
    - condition: state
    entity_id: !input light_entity
    state: 'on'
    sequence:
    - service: light.turn_on
    data:
    brightness_pct: >-
    {{ (float(max_brightness) - (float(max_brightness) *
    (as_timestamp(states(timestamp_sensor)) -
    as_timestamp(now())) /
    (float(sunrise_duration) * 60))) | int }}
    color_temp: >-
    {{ (float(end_mired) + (float(start_mired) - float(end_mired)) *
    ((as_timestamp(states(timestamp_sensor)) -
    as_timestamp(now())) /
    (float(sunrise_duration) * 60))) | int }}
    entity_id: !input light_entity
    - wait_template: '{{ as_timestamp(states(timestamp_sensor)) != None }}'
    - wait_template: '{{ 0 < as_timestamp(states(timestamp_sensor)) - as_timestamp(states(''sensor.date_time_iso''))
    < 60 * float(sunrise_duration) }}'
    - choose: []
    default: !input 'pre_sunrise_actions'
    - service: light.turn_on
    data:
    brightness_pct: 1
    color_temp: '{{ start_mired }}'
    entity_id: !input 'light_entity'
    - repeat:
    while:
    - condition: template
    value_template: '{{ as_timestamp(states(timestamp_sensor)) != None }}'
    - condition: template
    value_template: '{{ 0 < as_timestamp(states(timestamp_sensor)) - as_timestamp(states(''sensor.date_time_iso''))
    < 60 * float(sunrise_duration) }}'
    sequence:
    - delay: '{{ tick_time | int }}'
    - choose:
    - conditions:
    - condition: state
    entity_id: !input 'light_entity'
    state: 'on'
    sequence:
    - service: light.turn_on
    data:
    brightness_pct: '{{ (float(max_brightness) - (float(max_brightness) *
    (as_timestamp(states(timestamp_sensor)) - as_timestamp(now())) / (float(sunrise_duration)
    * 60))) | int }}'
    color_temp: '{{ (float(end_mired) + (float(start_mired) - float(end_mired))
    * ((as_timestamp(states(timestamp_sensor)) - as_timestamp(now())) /
    (float(sunrise_duration) * 60))) | int }}'
    transition: '{{ tick_time | int }}'
    entity_id: !input 'light_entity'
    mode: single
    max_exceeded: silent
  29. sbyx revised this gist Dec 15, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,7 @@ blueprint:
    min: 5
    max: 100
    step: 1
    unit_of_measurement: %
    unit_of_measurement: '%'
    pre_sunrise_actions:
    name: Pre-sunrise actions
    description: "Actions to run before sunrise starts (set e.g. a Delay with value 00:00:00 if you don't want to do anything)"
  30. sbyx revised this gist Dec 15, 2020. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion wake-up-light-alarm-with-sunrise-effect.yaml
    Original file line number Diff line number Diff line change
    @@ -24,6 +24,15 @@ blueprint:
    max: 60
    step: 5
    unit_of_measurement: min
    max_brightness:
    name: Maximum brightness
    description: 'The brightness will be transitioned from 1% to the configured percentage. (suggestion: 100)'
    selector:
    number:
    min: 5
    max: 100
    step: 1
    unit_of_measurement: %
    pre_sunrise_actions:
    name: Pre-sunrise actions
    description: "Actions to run before sunrise starts (set e.g. a Delay with value 00:00:00 if you don't want to do anything)"
    @@ -34,6 +43,7 @@ variables:
    light_entity: !input light_entity
    timestamp_sensor: !input timestamp_sensor
    sunrise_duration: !input sunrise_duration
    max_brightness: !input max_brightness
    start_mired: "{{ state_attr(light_entity, 'max_mireds') }}"
    end_mired: "{{ state_attr(light_entity, 'min_mireds') }}"

    @@ -74,7 +84,7 @@ action:
    - service: light.turn_on
    data:
    brightness_pct: >-
    {{ (100 - (100 *
    {{ (float(max_brightness) - (float(max_brightness) *
    (as_timestamp(states(timestamp_sensor)) -
    as_timestamp(now())) /
    (float(sunrise_duration) * 60))) | int }}