# Switch a flow on or off

**URL:** <https://discourse.nodered.org/t/switch-a-flow-on-or-off/9106>\
**Category:** Dashboard\
**Created:** [18 March 2019 06:44 UTC](https://discourse.nodered.org/t/switch-a-flow-on-or-off/9106 "2019-03-18T06:44:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RickW](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@RickW](https://discourse.nodered.org/u/RickW)\
**Post date:** [18 March 2019 06:44 UTC](https://discourse.nodered.org/t/switch-a-flow-on-or-off/9106/1 "2019-03-18T06:44:59Z")

</div>

I would like to use a dashboard switch to allow or stop a flow of time triggered analog data from a sensor input to a save to file node.

It seems like a fairly simple task to request but I can't picture how I can do it.

On the dashboard switch properties I can see True and False or could make it a number 0 and 1, but what node can I use to "switch" the flow?

The Function Switch node seems like a logical choice but I need an in and an out for the flow, and I need somewhere to connect the output of the Dashboard Switch?

Does it have to do with Topic?  
Do I use the input of the Function Switch for both the flow and the switch and somehow tell it what to do the the properties settings of the Function Switch?  
I have not yet grasped the concept of Topic. Can anyone suggest a simple tutorial that could help?

Thank you.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [18 March 2019 06:48 UTC](https://discourse.nodered.org/t/switch-a-flow-on-or-off/9106/2 "2019-03-18T06:48:50Z")

</div>

The cookbook is always a good place to start.  
Take a look at this flow and it should give you a start on how a dashboard switch could control a different flow

[https://cookbook.nodered.org/basic/route-on-context](https://cookbook.nodered.org/basic/route-on-context)

---

<div class="post-metadata">

**Author:** ![RickW](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@RickW](https://discourse.nodered.org/u/RickW)\
**Post date:** [18 March 2019 07:18 UTC](https://discourse.nodered.org/t/switch-a-flow-on-or-off/9106/3 "2019-03-18T07:18:22Z")

</div>

Thank you.

So there is no connecting line between the change node and the switch node.  
It just magically watches the value of state without any connection.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [18 March 2019 07:20 UTC](https://discourse.nodered.org/t/switch-a-flow-on-or-off/9106/4 "2019-03-18T07:20:05Z")

</div>

Well it’s not magic.

[https://nodered.org/docs/user-guide/context](https://nodered.org/docs/user-guide/context)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [18 March 2019 08:03 UTC](https://discourse.nodered.org/t/switch-a-flow-on-or-off/9106/5 "2019-03-18T08:03:39Z")

</div>

Or you could use a function node as a simple gate (and keep the wiring visible).  
[https://flows.nodered.org/flow/a985944e789d90e0cd2008d85b7aaa65](https://flows.nodered.org/flow/a985944e789d90e0cd2008d85b7aaa65)  
Up to you

---

<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:** [18 March 2019 09:20 UTC](https://discourse.nodered.org/t/switch-a-flow-on-or-off/9106/6 "2019-03-18T09:20:59Z")

</div>

I recommend using `node-red-contrib-simple-gate` for this. You can feed the signal from the switch straight into it to control whether it allows messages to pass or not.
