Looking for node help timing

(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.

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

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

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.

Your right

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

Just a message.

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

(Nearly got it now BTW)

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.

[{"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":[]}]
1 Like

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

(Foreign node: count)

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

This is better.

[{"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.

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