Wake-up light automation not good working

Hi, i have made a wake-up light automation

The automation is triggered by a state change of the sensor.wekker_minus_10_minutes
First turn on the rgb light with a red color and low brightness.

Then repeat a sequence of actions 30 times, each time increasing the brightness and changing the color of the light. This creates the gradual wake-up effect.
Add a delay of 20 seconds after the final step of the sequence. This is to ensure that the light remains on for a little while after it has reached maximum brightness.

Overall, this automation must simulates a sunrise by gradually increasing the brightness and changing the color of a light entity over a period of 30 minutes, starting from a low red color and ending with a bright, warm white color.

But the automation stops for me at 14% on a green light. what am I not doing quite right yet?

alias: wake-up light
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.wekker_minus_10_minutes
condition: []
action:
  - service: light.turn_on
    data:
      brightness_pct: 1
      rgbw_color:
        - 255
        - 0
        - 0
        - 0
    target:
      entity_id: light.lightstrips_1
  - repeat:
      count: "30"
      sequence:
        - service: input_number.set_value
          data:
            entity_id: input_number.wake_up_light
            value: "{{ (range(26)|list)[states('input_number.wake_up_light')|int] }}"
        - delay:
            hours: 0
            minutes: 0
            seconds: 20
            milliseconds: 0
        - service: light.turn_on
          data_template:
            entity_id: light.lightstrips_1
            brightness: "{{ ((states('input_number.wake_up_light')|int+1)*100)/30 }}"
            rgb_color:
              - >-
                {{ 255 - ((states('input_number.wake_up_light')|int+1)*255)//30
                }}
              - >-
                {{ 200 - ((states('input_number.wake_up_light')|int+1)*100)//30
                }}
              - 0
  - delay:
      hours: 0
      minutes: 0
      seconds: 20
      milliseconds: 0
mode: single

Why range(26)? If you use range(30) it should work — certainly seems to in the template editor:

{% for i in range(30)|list %}
step: {{ i -}}
; brightness: {{ (((i|int+1)*100)/30) |round(2) -}}
; red {{ 255 - ((i|int+1)*255)//30 -}}
; green {{ 200 - ((i|int+1)*100)//30 -}}
{% endfor %}

Although I wouldn’t call [0, 100, 0] “warm white”, more a sort of “jungle green”…

I think there’s probably an easier way to do the loop than with the input_number. Script Syntax - Home Assistant

I see, i have set the count not good. and that is right it is jungle green instead of warm white color. I hadn’t thought that I can check it in the template editor :grin:

@Troon i have made this script:

sequence:
  - service: light.turn_on
    target:
      entity_id: light.{{ light }}
    data:
      brightness: 10
  - repeat:
      count: 30
      sequence:
        - delay: "00:01:00"
        - service: light.turn_on
          target:
            entity_id: light.{{ light }}
          data:
            brightness: "{{ ((loop.index * 100) / 30)|int }}"
  - repeat:
      count: 30
      sequence:
        - delay: "00:01:00"
        - service: light.turn_on
          target:
            entity_id: light.{{ light }}
          data:
            brightness: "{{ ((30 - loop.index) * 100) / 30|round(0) }}"
alias: Wake up light
mode: single

with this automation:

alias: Wake up light final
description: ""
trigger:
  - platform: sun
    event: sunset
    offset: "-01:00:00"
  - platform: state
    entity_id:
      - sensor.wekker_minus_10_minutes
condition: []
action:
  - service: script.turn_on
    data:
      light: lightstrips_1
    target:
      entity_id: script.nieuw_script
mode: single

but i get these error: extra keys not allowed @ data[‘light’]. Got None why can i not pass the variable ?

Because data requires your variables to be specified under variables.

action:
  - service: script.turn_on
    data:
      variables:
        light: 'lightstrips_1'
    target:
      entity_id: script.nieuw_script

Reference: Passing variables to scripts

can you help me futher, the automation is working but the light is not increasing the brightness

You’re using brightness: and applying a scale of 0-100, when brightness is 0-255.

Use brightness_pct: if you want to use 0-100.

Also, you now have 2 loops, one increasing the brightness, another decreasing it.

Is this what you intended ? Its not mentioned in your original post.

No, only increasing and stay on when the brightness 100%

Are you using ChatGPT to produce this, or randomly copy/pasting stuff that looks similar to what you want? There’s no way you could have written that script above thinking that it would do that.

Paste the latest status of your script and describe exactly what you want it to do.