Repeat actions until an event fired

Firing of a deconz event triggers my automation, no problem.
I need that automation to repeat until another (seperate) event is fired on the event bus.
Can I achieve this with something like the below? I need help with the syntax if it is possible.
If this will not work any other ideas please?

- alias: "Bedside dim up"
  trigger:
    - platform: event
      event_type: deconz_event
      event_data:
        id: bedside_switch
        event: 1001
  action:
    - alias: "Repeat the sequence UNTIL stop event occurs"
      repeat:
        sequence:
            #actions go here
        until:
          - condition: ????
               ????

the second event will be:

{
    "event_type": "deconz_event",
    "data": {
        "id": "bedside_switch",
        "unique_id": "",
        "event": 1003,
        "device_id": "ff9a8"
    },
    "origin": "REMOTE",
    "time_fired": "+00:00",
    "context": {
        "id": "4eb5b",
        "parent_id": null,
        "user_id": null
    }
}

There is no event condition. You may have to use another automation that listens for the second event and sets an input boolean. This can then be used in your first automation repeat until state condition. Don’t forget to reset the input boolean after the repeat loop finishes in your first automation.

Thanks Tom - I had that in mind as my backup option - but not as elegant as I would like.
I’ll also look to add an incremental counter in there to stop an infinite loop.

You can put a wait_for_trigger inside a repeat loop to accomplish this. Here is snippet of a working example.

    - repeat:
        until: "{{ wait.trigger is not none or repeat.index >= 10 }}"
        sequence:
          - service: system_log.write
            data:
              message: "Holding {{ button_name }} button..."
          - wait_for_trigger:
              platform: event
              event_type: zwave_js_value_notification
              event_data:
                device_id: "{{ trigger.event.data.device_id }}"
                property_key: "{{ trigger.event.data.property_key }}"
            timeout:
              milliseconds: 1000
6 Likes

Amazing, @MizterB - it works perfectly!!