How can I add an dynamic timeout for my tablet automation?

Hey all, I can’t get this node-red flow to work. The thing I want is as follows: If my motion sensor is on, then send an API request to put my tablet screen on.
When there is no more motion detected, start a timer of x seconds (dynamically set input_number inside HA). Once there is motion in between, reset that timer.
Once the timer finishes, send another API call to put the tablet off.

I’ve this working now with a static Trigger node, but I want to put the dynamic input_number between it. This is my current one:

The trigger node doesn’t support a dynamic timeout on the input message. If you change over to stoptimer3 (https://flows.nodered.org/node/node-red-contrib-stoptimer3), it supports msg.duration on the input message.

image

This is a sample of my function node that sets the duration:
image

Thanks a lot! Got it working with the function node + stoptimer 3 now.

1 Like

Node-RED v1.2 allows overriding the delay of the trigger node from the message object.

https://github.com/node-red/node-red/pull/2707

1 Like

FINALLY! Thanks for the heads up.

Got it working now with the stoptimer3 and a “stop” for the timer when motion is detected after the off state and on state. I see that the trigger node itself can use dynamic variables as well? I think I can improve some stuff about this flow: