TIme remaining on Trigger node - debug or msg.property

I know this is an old thread, but I just used @Andrei 's flow and it's good for showing the 'running' time of the trigger (thanks).

In my case, I have the trigger set for 2 minutes and "extend delay if new message arrives" is ticked. Evertime the PIR detects motion, the trigger starts again.

It would be good if the function would re-start counting from zero at every trigger.

Did anyone find a solution?

This is Andrei's function:

var counting = function () {
  let counter = flow.get('counter');
  counter += 1;
  node.status({text:counter + " seconds"});
  flow.set('counter',counter);
   return counter;
}

if (msg.payload === "true") {
    flow.set('counter',0);
    node.status({text: "Started.."}); 
    let timer1 = setInterval(counting, 1000);
    flow.set('timer1',timer1);
} else if (msg.payload === "false") {
    node.status({}); // clear the status decoration
    clearInterval(flow.get('timer1')); 
    
}

return msg;