Check event happening before a certain timeout

I have a trivial issue, but I got lost.
I need a timer to start in a certain flow position when "ON" message is received. Then, if an "OFF" message is received within 3 seconds, another branch of the flow will take part.
I tried the "countdown" module but it doesn't fit with my needs.

You could do it with a Trigger and a node-red-contrib-simple-gate
Depending on what you want to happen if another ON or OFF comes in during the timeout you might have to feed the output back to close the gate and reset the trigger.

[{"id":"1cff539d.ca4f0c","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":90,"y":4760,"wires":[["7fd9e863.35aa4"]]},{"id":"2186e261.65693e","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":90,"y":4820,"wires":[["7fd9e863.35aa4"]]},{"id":"7fd9e863.35aa4","type":"switch","z":"bdd7be38.d3b55","name":"ON/OFF","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":220,"y":4800,"wires":[["bd9ed63e.05d258"],["9bdecbe2.deb46"]]},{"id":"bd9ed63e.05d258","type":"trigger","z":"bdd7be38.d3b55","name":"Open/close gate","op1":"open","op2":"close","op1type":"str","op2type":"str","duration":"3","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":380,"y":4740,"wires":[["e3b302c7.607e18"]]},{"id":"9bdecbe2.deb46","type":"gate","z":"bdd7be38.d3b55","name":"","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"x":610,"y":4800,"wires":[["5e80548b.7280ec"]]},{"id":"e3b302c7.607e18","type":"change","z":"bdd7be38.d3b55","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":4740,"wires":[["9bdecbe2.deb46"]]},{"id":"5e80548b.7280ec","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":4900,"wires":[]}]
1 Like

Thanks, but how to check "within 3 seconds from ON"?

Did you import my suggestion and try it?

Yes, and I have seen how you are suggesting to use the trigger node, thanks.

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