This may sound like a dumb question, but the docs don't answer this for me. I have two delay nodes, both set to a random delay of 7 ~ 27 minutes. When the flow runs and hits these, one has a blue square with the number 3 under it, the other has a blue square with a number 1 under it. What exactly does these numbers mean???
3 means there are 3 queued (delayed) messages.
Interesting, I wouldn't actually expect to have any queued messages in this case, but ok. Is there a way to tell what the current random delay value is? In this example, is there a way to tell if the current delay is 7 minutes, 15 minutes, etc?
Unfortunately not
Having a random delay between 7~27 minutes - you should expect at the minimum, a 7 minute delayed/queued message. a delayed message, will also be in the count you see, until its time has elapsed.
Mmm...
If this is critical to your operation, you can get close, but it's not perfect.
This will spit out the last delay that was set.
Given enough time, it can be improved I'm sure.
The bottom output is the message to state what delay time was used for the incoming message (its delivered before the payload its self)
[{"id":"15d578429f65a96d","type":"subflow","name":"Delay","info":"","category":"","in":[{"x":85,"y":70,"wires":[{"id":"ad078c22a00752a9"}]}],"out":[{"x":725,"y":65,"wires":[{"id":"aa35cd79e9e79663","port":0}]},{"x":725,"y":170,"wires":[{"id":"2866b8177211025b","port":0}]}],"env":[{"name":"Min","type":"num","value":""},{"name":"Max","type":"num","value":""}],"meta":{},"color":"#3FADB5","icon":"node-red/timer.svg"},{"id":"ad078c22a00752a9","type":"function","z":"15d578429f65a96d","name":"Gen Rand Delay","func":"msg.delay = Math.floor(Math.random() * env.get(\"Max\")) + env.get(\"Min\");\n\nlet DelayStatus = {\n lastDelay:msg.delay\n}\n\nnode.send([msg,{payload:DelayStatus}])","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":70,"wires":[["aa35cd79e9e79663"],["2866b8177211025b"]]},{"id":"aa35cd79e9e79663","type":"delay","z":"15d578429f65a96d","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":485,"y":65,"wires":[[]]},{"id":"2866b8177211025b","type":"junction","z":"15d578429f65a96d","x":450,"y":170,"wires":[[]]},{"id":"b1cc4c5dfefe297a","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"daa32dd9a0f6a262","type":"subflow:15d578429f65a96d","z":"b1cc4c5dfefe297a","name":"","env":[{"name":"Min","value":"1000","type":"num"},{"name":"Max","value":"5000","type":"num"}],"x":335,"y":155,"wires":[["a32b70e1cc1a8319"],["68de76d29ae0f090"]]},{"id":"aa292295b271ddbd","type":"inject","z":"b1cc4c5dfefe297a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":165,"y":155,"wires":[["daa32dd9a0f6a262"]]},{"id":"68de76d29ae0f090","type":"debug","z":"b1cc4c5dfefe297a","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":570,"y":170,"wires":[]},{"id":"a32b70e1cc1a8319","type":"debug","z":"b1cc4c5dfefe297a","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":570,"y":125,"wires":[]}]
I do enjoy a challenge
So I say I'm surprised that I see more than one message in the queue due to the way I have the flow setup, unless I fundamentally misunderstand how a loop node works.
Below is a screenshot of the flow, and I only allow one message to get through from the BigTimer, then I block those messages after that until I change the state of the flow.loop_running variable to false. The reason is I found that when the BigTimer would trigger every minute, it caused the loop node to "reset". So unless the loop node is generating it's own messages somehow, I really don't expect more than a single message in the loop ever. Of course, I have a misunderstanding with the conditional portion on the loop node so maybe this is a bigger misunderstanding of the node overall.
It's not critical to get the current delay, just makes troubleshooting easier I suppose.
It is easy enough to check by adding a debug node on the input and output so you can track the messages.
It is very unusual to need a loop node, there are usually better ways of solving the problem.
These loops are most likely the culprit.
The OP has opened another thread on their basic loop problem
Yeah, this one was going off topic so opened another thread on the different topic. I think I got the answer I was looking for originally. Thank you.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.