Ignore trigger if followed rapidly by another trigger?

I’m very new to HA so apologies if this is easy. I did try to find an existing question but couldn’t find one that deals with this particular logic.

I want to perform the following:

If <trigger x> occurs then
    wait 20 seconds to see if <trigger y> occurs
    if <trigger y> did occur then
        do nothing
    else
        do stuff

I think it’s quite easy if “do nothing” and “do stuff” were the other way around - I could use a wait template and not continue on timeout. But how do I continue on timeout, but not continue if occurred?

You can do that with a condition which checks if a timer is running in an automation.
When you get the trigger 1 of the actions will be to start a timer, from the GUI you can pick a timer entity or create a helper in which you will set the duration.

Then the condition would be to check the state of the timer entity or helper if its idle

Something like:

description: "block for 10sec"
mode: single
triggers:
  - trigger: state
    entity_id:
      - "your trigger"
    to: "on"
conditions:
  - condition: state
    entity_id: timer.helper_timer
    state: idle
actions:
  - action: timer.start
    metadata: {}
    data: {}
    target:
      entity_id: timer.helper_timer
  - action: whatever you want todo

Just an example, best to create it in the GUI in automations.

Ah that makes sense - thank you kindly.

A wait for trigger action sets the wait variable when it completes. You can use this variable in a subsequent if/then action (with a template)