Control the delay node with input from dashboard

I want to set "x" minutes and "y" minutes delay by using dashboard's numeric nodes.
eg - if I set number 7 in the numeric node on the dashboard, the delay node will delay the messages for 7 minutes.
The attached image explains the situation more clearly. Can we use "override delay with msg.delay" for both nodes? and how?
I am new at node-red & javascript and not able to code this using function node. Please help!

Did you look at the Help tab for the node?

You will need to add a change node between each ui-numeric node and delay node to copy the payload to msg.delay

{EDIT} ohh now I see the issue. each msh from the ui_numeric node will also pop into the loop so ou will have to filter them out with a switch node. Give me a moment to create an example.

Here you go. The key is to store each delay (from the ui-numeric) into a separate flow variable and then in the loop, grab the flow variable and move it to msg.delay

Here is the flow:

[{"id":"15195cb8.9b52f3","type":"inject","z":"d46a4272.d095b8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"from inject","payload":"true","payloadType":"bool","x":140,"y":200,"wires":[["f3e907ec.4e9bb8"]]},{"id":"8881beaa.e689b8","type":"delay","z":"d46a4272.d095b8","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":360,"y":340,"wires":[["489b7481.8d36f4","7495a4ea.5ee71c"]]},{"id":"b6ff3e9a.d1e68","type":"ui_numeric","z":"d46a4272.d095b8","name":"","label":"Delay 1","tooltip":"","group":"8711d53.103de28","order":11,"width":0,"height":0,"wrap":false,"passthru":true,"topic":"delay 1","format":"{{value}}","min":0,"max":10,"step":1,"x":420,"y":160,"wires":[["366cfbb5.c7cd84"]]},{"id":"bc451a11.b80f38","type":"ui_numeric","z":"d46a4272.d095b8","name":"","label":"Delay 2","tooltip":"","group":"8711d53.103de28","order":12,"width":0,"height":0,"wrap":false,"passthru":true,"topic":"delay 2","format":"{{value}}","min":0,"max":10,"step":1,"x":720,"y":160,"wires":[["d4b76007.f26fb"]]},{"id":"bd30978e.3bd168","type":"delay","z":"d46a4272.d095b8","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":780,"y":340,"wires":[["108cedcb.562a72","f3e907ec.4e9bb8"]]},{"id":"f3e907ec.4e9bb8","type":"change","z":"d46a4272.d095b8","name":"frog","rules":[{"t":"set","p":"payload","pt":"msg","to":"frog","tot":"str"},{"t":"set","p":"delay","pt":"msg","to":"delay1","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":130,"y":340,"wires":[["8881beaa.e689b8"]]},{"id":"489b7481.8d36f4","type":"change","z":"d46a4272.d095b8","name":"cat","rules":[{"t":"set","p":"payload","pt":"msg","to":"cat","tot":"str"},{"t":"set","p":"delay","pt":"msg","to":"delay2","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":340,"wires":[["bd30978e.3bd168"]]},{"id":"366cfbb5.c7cd84","type":"change","z":"d46a4272.d095b8","name":"","rules":[{"t":"set","p":"delay1","pt":"flow","to":"payload*1000","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"delay value","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":220,"wires":[[]]},{"id":"d4b76007.f26fb","type":"change","z":"d46a4272.d095b8","name":"","rules":[{"t":"set","p":"delay2","pt":"flow","to":"payload*1000","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"delay value 2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":220,"wires":[[]]},{"id":"108cedcb.562a72","type":"debug","z":"d46a4272.d095b8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":420,"wires":[]},{"id":"7495a4ea.5ee71c","type":"debug","z":"d46a4272.d095b8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":370,"y":420,"wires":[]},{"id":"8711d53.103de28","type":"ui_group","z":"","name":"delay input","tab":"69dce23.e7db49c","order":1,"disp":true,"width":"6","collapse":false},{"id":"69dce23.e7db49c","type":"ui_tab","z":"","name":"Delay test","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Thanks a lot! This is exactly what i was looking for. Now i understood how it works!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.