How to view delay node random time as a countdown?

hi all... i have a number of delay nodes in a flow which are set to delay for random intervals and i would like to see the countdown in dashboard....

for example a delay node is set to random time between 10-30 sec.. as the flow is running i would like to see what interval was chosen between 10 and 30 seconds and display a countdown of it in the dashboard...

would anyone know how to do this ? i have looked around at other posts and tried to find other node besides the default delay one but havent had any luck..

as you are setting the delay with a msg.delay, send that to a UI Text node. If necessary, copy msg.delay in to msg.payload (in a change node) before the UI text node.

thanks for your help... I tried what you described but doesnt seem to work.. i maybe didnt explain my goal properly...

i have a regular delay node with the properties set to delay a random time.. i took a change node and converted msg.delay out of the delay node to msg.payload and sent that to debug to show the payload but its showing "undefined".. also tried it with dashboard text and didnt show anything..

also i dont just want to see the random number chosen.. for example if the delay is set to random between 10-30 seconds and chooses 18.. i dont just want to see the number "18" id like to see it countdown from 18 to 0.. i figured this makes it a bit more complex ?

i thought about adding a function node to choose a random number to send to the delay node using msg.delay and then take the random number from the function node to show the countdown in textui node, but i still dont know how to get it to countdown ? it would be more elegant if it could be done with just the standard delay node somehow but if i need to use a few nodes that could still work.. if you have any further ideas would be keen to hear..

It can be done without using the function node. The idea is to load the random number to msg.payload, delay 1 second using the trigger node, and then decrement msg.payload using a change node. The trigger node will be reset when payload reaches the value zero.

[{"id":"13040b63810e7b1b","type":"tab","label":"Flow 4","disabled":false,"info":"","env":[]},{"id":"85611df1d2aa62b5","type":"trigger","z":"13040b63810e7b1b","name":"heartbeat","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"1","extend":false,"overrideDelay":false,"units":"s","reset":"0","bytopic":"all","topic":"topic","outputs":1,"x":520,"y":180,"wires":[["131bed3b32a1a64a"]],"outputLabels":["send \"fail\" if not feeded"]},{"id":"2ed4ee7be5488558","type":"inject","z":"13040b63810e7b1b","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":180,"wires":[["607a9ef5307de2e5"]]},{"id":"1b4d94e2ff9d92b5","type":"link out","z":"13040b63810e7b1b","name":"link out 1","mode":"link","links":["c4e2a8281a303149"],"x":795,"y":260,"wires":[]},{"id":"c4e2a8281a303149","type":"link in","z":"13040b63810e7b1b","name":"link in 1","links":["1b4d94e2ff9d92b5"],"x":485,"y":260,"wires":[["85611df1d2aa62b5"]]},{"id":"8f6ca65f4feac75b","type":"debug","z":"13040b63810e7b1b","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":880,"y":180,"wires":[]},{"id":"607a9ef5307de2e5","type":"random","z":"13040b63810e7b1b","name":"","low":"5","high":10,"inte":"true","property":"payload","x":340,"y":180,"wires":[["85611df1d2aa62b5"]]},{"id":"131bed3b32a1a64a","type":"change","z":"13040b63810e7b1b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload - 1","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":180,"wires":[["8f6ca65f4feac75b","1b4d94e2ff9d92b5"]]}]

nice... i see that works to create the countdown but how do i get it to delay the original flow also ? apologies if its obvious but im still new to NR...

At the end of @Andrei flow, replace 'debug 3' with a switch testing if msg.payload = 0

[{"id":"8f6ca65f4feac75b","type":"debug","z":"13040b63810e7b1b","name":"Continue with flow","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1110,"y":80,"wires":[]},{"id":"d9c5a27a78a927ee","type":"switch","z":"13040b63810e7b1b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":910,"y":180,"wires":[["8f6ca65f4feac75b"],["fc4b6ed9508ce08b"]]},{"id":"fc4b6ed9508ce08b","type":"debug","z":"13040b63810e7b1b","name":"Show count down value","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":240,"wires":[]}]

So you would send the msg to be delayed into this flow. First move msg.payload to msg.original_payload (to save the data) then on exiting this flow, in a change node, move msg.original_payload back to msg.payload.

1 Like

cool that works... thanks.

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