Blueprint to count trigger

I try to set up a blueprint to count trigger in a given time. I want to detect if some of my switches are pressed multiple times within a time.

This is my try so far:

blueprint:
  name: "Count trigger"
  domain: automation
  description: ""

  # INPUTS
  input:

    # trigger
    in_Trigger:
      name: "Auslöser"
      selector:
        trigger:

    # time
    in_TimeAcceptInput:
      name: "Zeit nächster Auslöser akzeptiert"
      selector:
        duration:
          enable_millisecond: true
      default:
        milliseconds: 500

# TRIGGER
trigger: !input in_Trigger

# ACTIONS
actions:
  - repeat:
      until: "{{ false }}"
      sequence:
        - wait_for_trigger: !input in_Trigger
          timeout: !input in_TimeAcceptInput
        - if: "{{ not wait.completed }}"
          then:
            # debug
            - action: script.notify_devices
              data:
                devices:
                  - thomas
                title: "Count: {{ repeat.index }}"
            #### stop automation/exit loop?

# MODE
mode: single
max_exceeded: silent

I know it’s possible to use a external helper to leave the loop, but I think it’s not very practical if I have to create a helper for every button.

I also know I can stop a script with

- action: script.turn_off
  target:
    entity_id: "{{ this.entity_id }}"

But I can’t pass a trigger to a script, right? So I would have to set up a script and a automation for every button (what is not better than automation and helper).

Is there a better way to do this? Thanks for you’r help :slight_smile:

Background

I’m switching from ZHA to zigbee2mqtt. I have multiple of the HUE dimmer switches. With ZHA it provides e.g. the function remote_button_double_press. But with zigbee2mqtt not.
I am using this function and want it to use also for other buttons (not HUE). So my idea was to implement it myself with a blueprint.

I can’t quite understand what your actual question is, but if it is how you may break out of the loop… simply set until to the exact same condition you already have for the if?

until: "{{ not wait.completed }}"

I thought I had tested this and it didn’t work :sweat_smile:
Obviously I did something wrong, this is working fine now :smiley: