Is there a way to have triggers timeout?

I want to be able to toggle a light switch 3 times on and off to open my garage door. But, if I dont do the 3 times in under 20 seconds I want it to timeout so its not saving these for when I hit the 3 and opens my garage door at some odd time.

what switch is it? Zigbee? ZHA or z2m?

Use a wait_for_trigger with timeout set to true.

Its a TP Link Kasa wifi switch

Thanks for this info. I tried it but it still seems to trigger randomly. I may be doing something else wrong. Not sure this is worth the trouble. Thanks though!!

Share your automation config (correctly formatted).

Have you listened to events when you press the switch? does it send a different even when you click once and when you click 3 times? If it sends the same message, one way I can think of achieving this in YAML

Create a counter:

    initial: 0
    minimum: 0
    maximum: 3

Then this automation should work. Never tried it and cannot test it though, be prepared to debug. Note restart mode.

  mode: restart
  - service: counter.increment
    entity_id: counter.YOUR_COUNTER
  - choose:
    - conditions:
      - condition: state
        entity_id: counter.YOUR_COUNTER
        state: 3
      - service: counter.reset
        entity_id: counter.YOUR_COUNTER
      - service: OPEN YOUR GARAGE HERE
    - delay: '00:00:02'  # I know you said 20 seconds but 2 seconds is more than enough for 3 clicks. Change it at will.
    - service: counter.reset
      entity_id: counter.YOUR_COUNTER

To achieve the same using the GUI

Note restart:

Action section:

Hi, I believe you wanted to set initial and maximum, as with step 3 it actually will jump to 3 then 6 then 9 and so on for every increment action.

Hey Tom, I deleted and recreated the Automation and it seems to be working for the most part. Not sure what I had messed up but I appreciate your help! Thanks Again!!

Hey Obaldius,
I recreated the automation and it seems to be working well so far. Not sure what I had messed up in the original but had changed so many things trying to get it working so who knows. I did create a counter and will use your method if this automation doesn’t seem reliable. I appreciate your time helping with this!!!

1 Like

I suggest using the history stats sensor.

Set it to:

state: "on"
type: count
start: {{ now().timestamp() -20 }}
end: {{ now() }}

This should give you the count of times the light has been on the last 20 seconds.

EDIT: I see now that “3 times on and off” has also been interpreted as on-off-on, where as I read it as on-off-on-off-on

you are totally right, thanks, I fixed it.