Help with if/then/else in script

Hi,

I’m trying to write a script for my garage door, which should do a specific sequence of actions if the door is partially open and last movement direction was opening.
Otherwise it should just send the impulse.

This is what I have so far:

garage_auf:
  alias: Garage Öffnen
  sequence:
    if:
      - condition: and
        conditions:
        - condition: state
          entity_id: sensor.garagentor_up_down
          state: '2.0'
        - condition: state
          entity_id: input_number.garagentor_letzte_richtung
          state: '3.0'
    then:  
      repeat:
        count: '3'
        sequence:
        - service: switch.turn_on
          data: {}
          target:
            entity_id: switch.garagentor
        - delay:
            hours: 0
            minutes: 0
            seconds: 3
            milliseconds: 0
    else:
      sequence:
      - service: switch.turn_on
        data: {}
        target:
          entity_id: switch.garagentor
  mode: single
  icon: mdi:garage-open

The if/then part works, but in the else part I get an error:
Script with alias 'Garage Öffnen' could not be validated and has been disabled: Unable to determine action @ data['sequence'][0]['else'][0]. Got None

After 30 minutes of trial and error, because I absolutely don’t know what’s wrong, I give up and hope someone can help me.

There is no sequence in that section, hence the error.

If you are interested, here’s a way to do it without employing if-then.

garage_auf:
  alias: Garage Öffnen
  sequence:
    - variables:
        iterations: >
          {{ 3 if states('sensor.garagentor_up_down')|int(0) == 2
            and states('input_number.garagentor_letzte_richtung')|int(0) == 3
            else 1 }}
    - repeat:
        count: '{{ iterations }}'
        sequence:
          - service: switch.turn_on
            target:
              entity_id: switch.garagentor
          - delay:
              seconds: 3
  mode: single
  icon: mdi:garage-open

There is no sequence means what?

I can’t do anything there?
I can just have an “action”?

The Syntax article states:
This action allow you to conditionally (if) run a sequence of actions (then) and optionally supports running other sequence when the condition didn’t pass (else).

Look at the link to the docs?

    else:
      - service: switch.turn_on

that’s how it should look, not how you had it

Thank you,
from the docs, as stated it wasn’t clear, that it could not have a sequence there - at least not for me…