Sunset Light transition - IF ELSE for CallService in Automation

hi,

i´m trying to make an ligth-alarm-clock, what should simulate an “sunrise”. So two lights should dim brigthness from 0 to 255 over 30minutes.

i have included an input_boolean as an so called “mainswitch” to activate/deactivate the automation…
my automation still works, when triggered.

but now i want to set light to off, when switching off my mainswitch and/or when a schedule-state changes to off, cleanout the condition section, and bring any “if else” condition to the action section, with an templateing like i had done successfully in another automation. Now i realized this was in a in data section only, what seems quit easy, but does not work here?
but how could i achive any “if else” condition to choose the action itself service: light.turn_on, or service: light.turn_off?
could anybody pls help me?
thank you in advance
br
Frank

alias: aTest_Lichtwecker_nous
description: ""
trigger:
  - platform: state
    entity_id:
      - schedule.lichtwecker
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 1
  - platform: state
    entity_id:
      - input_boolean.lichtwecker_mainswitch
    from: null
    to: "off"
condition:
  - condition: state
    entity_id: input_boolean.lichtwecker_mainswitch
    state: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 0
action:
  - service: light.turn_on
    data:
      brightness: 1
    target:
      entity_id:
        - light.nous_bb_93
        - light.nous_bb_94
  - repeat:
      sequence:
        - service: light.turn_on
          data:
            entity_id: light.nous_bb_93
            brightness: "{{ state_attr('light.nous_bb_93', 'brightness') | int(0) + 2 }}"
          enabled: true
        - service: light.turn_on
          data:
            entity_id: light.nous_bb_94
            brightness: "{{state_attr('light.nous_bb_94', 'brightness') | int(0) + 2 }}"
          enabled: true
        - delay:
            hours: 0
            minutes: 0
            seconds: 14
            milliseconds: 118
        - condition: numeric_state
          entity_id: light.nous_bb_93
          attribute: brightness
          below: 255
          above: 255
      until:
        - condition: or
          conditions:
            - condition: template
              value_template: "{{ state_attr('light.nous_bb_93', 'brightness') | int >=254 }}"
mode: restart
initial_state: "on"