# How to delay only true messages

**URL:** https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337
**Category:** General
**Tags:** delay
**Created:** [1 December 2023 11:51 UTC](https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337 "2023-12-01T11:51:10Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![mrDal666](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrdal666/32/83627_2.png) [@mrDal666](https://discourse.nodered.org/u/mrDal666)
#### Post date: [1 December 2023 11:51 UTC](https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337/1 "2023-12-01T11:51:10Z")

</div>

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.

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [1 December 2023 12:00 UTC](https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337/2 "2023-12-01T12:00:20Z")

</div>

Just keep it simple?

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/8/c8e358801fcabe550cae5b68f2aca0aeb7eb34ca.png)

```auto
[{"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"]]}]

```

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [1 December 2023 12:08 UTC](https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337/3 "2023-12-01T12:08:23Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![mrDal666](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrdal666/32/83627_2.png) [@mrDal666](https://discourse.nodered.org/u/mrDal666)
#### Post date: [1 December 2023 12:15 UTC](https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337/4 "2023-12-01T12:15:36Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [1 December 2023 12:21 UTC](https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337/5 "2023-12-01T12:21:36Z")

</div>

> [@mrDal666](#):
>
> until the 60 minutes or false message is send

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

---

<div class="post-metadata">

### Author: ![mrDal666](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrdal666/32/83627_2.png) [@mrDal666](https://discourse.nodered.org/u/mrDal666)
#### Post date: [1 December 2023 12:58 UTC](https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337/6 "2023-12-01T12:58:51Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [1 December 2023 13:42 UTC](https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337/7 "2023-12-01T13:42:19Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/b/1b669a9b9841ffd0bcf61c49f560ddb19b0a1a64.png)

```auto
[{"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"]]}]

```

---

<div class="post-metadata">

### Author: ![mrDal666](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrdal666/32/83627_2.png) [@mrDal666](https://discourse.nodered.org/u/mrDal666)
#### Post date: [1 December 2023 13:48 UTC](https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337/8 "2023-12-01T13:48:25Z")

</div>

thanks seems to be working fine now.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [1 December 2023 13:58 UTC](https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337/9 "2023-12-01T13:58:22Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [1 December 2023 14:21 UTC](https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337/10 "2023-12-01T14:21:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mrDal666](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrdal666/32/83627_2.png) [@mrDal666](https://discourse.nodered.org/u/mrDal666)
#### Post date: [1 December 2023 14:30 UTC](https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337/11 "2023-12-01T14:30:27Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [15 December 2023 14:31 UTC](https://discourse.nodered.org/t/how-to-delay-only-true-messages/83337/12 "2023-12-15T14:31:05Z")

</div>

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