# Using the simple gate node

**URL:** <https://discourse.nodered.org/t/using-the-simple-gate-node/20199>\
**Category:** Share Your Projects\
**Created:** [11 January 2020 20:35 UTC](https://discourse.nodered.org/t/using-the-simple-gate-node/20199 "2020-01-11T20:35:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [11 January 2020 20:35 UTC](https://discourse.nodered.org/t/using-the-simple-gate-node/20199/1 "2020-01-11T20:35:17Z")

</div>

This is all thanks to "DrMike" who made `node-red-contrib-simple-gate`

I was in a situation where I needed to turn on **one** of _many_ and only have that single one passing signals.

I know recently I have posted a revelation how I have gone away from the `gate` node, but sometimes it is just handy to use.

This gives a visual indication of what is happening and it helps you see the bigger picture than the new way I was using in the other thread.

Anyway, this is a picture of the flow (first) so you can see what it is.

 ![Screenshot from 2020-01-12 07-31-08](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/4/e43e107a7193aae4fb4acd60ebdee327d094966a.png)

You have have as many inputs/outputs as needed. You just need to add the number of outputs to the `function` node and wire up the extra `trigger` and `switch`nodes.

I have added comments in the code indicating what needs to be done.

Here is the flow.

```auto
[{"id":"4211b708.4986a8","type":"gate","z":"9245b569.9f881","name":"Gate 1","controlTopic":"control","defaultState":"closed","openCmd":"1","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":650,"y":2360,"wires":[[]]},{"id":"eea931b1.4cc398","type":"function","z":"9245b569.9f881","name":"","func":"// This line needs to reflect the number of outputs\nlet output = [null,null,null,null,null];\nif (msg.payload === 'close') {\n // As does this line.\n node.send([msg,msg,msg,msg,msg]);\n} else {\n output[msg.payload - 1] = msg;\n node.send(output);\n}\n","outputs":5,"noerr":0,"x":370,"y":2540,"wires":[["4211b708.4986a8"],["2694e596.62245a"],["ff3b16e.1fcb6e8"],["bc9f33b6.966ea"],["3486957.5f77d6a"]]},{"id":"2694e596.62245a","type":"gate","z":"9245b569.9f881","name":"Gate 2","controlTopic":"control","defaultState":"closed","openCmd":"2","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":650,"y":2450,"wires":[[]]},{"id":"ff3b16e.1fcb6e8","type":"gate","z":"9245b569.9f881","name":"Gate 3","controlTopic":"control","defaultState":"closed","openCmd":"3","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":650,"y":2540,"wires":[[]]},{"id":"bc9f33b6.966ea","type":"gate","z":"9245b569.9f881","name":"Gate 4","controlTopic":"control","defaultState":"closed","openCmd":"4","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":660,"y":2630,"wires":[[]]},{"id":"3486957.5f77d6a","type":"gate","z":"9245b569.9f881","name":"Gate 5","controlTopic":"control","defaultState":"closed","openCmd":"5","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":650,"y":2720,"wires":[[]]},{"id":"71d40ac5.f1076c","type":"trigger","z":"9245b569.9f881","op1":"close","op2":"","op1type":"str","op2type":"pay","duration":"1","extend":false,"units":"ms","reset":"","bytopic":"all","name":"","x":350,"y":2480,"wires":[["eea931b1.4cc398"]]},{"id":"c8b521d5.fd8488","type":"inject","z":"9245b569.9f881","name":"","topic":"control","payload":"2","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":2440,"wires":[["71d40ac5.f1076c"]]},{"id":"b86d459f.6c0f3","type":"inject","z":"9245b569.9f881","name":"","topic":"control","payload":"3","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":2480,"wires":[["71d40ac5.f1076c"]]},{"id":"f8443771.039c","type":"inject","z":"9245b569.9f881","name":"","topic":"control","payload":"4","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":2520,"wires":[["71d40ac5.f1076c"]]},{"id":"6e0ee866.dc54","type":"inject","z":"9245b569.9f881","name":"","topic":"control","payload":"5","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":2560,"wires":[["71d40ac5.f1076c"]]},{"id":"ddec183d.4dbab","type":"inject","z":"9245b569.9f881","name":"","topic":"control","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":2400,"wires":[["71d40ac5.f1076c"]]},{"id":"52c96bf2.890134","type":"comment","z":"9245b569.9f881","name":"Switching node","info":"","x":650,"y":2320,"wires":[]},{"id":"f9f80aea.7a529","type":"comment","z":"9245b569.9f881","name":"Switching node","info":"","x":650,"y":2410,"wires":[]},{"id":"3eb7d655.f1be72","type":"comment","z":"9245b569.9f881","name":"Switching node","info":"","x":650,"y":2500,"wires":[]},{"id":"3a77f145.bb19ae","type":"comment","z":"9245b569.9f881","name":"Switching node","info":"","x":650,"y":2590,"wires":[]},{"id":"320edd02.e6565a","type":"comment","z":"9245b569.9f881","name":"Switching node","info":"","x":650,"y":2680,"wires":[]}]

```

I hope someone finds it helpful.

Remember this is **not** mine. I asked the guy who made the `gate` node and he did it.  
That isn't shifting blame if there is anything wrong. More so it is so the right person gets the credit.

---

<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:** [11 January 2020 22:10 UTC](https://discourse.nodered.org/t/using-the-simple-gate-node/20199/2 "2020-01-11T22:10:03Z")

</div>

(renamed the post to indicate what it was about)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [11 January 2020 22:11 UTC](https://discourse.nodered.org/t/using-the-simple-gate-node/20199/3 "2020-01-11T22:11:59Z")

</div>

Thanks. I probably didn't think that through with the title.
