Dimm a hue light up and down with long press of fibaro dimmer

Hi, I tried to make an automation to dim a hue light with a fibaro dimmer which acts sollely as a remote. It should do the following:

1: long press key 1 > the hue light should brighten until release of the key.
2. the next time the key is long pressed the hue light should dim until release.
3. the next time the key is long pressed the hue light should brighten.
4. and so on…

I made an automation which should switch between 2 option based on a toggle switch which is set on or off based on the option which is executed. But somehow I can’t make it work.

alias: 'Light: Dim one light until release (Duplicate)'
description: ''
trigger:
  - platform: device
    device_id: 80bb47cd550fa2d7f660000337fab85a
    domain: zwave_js
    type: event.value_notification.scene_activation
    property: sceneId
    property_key: null
    endpoint: 0
    command_class: 43
    subtype: Endpoint 0
    id: key-hold
    value: 12
  - platform: device
    device_id: 80bb47cd550fa2d7f660000337fab85a
    domain: zwave_js
    type: event.value_notification.scene_activation
    property: sceneId
    property_key: null
    endpoint: 0
    command_class: 43
    subtype: Endpoint 0
    id: key-released
    value: 13
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.dimmer_keuken_state
            state: 'on'
        sequence:
          - repeat:
              while:
                - condition: trigger
                  id: key-hold
              sequence:
                - service: light.turn_on
                  data:
                    brightness_step_pct: 5
                  target:
                    entity_id: light.signify_netherlands_b_v_lwo001_ad7feb08_level_on_off
                - delay:
                    hours: 0
                    minutes: 0
                    seconds: 0
                    milliseconds: 50
      - conditions:
          - condition: state
            entity_id: input_boolean.dimmer_keuken_state
            state: 'off'
        sequence:
          - repeat:
              while:
                - condition: trigger
                  id: key-hold
              sequence:
                - service: light.turn_on
                  data:
                    brightness_step_pct: -5
                - delay:
                    hours: 0
                    minutes: 0
                    seconds: 0
                    milliseconds: 50
    default: []
  - service: input_boolean.toggle
    data: {}
    target:
      entity_id: input_boolean.dimmer_keuken_state
mode: restart