# Delay flow at start once for a while

**URL:** <https://discourse.nodered.org/t/delay-flow-at-start-once-for-a-while/57009>\
**Category:** General\
**Created:** [21 January 2022 11:04 UTC](https://discourse.nodered.org/t/delay-flow-at-start-once-for-a-while/57009 "2022-01-21T11:04:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nefedor](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nefedor](https://discourse.nodered.org/u/Nefedor)\
**Post date:** [21 January 2022 11:04 UTC](https://discourse.nodered.org/t/delay-flow-at-start-once-for-a-while/57009/1 "2022-01-21T11:04:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [21 January 2022 11:52 UTC](https://discourse.nodered.org/t/delay-flow-at-start-once-for-a-while/57009/2 "2022-01-21T11:52:57Z")

</div>

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 `msg`s 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 `msg`s 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](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point.

---

<div class="post-metadata">

**Author:** ![Nefedor](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nefedor](https://discourse.nodered.org/u/Nefedor)\
**Post date:** [21 January 2022 13:58 UTC](https://discourse.nodered.org/t/delay-flow-at-start-once-for-a-while/57009/3 "2022-01-21T13:58:15Z")

</div>

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

 ![IMG-20220120-WA0000](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/6/86d6c188f8228bf022d971255c37e8604897e6fb.jpeg)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [21 January 2022 14:32 UTC](https://discourse.nodered.org/t/delay-flow-at-start-once-for-a-while/57009/4 "2022-01-21T14:32:08Z")

</div>

Or like this

 ![Untitled 6](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/77cf9929bc6d81203a9855dd6a4b8a95d7e68cd3.jpeg)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 January 2022 16:46 UTC](https://discourse.nodered.org/t/delay-flow-at-start-once-for-a-while/57009/5 "2022-01-21T16:46:52Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/6/f67e6b7d67ba3cbb0508b2b77b6bf75451ad8ff0.png)

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

---

<div class="post-metadata">

**Author:** ![Nefedor](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nefedor](https://discourse.nodered.org/u/Nefedor)\
**Post date:** [21 January 2022 20:10 UTC](https://discourse.nodered.org/t/delay-flow-at-start-once-for-a-while/57009/6 "2022-01-21T20:10:08Z")

</div>

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

---

<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:** [4 February 2022 20:10 UTC](https://discourse.nodered.org/t/delay-flow-at-start-once-for-a-while/57009/7 "2022-02-04T20:10:45Z")

</div>

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