How to delay only true messages

Hi, i need some help.
i want to delay only a true message for 1 hour and not the false.
how do i do that?
been searching for a week now zo please help.

i tryed somting like this but its not working.

[{"id":"3a512d1f9a3d020e","type":"delay","z":"efdd5570610d8dbe","name":"","pauseType":"delay","timeout":"60","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":710,"y":1230,"wires":[["22629e1fe5ecc4a7"]]},{"id":"e54a215f33c96b31","type":"switch","z":"efdd5570610d8dbe","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":1280,"wires":[["9c36e6a555a575d0","54f1d9a2f8440d93"],["9bf90509c08b9bc9","316ed36726efd01a"]]},{"id":"22629e1fe5ecc4a7","type":"debug","z":"efdd5570610d8dbe","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":860,"y":1270,"wires":[]},{"id":"13183e280a2d8fc6","type":"inject","z":"efdd5570610d8dbe","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":90,"y":1280,"wires":[["e54a215f33c96b31","e28140b27cbfb39d"]]},{"id":"f6664764e747acc9","type":"inject","z":"efdd5570610d8dbe","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":90,"y":1330,"wires":[["e54a215f33c96b31","de96a162a60a4989"]]},{"id":"9c36e6a555a575d0","type":"change","z":"efdd5570610d8dbe","name":"","rules":[{"t":"set","p":"delay","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":1230,"wires":[["3a512d1f9a3d020e","5a8d012691e0a7c7"]]},{"id":"9bf90509c08b9bc9","type":"change","z":"efdd5570610d8dbe","name":"","rules":[{"t":"move","p":"false","pt":"msg","to":"reset","tot":"msg"},{"t":"move","p":"false","pt":"msg","to":"false","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":1270,"wires":[["22629e1fe5ecc4a7","d2e9a61942109d67","3a512d1f9a3d020e"]]},{"id":"5a8d012691e0a7c7","type":"debug","z":"efdd5570610d8dbe","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":720,"y":1340,"wires":[]},{"id":"d2e9a61942109d67","type":"debug","z":"efdd5570610d8dbe","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":720,"y":1400,"wires":[]},{"id":"54f1d9a2f8440d93","type":"debug","z":"efdd5570610d8dbe","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":500,"y":1350,"wires":[]},{"id":"316ed36726efd01a","type":"debug","z":"efdd5570610d8dbe","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":500,"y":1410,"wires":[]},{"id":"e28140b27cbfb39d","type":"debug","z":"efdd5570610d8dbe","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":290,"y":1350,"wires":[]},{"id":"de96a162a60a4989","type":"debug","z":"efdd5570610d8dbe","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":290,"y":1410,"wires":[]}]

Just keep it simple?

Use a switch Node, and only send delayable messages out the first pin, and for others, skip the delay?

image

[{"id":"eeb33f649f8ba3b2","type":"inject","z":"37e03d102adc186c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":305,"y":155,"wires":[["f7bda0d604c093d6"]]},{"id":"8457cc7c60dfca2b","type":"inject","z":"37e03d102adc186c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":305,"y":200,"wires":[["f7bda0d604c093d6"]]},{"id":"f7bda0d604c093d6","type":"switch","z":"37e03d102adc186c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":485,"y":200,"wires":[["f39882bd50f85f94"],["df8244435b20aa9b"]]},{"id":"f39882bd50f85f94","type":"delay","z":"37e03d102adc186c","name":"","pauseType":"delay","timeout":"60","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":740,"y":175,"wires":[["d2f7674013e7a125"]]},{"id":"d2f7674013e7a125","type":"debug","z":"37e03d102adc186c","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":965,"y":175,"wires":[]},{"id":"fa9204d530af3322","type":"debug","z":"37e03d102adc186c","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":965,"y":215,"wires":[]},{"id":"df8244435b20aa9b","type":"junction","z":"37e03d102adc186c","x":670,"y":215,"wires":[["fa9204d530af3322"]]}]
1 Like

What do you want to happen if there is a true message followed by a false one a minute later? Do you want the true one to be passed on after another 59 minutes (which is what your question says) or do you want the false message to cancel the delayed true?

1 Like

i want the true message to be delayed, until the 60 minutes or false message is send.
also i think the tue and false needs te be set because the timer starts again if multiple true messages are send, or am i wrong about this?

So if a false message is received, you want that to bypass the delay, BUT in addition, release what is currently delayed?

sorry for the confusion.

  • if true then delay 60 minutes.
  • if false then reset delay and send false.
  • if true is send multiple times stay counting down.
  • if 60 minutes has pased then output needs to be true until false is send.

I think this may do what you want, though you still have not been clear.

  1. If a false message arrives then it is sent straight through.
  2. If a true message arrives then it will be delayed by 5 seconds (obviously change that to 1 hour for your requirement).
  3. If a false message arrives while a true is waiting then the true will be cancelled and the false will be sent on.
  4. If a true message arrives while a true is waiting then the second true will be ignored.

[{"id":"710101ef5fe87348","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":150,"y":2880,"wires":[["72a36d33ba3e342e"]]},{"id":"c4580ed7c55ed2f9","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":150,"y":2920,"wires":[["72a36d33ba3e342e"]]},{"id":"7b5919911d0cede4","type":"debug","z":"bdd7be38.d3b55","name":"debug 114","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":810,"y":2920,"wires":[]},{"id":"ab53a9fc234f4f34","type":"group","z":"bdd7be38.d3b55","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["24a846b6682d176f","8ea875922c57aa48","72a36d33ba3e342e","e35b0c0aca27bc68"],"x":294,"y":2839,"w":432,"h":122},{"id":"24a846b6682d176f","type":"switch","z":"bdd7be38.d3b55","g":"ab53a9fc234f4f34","name":"true/false","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":410,"y":2920,"wires":[["8ea875922c57aa48"],["e35b0c0aca27bc68","8ea875922c57aa48"]]},{"id":"8ea875922c57aa48","type":"trigger","z":"bdd7be38.d3b55","g":"ab53a9fc234f4f34","name":"","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"false","bytopic":"all","topic":"topic","outputs":1,"x":580,"y":2880,"wires":[["e35b0c0aca27bc68"]]},{"id":"72a36d33ba3e342e","type":"junction","z":"bdd7be38.d3b55","g":"ab53a9fc234f4f34","x":320,"y":2920,"wires":[["24a846b6682d176f"]]},{"id":"e35b0c0aca27bc68","type":"junction","z":"bdd7be38.d3b55","g":"ab53a9fc234f4f34","x":700,"y":2920,"wires":[["7b5919911d0cede4"]]}]
1 Like

thanks seems to be working fine now.

Good. For the future please note the detail in my description of what the flow does. It would have saved those here time if you had given a description to that level of detail when you asked the question. Thanks.

1 Like

Sorry, I had not seen your intermediate responses before I posted mine. I now see that you had clarified your requirement.

1 Like

No worries, I'm new and have a lot to learn.
I find Node-RED difficult to program compared to CODESYS.
Thanks for the quick response.

1 Like

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