Repeat until automation with mqtt Ikea switch falls in endless loop

Hi, I’m trying to manage long click on Tradfri E1743 to move up/down mqtt light brightness.
On long click the brightness moves up but on button release the until condition is not fired and the mqtt.publih service holds in endless loop. Also moving to while loop the result is the same
Is there any chance to reach my goal? Thanks

- alias: Switch Ikea Brightness up
  trigger:
    platform: state
    entity_id: sensor.switch_ikea_action
    to: 'brightness_move_up'

  action:
    - alias: move brightness up
      repeat:
        sequence:
          - service: mqtt.publish
            data_template:
              topic: 'zigbee2mqtt/my_light/set'
              payload: >-
                {
                 "brightness_step": 20
                } 
        until: 
          - condition: state
            entity_id: sensor.switch_ikea_action
            state: 'brightness_stop'
1 Like

For anyone interested, found solution adding delay

- alias: Switch Ikea Brightness up
  trigger:
    platform: state
    entity_id: sensor.switch_ikea_action
    to: 'brightness_move_up'

  action:
    - alias: move brightness up
      repeat:
        sequence:
          - service: mqtt.publish
            data_template:
              topic: 'zigbee2mqtt/my_light/set'
              payload: >-
                {
                 "brightness_step": 20
                } 
          - delay:
                milliseconds: 200
        until: 
          - condition: state
            entity_id: sensor.switch_ikea_action
            state: 'brightness_stop'