Cancelling an automation

I use frigate to determine if a person is present in a room . Sometimes it’s a bit quick to suggest they are not .
This causes the issue that occupany turns a light on ( works great ) but also can turn it off far too soon .
I tried to create a light off automation that has a delay of 30 seconds before turning the light off .
The problem is if you re enter the room in that time the light still goes off as automation is running .
Ideally I’d want a lights on automation to cancel any current lights off automation. Can’t see an obvious way ( or a better way ) to achieve this .
Suggestions welcome

Thinking about it .
I could set a count down timer . Then occupany ( could stop this ) which would prevent lights going off when timer is zero .
Seems crude , but I guess would work …

Thanks . I did search and found this and other related articles . Was assuming for such a basic function ( light on , cancel light off type thing ) that maybe it could be done in the UI .
Coming from homeseer this was possible .

All of that can be done in the UI.