How to 'createTimer' and 'Timer.cancel' when item change state?

Hello,

Interesting but I’ve added the following in the cancellation rule..as you need to cancel a running and not terminated timer but thanks for the Code, ive used it and worked well…just adapted with the below

when
etc…
then
if(garagedoor2Timer === null || garagedoor2Timer.hasTerminated)
{
return;
}
garagedoor2Timer.cancel() //Terminate timer if door is closed before the timer ends

end