Using the simple gate node

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.

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 switchnodes.

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

Here is the flow.

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

1 Like

(renamed the post to indicate what it was about)

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