Ratgdo automation help

I would like some help creating a automation for my ratdo that automatically closes the door 30 minutes after opening or after the obstruction sensor is triggered, whichever happens last.

So if I open the door and nobody walks in or out of the garage, the garage door will close 30 minutes later. But lets say 5 minutes after opening the door, I trip the obstruction sensor, the 30 minute timer restarts and if nothing trips the obstruction sensor again, it will close 35 minutes after first opening.

Thanks in advance!

Use a timer helper. When either situation occurs, start/restart the timer depending on the timer’s current status.

Another automation that closes the door when the timer finishes.

You could certainly do it all in one automation with trigger ids.