Abort Automation Pattern

I am trying to implement the following pattern in an automation;

WHEN a trigger signal is received
WAIT a set period of time
THEN perform an action
UNLESS an abort signal is received during the wait period

I can achieve this fairly easily in Node-RED using a timer node paired with a change node to stop the timer and cancel all downstream nodes.

How would one achieve this in a YAML based automation?

Depends on what your abort signal is and I can think of a dozen ways (well 5) off the top of my head.
Some are more elegant than others so I’ll just mention the most ham fisted to start (this won’t actually work either if the automation has entered the action phase) turn the automation off. (don’t do it it won’t work)

So there is a ‘for’ option
So trigger entity light going on (say)
For 10 minutes
Well if the light goes off, the trigger collapses and the action won’t happen

The next is when the abort signal is not the trigger going off
Still run the trigger and for
But then put in a condition on your abort signal

The next says the trigger is momentary and isn’t on for 10 minutes
Put your delay in a script called from the automation action with the actual instructions in the script after the delay
Abort signal cancels the script

You didn’t give any entity ids of triggers, sample outputs or abort entities so can’t flesh it out more than that

Please note that is is all very simple and standard stuff as there is not a template in sight