How to repeat an action until another (specific) device trigger is received

@ sergimola

Did you have any luck figuring this out?

Thanks to this thread I managed to make the IKEA STYRBAR TRÅDFRI remote control to change the brightness continuously:

alias: CCT2 brightness
description: ""
trigger:
  - platform: device
    domain: mqtt
    device_id: 158e091f98b38d8c47cf01cd5c376c50
    type: action
    subtype: brightness_move_up
    discovery_id: 0x60c647fffe5ffefb action_brightness_move_up
    id: _brightness_move_up
  - platform: device
    domain: mqtt
    device_id: 158e091f98b38d8c47cf01cd5c376c50
    type: action
    subtype: brightness_move_down
    discovery_id: 0x60c647fffe5ffefb action_brightness_move_down
    id: _brightness_move_down
  - platform: device
    domain: mqtt
    device_id: 158e091f98b38d8c47cf01cd5c376c50
    type: action
    subtype: brightness_stop
    discovery_id: 0x60c647fffe5ffefb action_brightness_stop
    id: _brightness_stop
condition: []
action:
  - variables:
      command: "{{ trigger.payload }}"
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ command == 'brightness_move_up' }}"
        sequence:
          - repeat:
              until:
                - condition: trigger
                  id: _brightness_stop
              sequence:
                - service: light.turn_on
                  data:
                    entity_id: light.cct2_ledcct
                    brightness_step_pct: 5
                    transition: 0.3
                - delay: "0.3"
      - conditions:
          - condition: template
            value_template: "{{ command == 'brightness_move_down' }}"
        sequence:
          - repeat:
              until:
                - condition: trigger
                  id: _brightness_stop
              sequence:
                - service: light.turn_on
                  data:
                    entity_id: light.cct2_ledcct
                    brightness_step_pct: -5
                    transition: 0.3
                - delay: "0.3"
mode: restart

I reused the device_id and discovery_id (modified here) as created by the visual designer when creating single push triggers. I suppose that simpler identifiers can be used, but I am just too tired of this obscure HA alchemy and happy it is finally working.

Now just to find some solution to change the color temperature too…