Only send msg when some input data has had value for amount of time

I am quite a newbie to Node-Red but until now have extremely enjoyed working with it. So my apologies if I am not using the right terminology...

My flow is involving reading/writing Modbus registers but the question is more generic.
Anyway, I am reading some Modbus registers as input and need to write some other Modbus registers as output. Now I am looking for a way to send a certain Modbus register only after a certain input register has had a certain value for a configurable amount of time. This to prevent the output register from going on and off continuously.
Another application of this is letting screens go down only after lux value outside has been greater than e.g. 10,000 lux for 5 minutes. This to prevent screens going up and down when it is cloudy and lux values are flickering around 10,000 lux. Many other applications can be though of.
I bet there is a generic node or pattern that can be applied here.

Thanks for your help!

Take a look at the trigger node. and switch node. Here is an example.

[{"id":"7d2819b0.323798","type":"inject","z":"5a245aa1.510164","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"12000","payloadType":"num","x":80,"y":4120,"wires":[["4fde099.51c9878"]]},{"id":"4fde099.51c9878","type":"switch","z":"5a245aa1.510164","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"10000","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":4140,"wires":[["d69c1ead.fe77b8"],["e948945f.d48328"]]},{"id":"9a987a64.59ba38","type":"inject","z":"5a245aa1.510164","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"8000","payloadType":"num","x":70,"y":4160,"wires":[["4fde099.51c9878"]]},{"id":"d69c1ead.fe77b8","type":"trigger","z":"5a245aa1.510164","name":"","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":470,"y":4120,"wires":[["af74e4d3.4aaa78"]]},{"id":"e948945f.d48328","type":"change","z":"5a245aa1.510164","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":4200,"wires":[["d69c1ead.fe77b8","af74e4d3.4aaa78"]]},{"id":"af74e4d3.4aaa78","type":"debug","z":"5a245aa1.510164","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":4140,"wires":[]}]

[{"id":"1fd089dc.ad6506","type":"inject","z":"942b70c6.58cc6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"lux","payload":"9999","payloadType":"num","x":908,"y":608,"wires":[["5bec8c36.863ac4"]]},{"id":"8d81fc99.7e288","type":"inject","z":"942b70c6.58cc6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"lux","payload":"10001","payloadType":"num","x":908,"y":656,"wires":[["5bec8c36.863ac4"]]},{"id":"e1239785.6f8388","type":"inject","z":"942b70c6.58cc6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"lux","payload":"12000","payloadType":"num","x":908,"y":704,"wires":[["5bec8c36.863ac4"]]},{"id":"19274e27.97e3b2","type":"inject","z":"942b70c6.58cc6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"lux","payload":"8000","payloadType":"num","x":908,"y":560,"wires":[["5bec8c36.863ac4"]]},{"id":"5bec8c36.863ac4","type":"switch","z":"942b70c6.58cc6","name":">= 10000 ?  ","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"10000","vt":"num"},{"t":"lt","v":"10000","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":1108,"y":624,"wires":[["7884ed7d.9262d4"],["a46590d4.c19c3"]]},{"id":"7884ed7d.9262d4","type":"change","z":"942b70c6.58cc6","name":"Send true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1276,"y":592,"wires":[["882c1b98.5958f8"]]},{"id":"a46590d4.c19c3","type":"change","z":"942b70c6.58cc6","name":"Send reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"reset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1286,"y":656,"wires":[["882c1b98.5958f8"]]},{"id":"882c1b98.5958f8","type":"trigger","z":"942b70c6.58cc6","name":"","op1":"","op2":"open sesame","op1type":"nul","op2type":"str","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1482,"y":624,"wires":[["e84f4530.96a458"]]},{"id":"e84f4530.96a458","type":"debug","z":"942b70c6.58cc6","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1648,"y":624,"wires":[]}]

Thanks guys! Wonderful!!

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