Script not working as expected when called from an Automation

I have a Script that turns on all of the lights and—for the ones that are dimmable—it gradually increases them from 1 to 255 and then stops.

alias: Fade On 2nd Floor Lights Group
sequence:
  - variables:
      start_brightness: 1
      end_brightness: 255
      brightness_increments: 3
      duration_mins: 1
      repeat_count: "{{ ((end_brightness - start_brightness) / brightness_increments) }}"
      repeat_delay: "{{ ((duration_mins * 60) / repeat_count) }}"
  - service: light.turn_on
    data:
      brightness: "{{ start_brightness }}"
    target:
      entity_id: light.2nd_floor_light_group
  - delay:
      hours: 0
      minutes: 0
      seconds: "{{ repeat_delay | int }} "
      milliseconds: 0
  - repeat:
      while:
        - condition: template
          value_template: >-
            {{ (state_attr('light.2nd_floor_light_group', 'brightness') <
            end_brightness) }}            
      sequence:
        - service: light.turn_on
          data:
            brightness: >-
              {{ state_attr('light.2nd_floor_light_group', 'brightness') | int +
              brightness_increments }}
          entity_id:
            - light.2nd_floor_light_group
        - delay:
            hours: 0
            minutes: 0
            seconds: "{{ repeat_delay | int }} "
            milliseconds: 0
mode: parallel
icon: mdi:lightbulb-multiple
max: 10

As long as I run it as a script, it works perfectly.

I am trying to call it from an Automation:

alias: " + When the time is equal to entity Input > Wake up time"
description: ""
trigger:
  - platform: time
    at: input_datetime.wake_up_time
condition: []
action:
  - service: script.fade_on_2nd_floor_lights_group
    data: {}
mode: parallel

When the Automation runs it only partially works. The non-dimmable lights turn on, the dimmable ones do not. According to the Traces, HA thinks it turned on the dimmable bulbs, but it did not.

Call a service 'Script: Fade On 1st Floor Lights Group' on

Fade On 1st Floor Lights Group (script.1701187248370) started
(script.1701187248370) turned on

(switch.wyze_cam_can_cam_power) turned off
(switch.bedroom_power_strip_02_usb_1) turned on
(light.turtle_lamp) turned on
(light.2nd_floor_light_group) turned on
(light.stairwell_overhead_02) turned on
(light.stairwell_overhead_lights) turned on
(switch.fairy_lights) turned on
(light.fairy_lights) turned on
(light.bedroom_table_lamp) turned on
(light.spare_bedroom_overhead) turned on
(light.corner_lamp) turned on
(switch.chest_lamp_socket_1) turned on
(light.stairwell_overhead_01) turned on
(light.chest_lamp) turned on

Do you have any lights that are in both groups, like a stairwell light?

You’ve shown us the “Fade On 2nd” script, but not the “Fade On 1st” script, and I don’t see another script invoked from the automation — unless you have two separate automations.

Sorted. Thanks for your reply.