Delay flow at start once for a while

How can I delay the flow on the initial node rpi-gpi-in once for a while so that the PIR sensor has time to calibrate. Any advice. Thank you.

Hi.

I am using a little imagination and a few assumptions (so forgive me if I misunderstand your question) but here is the answer to how I read your question...

"flow 1"
Use a flow variable in a switch node to block the flow of msgs from the GPIO until it the flow variable is SET.

"flow 2"
In a separate flow, an inject (set to fire on startup after nn secs) would then SET the flow variable and therefore allow the GPIO msgs to flow through the switch in "flow 1".


If parts of this dont make any sense to you & you are new to node-red, I can recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point.

Good advice. I use flow variable in flow. For me, this is a clear decision. Perhaps there is a more elegant solution.

Or like this

1 Like

I like to use node-red-contrib-simple-gate for situations like this.

image

[{"id":"0f4ab0c1025e5e72","type":"gate","z":"bdd7be38.d3b55","name":"","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"storeName":"memoryOnly","x":350,"y":2740,"wires":[["2e94f0ac1f3f37d1"]]},{"id":"4a365251e49b5393","type":"inject","z":"bdd7be38.d3b55","name":"Open after 5 secs","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"5","topic":"control","payload":"open","payloadType":"str","x":160,"y":2660,"wires":[["0f4ab0c1025e5e72"]]},{"id":"07acd25b3b49bdf1","type":"inject","z":"bdd7be38.d3b55","name":"GPIO simulator","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payloadType":"date","x":160,"y":2740,"wires":[["0f4ab0c1025e5e72"]]},{"id":"2e94f0ac1f3f37d1","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":540,"y":2740,"wires":[]}]

However, if you decide to go with a flow variable then I suggest calling it flow.enabled rather than flow.disabled. Double negatives are too much for my brain to cope with.

2 Likes

Colin, thanks a lot for the tip. Simple Gate is the perfect solution. I'm happy with the responsiveness of the community

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