# Node That only sends when 3 Payloads come in the right Order

**URL:** <https://discourse.nodered.org/t/node-that-only-sends-when-3-payloads-come-in-the-right-order/51237>\
**Category:** General\
**Created:** [19 September 2021 13:26 UTC](https://discourse.nodered.org/t/node-that-only-sends-when-3-payloads-come-in-the-right-order/51237 "2021-09-19T13:26:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zyan](https://avatars.discourse-cdn.com/v4/letter/z/8e7dd6/32.png) [@Zyan](https://discourse.nodered.org/u/Zyan)\
**Post date:** [19 September 2021 13:26 UTC](https://discourse.nodered.org/t/node-that-only-sends-when-3-payloads-come-in-the-right-order/51237/1 "2021-09-19T13:26:21Z")

</div>

Hi guys iam Trying to make somethig that when i send 3 Different Payloads in a Node it should send something.

For Example first Payload : "up" second Payload: "down" third Payload: "left"

So and only when these 3 Payloads Match in that Order it should send something. When they dont Match it should Resett after 3 Seconds

I wanne make something like a Code for Different Light Scenes and i got an Gesture Sensor.

So for Example up down left should be Scene 1 ; left rigt down Scene 2

Thx for your Help in Advance

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [19 September 2021 13:52 UTC](https://discourse.nodered.org/t/node-that-only-sends-when-3-payloads-come-in-the-right-order/51237/2 "2021-09-19T13:52:43Z")

</div>

Nice use case. As usual there are many ways to achieve your goal. My approach would be to concatenate the payloads in groups of three. A switch node at the end of the flow would allow only the matched string to pass.

Something like this:

 ![a4](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/1/c1c872b2843aa7497de320e73d1ab3fdc199da85.png)

The rule in the swtich node is set to "upupdown", so only this sequence would be a match.

Testing flow:

```auto
[{"id":"a3b92cc4.e3cb","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"fe98a93d.9ad0f8","type":"inject","z":"a3b92cc4.e3cb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"up","payloadType":"str","x":170,"y":160,"wires":[["fb39f8f9.173538"]]},{"id":"ce95dd27.9a57","type":"inject","z":"a3b92cc4.e3cb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"down","payloadType":"str","x":170,"y":220,"wires":[["fb39f8f9.173538"]]},{"id":"59491ed3.2f9cd","type":"inject","z":"a3b92cc4.e3cb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"left","payloadType":"str","x":170,"y":280,"wires":[["fb39f8f9.173538"]]},{"id":"84f1ec26.d5d66","type":"inject","z":"a3b92cc4.e3cb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"right","payloadType":"str","x":170,"y":340,"wires":[["fb39f8f9.173538"]]},{"id":"fb39f8f9.173538","type":"batch","z":"a3b92cc4.e3cb","name":"","mode":"count","count":"3","overlap":"2","interval":10,"allowEmptySequence":false,"topics":[],"x":370,"y":260,"wires":[["438f7b96.777dc4"]]},{"id":"8028bfa1.dc15c","type":"debug","z":"a3b92cc4.e3cb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":850,"y":260,"wires":[]},{"id":"1c72b271.79fe0e","type":"switch","z":"a3b92cc4.e3cb","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"upupdown","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":670,"y":260,"wires":[["8028bfa1.dc15c"]]},{"id":"438f7b96.777dc4","type":"join","z":"a3b92cc4.e3cb","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":260,"wires":[["1c72b271.79fe0e","87e02340.b97f7"]]},{"id":"87e02340.b97f7","type":"debug","z":"a3b92cc4.e3cb","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":340,"wires":[]}]

```

---

<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:** [19 September 2021 14:05 UTC](https://discourse.nodered.org/t/node-that-only-sends-when-3-payloads-come-in-the-right-order/51237/3 "2021-09-19T14:05:51Z")

</div>

> [@Zyan](#):
>
> up down left should be Scene 1

If the first three don't match anything are those three to be discarded, or should the second, third, fourth be tested?

---

<div class="post-metadata">

**Author:** ![Zyan](https://avatars.discourse-cdn.com/v4/letter/z/8e7dd6/32.png) [@Zyan](https://discourse.nodered.org/u/Zyan)\
**Post date:** [19 September 2021 16:26 UTC](https://discourse.nodered.org/t/node-that-only-sends-when-3-payloads-come-in-the-right-order/51237/4 "2021-09-19T16:26:01Z")

</div>

This is exactly what i was looking for, i only would like to reset it , for example an delay node that deletes all input that comes and when there wasnt a new input it should send one message after 3 seconds.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [19 September 2021 16:27 UTC](https://discourse.nodered.org/t/node-that-only-sends-when-3-payloads-come-in-the-right-order/51237/5 "2021-09-19T16:27:12Z")

</div>

Just add a 3 second time out in the join node.

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [19 September 2021 17:16 UTC](https://discourse.nodered.org/t/node-that-only-sends-when-3-payloads-come-in-the-right-order/51237/6 "2021-09-19T17:16:56Z")

</div>

I overlooked that timing requirement. It could be lime @E1cid suggested, just setup the 3 seconds delay in the configuration of the join node, in which case it will count the delay from the first message. The batch node could be dismissed.

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

```auto
[{"id":"a3b92cc4.e3cb","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"fe98a93d.9ad0f8","type":"inject","z":"a3b92cc4.e3cb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"up","payloadType":"str","x":270,"y":160,"wires":[["438f7b96.777dc4"]]},{"id":"ce95dd27.9a57","type":"inject","z":"a3b92cc4.e3cb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"down","payloadType":"str","x":270,"y":220,"wires":[["438f7b96.777dc4"]]},{"id":"59491ed3.2f9cd","type":"inject","z":"a3b92cc4.e3cb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"left","payloadType":"str","x":270,"y":280,"wires":[["438f7b96.777dc4"]]},{"id":"84f1ec26.d5d66","type":"inject","z":"a3b92cc4.e3cb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"right","payloadType":"str","x":270,"y":340,"wires":[["438f7b96.777dc4"]]},{"id":"8028bfa1.dc15c","type":"debug","z":"a3b92cc4.e3cb","name":"Scene 1 = updownleft","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":760,"y":220,"wires":[]},{"id":"1c72b271.79fe0e","type":"switch","z":"a3b92cc4.e3cb","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"updownleft","vt":"str"},{"t":"eq","v":"leftrightdown","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":550,"y":280,"wires":[["8028bfa1.dc15c"],["ae3a89bc.cdb818"],["df6f89cd.0060f8"]]},{"id":"438f7b96.777dc4","type":"join","z":"a3b92cc4.e3cb","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"3","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":430,"y":280,"wires":[["1c72b271.79fe0e"]]},{"id":"ae3a89bc.cdb818","type":"debug","z":"a3b92cc4.e3cb","name":"Scene 2 = leftrightdown","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":260,"wires":[]},{"id":"df6f89cd.0060f8","type":"change","z":"a3b92cc4.e3cb","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"no match after 3 seconds","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":300,"wires":[["f5e2dbbf.6a53b8"]]},{"id":"f5e2dbbf.6a53b8","type":"debug","z":"a3b92cc4.e3cb","name":"no match after 3 seconds","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":950,"y":300,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Zyan](https://avatars.discourse-cdn.com/v4/letter/z/8e7dd6/32.png) [@Zyan](https://discourse.nodered.org/u/Zyan)\
**Post date:** [19 September 2021 18:27 UTC](https://discourse.nodered.org/t/node-that-only-sends-when-3-payloads-come-in-the-right-order/51237/7 "2021-09-19T18:27:11Z")

</div>

Thx a lot guys for the Help it works Great like that .

---

<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:** [3 October 2021 18:27 UTC](https://discourse.nodered.org/t/node-that-only-sends-when-3-payloads-come-in-the-right-order/51237/8 "2021-10-03T18:27:47Z")

</div>

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