Message malformed error when trying to incorporate action field in script

Hi,
I’m currently trying to create a new script with a duration and an action input field. The purpose of the script is to carry out a custom action only when the knx interface on my home assistant instance is available. If it is not available, it waits for it to become available or until the defined timeout occurs. If the action could not be carried out, the script stops with an error.

The reason why I am doing this is that I am currently modifying my knx configuration a lot and then need to reload it, which causes the knx integration to become unavailable for a short period of time. This is therefore an attempt at trying to harden my automations against these knx integration reloads. The idea is to simply call this script and put the desired action inside of it like some kind of wrapper.

The issue with the script is that I don’t know how to incorporate the action field in the if-else sequence below. No matter what I try, I always get the following error:

Message malformed: Unable to determine action @ data['sequence'][1]['then'][0]

How can I get this to work? This is the script in question:

alias: KNX action wrapper
icon: mdi:package-variant
mode: parallel
max: 32
fields:
  duration:
    selector:
      duration: {}
    name: Duration
    default:
      hours: 0
      minutes: 5
      seconds: 0
  action:
    selector:
      action: {}
    name: Action
    required: true
    default: []
sequence:
  - wait_template: >-
      {{ (not is_state('sensor.knx_interface_connected_since', 'unavailable'))
      and (not is_state('sensor.knx_interface_connected_since', 'unknown'))}}
    continue_on_timeout: true
    timeout: "{{ duration }}"
  - if:
      - condition: template
        value_template: >-
          {{ (not is_state('sensor.knx_interface_connected_since',
          'unavailable')) and (not
          is_state('sensor.knx_interface_connected_since', 'unknown'))}}
    then: >-
     {{ action }}
    else:
      - stop: >-
          Unable to execute action as KNX bus is currently unavailable or its
          state unknown
        error: true