Perform an automation as long as a button is pressed

Hi everyone,

I am looking for a way how I can perform a certain task as long as a button is pressed. In my case, I do have some HA controllable shutters and some Ikea switches (soon to be replaced by a wall mounted zigbee switch). Now I want the shutter to roll up/down as long as the up/down button is pressed on the Zigbee switch. All switches are connected via MQTT and the shutters are connected via the HomePilot integration and the commnunication between them works fine too.

What I’m struggerling with is the way the automation is supposed to work. I tried to implement this by having 3 invidual automations, one automation for pulling the shutter up when the up button is pressed, one automation to let the shutter down when the down button is pressed and a third automation to stop the shutter as soon as the no button is pressed (stop) action is fired from the button.

This is what the up automation looks like:

alias: EG Gartenfenster Rolladen Hoch
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.schalter_4_wege_action
    to: brightness_move_up
condition: []
action:
  - device_id: 599fd1ab3c698fac252c329c3ffba8a9
    domain: cover
    entity_id: b345bef1bb6d12210ed28857a4a2ba6b
    type: open
mode: single

This is what the stop automation looks like

alias: EG Gartenfenster Rolladen Stop
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.schalter_4_wege_action
    to: brightness_stop
condition: []
action:
  - device_id: 599fd1ab3c698fac252c329c3ffba8a9
    domain: cover
    entity_id: b345bef1bb6d12210ed28857a4a2ba6b
    type: stop
mode: single

This in itself works fine but when I press the button and let go, I can see that the automation cannot start again until a certain time passed. From the screenshot we can see that the column Last triggered says in 5 seconds (not xyz seconds ago).

This actually means that the automation cannot be started again until this timeout passed and with the stop animation running after the button press was released it is even possible to keep the button pressed a couple of times in a short timeframe and end up having the stop automation never triggered (because e.g. the shutter up automation was triggered twice but the second stop automation was still in cooldown when the stop trigger was sent and is never executed). Is there any way to remove this cooldown / debounce somewhere?

I looked at the automation documentation and also searched the web for debouncing, cooldown and timeouts for automations but couldn’t find out where this even comes from. Is this something that is configured globally for all automations?

And is this approach even advised for what I want to do? :sweat_smile:

Your help is very much appreciated :pray:

There is no de-bouncing. There is something wrong with your system clock. Last triggered should never be in the future.