Morning lights automation

In case there wasn’t enough morning lights automation question topics, here’s another one! I’ve looked through several of them and haven’t found a good example of what I’m seeing.

I have the code below set to slowly increase brightness and temperature of a set of lights over 30 minutes (the delay in the code below is normally one minute, it’s set to two seconds for testing). When it runs, it seems to make it through the first few loops, but then gets hung up. The traces are odd too — quickly turning into a stack of “Light turn on…” near the top and “Delay for…” at the bottom, with no “Set Variable” entries beyond the initial one before the repeat block. It also takes way longer to complete than expected — the test I ran before making this, with a two-second delay meaning it should have finished in one minute, is “Still running” 15 minutes later.

alias: Bedroom Lights, 6:00 Weekday Sunrise
description: ""
triggers:
  - trigger: time
    at: "06:00:00"
conditions:
  - condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
actions:
  - variables:
      temp: 2720
      brightness: 10
  - repeat:
      count: 31
      sequence:
        - action: light.turn_on
          metadata: {}
          data:
            color_temp_kelvin: "{{ temp }}"
            brightness_pct: "{{ brightness }}"
          target:
            entity_id: light.bedroom_lights
        - variables:
            temp: "{{ temp + 126 }}"
            brightness: "{{ brightness + 3 }}"
        - delay:
            hours: 0
            minutes: 0
            seconds: 2
            milliseconds: 0
mode: single

Some lights has transition.
That would be what you did here

Apologies, but I’m not entirely following what you’re saying.

You turn on the light at a low setting.
Then you use the transition and set a time and a higher brightness.

What version of HA are you on? There has been changes to variables scope not that long ago.

I’m on the latest stable release.

Ah, I see. Unfortunately my lights don’t appear to have this.

Seem to have figured it out - targeting my bedroom lights group wasn’t working correctly, but targeting the individual entities does. Also tweaked the script to remove the variables bits, although I expect the original script would have worked with the change in targeted entities as well.

alias: Bedroom Lights, 6:00 Weekday Sunrise
description: ""
triggers:
  - trigger: time
    at: "06:00:00"
conditions:
  - condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
actions:
  - repeat:
      count: 31
      sequence:
        - action: light.turn_on
          metadata: {}
          data:
            color_temp_kelvin: "{{ (repeat.index - 1) * 126 + 2720 }}"
            brightness_pct: "{{ (repeat.index - 1) * 3 + 10 }}"
          target:
            entity_id:
              - light.bedroom_left
              - light.bedroom_right
        - delay:
            hours: 0
            minutes: 1
            seconds: 0
            milliseconds: 0
mode: single