# Looking for node help timing

**URL:** <https://discourse.nodered.org/t/looking-for-node-help-timing/62491>\
**Category:** General\
**Created:** [11 May 2022 06:32 UTC](https://discourse.nodered.org/t/looking-for-node-help-timing/62491 "2022-05-11T06:32:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [11 May 2022 06:32 UTC](https://discourse.nodered.org/t/looking-for-node-help-timing/62491/1 "2022-05-11T06:32:51Z")

</div>

(I am cursed with this scenario that if I don't ask I will remain stuck but if I do ask, it increases the chances I work it out myself.)

# Requirement:

Messages received. If two are received within a given time it sends me a message.  
If the time expires things are reset.

I feel I have been here before, but am not sure.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [11 May 2022 06:42 UTC](https://discourse.nodered.org/t/looking-for-node-help-timing/62491/2 "2022-05-11T06:42:46Z")

</div>

> [@Trying\_to\_learn](#):
>
> (I am cursed with this scenario that if I don't ask I will remain stuck but if I do ask, it increases the chances I work it out myself.)

That's the way I work a lot of the time - T'Internet makes for a great Rubber Duck 🙂

At first glance, without actually trying anything I'd hope that the trigger node would sort this out

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [11 May 2022 06:44 UTC](https://discourse.nodered.org/t/looking-for-node-help-timing/62491/3 "2022-05-11T06:44:19Z")

</div>

But the `trigger` node will only _trigger_ if the time EXCEEDS the time.

I want an output if two messages are received within a time frame.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [11 May 2022 06:47 UTC](https://discourse.nodered.org/t/looking-for-node-help-timing/62491/4 "2022-05-11T06:47:09Z")

</div>

Your right

What output is required - just a 1/0 or true/false type msg.payload?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [11 May 2022 06:49 UTC](https://discourse.nodered.org/t/looking-for-node-help-timing/62491/5 "2022-05-11T06:49:16Z")

</div>

Just a message.

`msg.payload` would be the best fit in this case.

(Nearly got it now BTW)

---

<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:** [11 May 2022 06:55 UTC](https://discourse.nodered.org/t/looking-for-node-help-timing/62491/6 "2022-05-11T06:55:50Z")

</div>

Would a join node followed by a swiitch node do the job. The join would be on a timeout and create an array , and the switch checks if count is greater than 1.  
e.g.

```auto
[{"id":"f97cc0ba.4982d8","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":780,"wires":[["40d2562d.d7c5b8"]]},{"id":"40d2562d.d7c5b8","type":"join","z":"bf9e1e33.030598","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"2","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":340,"y":780,"wires":[["ea24554f.578e2"]]},{"id":"ea24554f.578e2","type":"switch","z":"bf9e1e33.030598","name":"","property":"$count($$.payload)","propertyType":"jsonata","rules":[{"t":"gt","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":490,"y":780,"wires":[["fa1497e7.26a5f"]]},{"id":"fa1497e7.26a5f","type":"debug","z":"bf9e1e33.030598","name":"send message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":680,"y":780,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [11 May 2022 07:00 UTC](https://discourse.nodered.org/t/looking-for-node-help-timing/62491/7 "2022-05-11T07:00:52Z")

</div>

This seems to work (Sorry @E1cid) I'll look at your code too.

(Foreign node: `count`)

```auto
[{"id":"12ad365093aa8340","type":"inject","z":"0918ee609bf69fc7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"SIGNAL","payloadType":"str","x":1940,"y":2450,"wires":[["49e86788f58b1c74"]]},{"id":"49e86788f58b1c74","type":"counter","z":"0918ee609bf69fc7","name":"","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":2,"x":2160,"y":2450,"wires":[["adee23994ae41ebb"],[]]},{"id":"adee23994ae41ebb","type":"switch","z":"0918ee609bf69fc7","name":">2 ?","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"2","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":2370,"y":2450,"wires":[["132316e65f97436b"],["5a8cd281cb964034"]]},{"id":"5a8cd281cb964034","type":"trigger","z":"0918ee609bf69fc7","name":"","op1":"","op2":"RESET","op1type":"nul","op2type":"str","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":2350,"y":2410,"wires":[["a5666f9ba8ad6363"]]},{"id":"76a6ef59fa75cf6b","type":"inject","z":"0918ee609bf69fc7","name":"Reset","props":[{"p":"reset","v":"true","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":2150,"y":2370,"wires":[["a5666f9ba8ad6363"]]},{"id":"132316e65f97436b","type":"change","z":"0918ee609bf69fc7","name":"WARN","rules":[{"t":"set","p":"payload","pt":"msg","to":"Message to be shown","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2520,"y":2450,"wires":[["21563e122869f47c"]]},{"id":"21563e122869f47c","type":"debug","z":"0918ee609bf69fc7","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2670,"y":2450,"wires":[]},{"id":"a5666f9ba8ad6363","type":"change","z":"0918ee609bf69fc7","name":"RESET","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":2160,"y":2410,"wires":[["49e86788f58b1c74"]]},{"id":"8d87e121fd60781d","type":"comment","z":"0918ee609bf69fc7","name":"Set to the time span.","info":"","x":2330,"y":2370,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [11 May 2022 07:15 UTC](https://discourse.nodered.org/t/looking-for-node-help-timing/62491/8 "2022-05-11T07:15:18Z")

</div>

This is better.

```auto
[{"id":"12ad365093aa8340","type":"inject","z":"0918ee609bf69fc7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"SIGNAL","payloadType":"str","x":1940,"y":2450,"wires":[["49e86788f58b1c74"]]},{"id":"49e86788f58b1c74","type":"counter","z":"0918ee609bf69fc7","name":"","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":2,"x":2160,"y":2450,"wires":[["adee23994ae41ebb"],[]]},{"id":"adee23994ae41ebb","type":"switch","z":"0918ee609bf69fc7","name":">1 ?","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"1","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":2370,"y":2450,"wires":[["132316e65f97436b"],["5a8cd281cb964034"]]},{"id":"5a8cd281cb964034","type":"trigger","z":"0918ee609bf69fc7","name":"","op1":"","op2":"RESET","op1type":"nul","op2type":"str","duration":"12","extend":false,"overrideDelay":false,"units":"hr","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":2350,"y":2410,"wires":[["a5666f9ba8ad6363"]]},{"id":"76a6ef59fa75cf6b","type":"inject","z":"0918ee609bf69fc7","name":"Reset","props":[{"p":"reset","v":"true","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":2150,"y":2370,"wires":[["a5666f9ba8ad6363"]]},{"id":"132316e65f97436b","type":"change","z":"0918ee609bf69fc7","name":"WARN","rules":[{"t":"set","p":"payload","pt":"msg","to":"Message to be shown","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2520,"y":2450,"wires":[["21563e122869f47c"]]},{"id":"21563e122869f47c","type":"debug","z":"0918ee609bf69fc7","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2670,"y":2450,"wires":[]},{"id":"a5666f9ba8ad6363","type":"change","z":"0918ee609bf69fc7","name":"RESET","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":2160,"y":2410,"wires":[["49e86788f58b1c74"]]},{"id":"8d87e121fd60781d","type":"comment","z":"0918ee609bf69fc7","name":"Set to the time span.","info":"","x":2330,"y":2370,"wires":[]}]

```

All that needs to be done is adjust the time in the `trigger` node to the time which if two messages arrive an event is caused.

---

<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:** [25 May 2022 07:16 UTC](https://discourse.nodered.org/t/looking-for-node-help-timing/62491/9 "2022-05-25T07:16:15Z")

</div>

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