Simple gate to switch on and off a flow

A simple flow demonstrating how to use a switch in a dashboard to turn on and off a flow of information in the server. This shows how to combine two inputs and use one of them to control the other.

[{"id":"af07d51.5afe728","type":"ui_switch","z":"d629259e.613838","name":"","label":"switch","group":"415ff655.a1d8f8","order":0,"width":0,"height":0,"passthru":true,"topic":"gate","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":245.5,"y":1005,"wires":[["c8edc66a.057cb8"]]},{"id":"c8edc66a.057cb8","type":"function","z":"d629259e.613838","name":"control","func":"if (msg.topic === \"gate\") {\n    context.pass = (msg.payload === true) ? true : false;\n    return null;  // exit out early as it's just the control\n}\nif (context.pass) {\n    return msg; // if enabled pass msg\n}\nreturn null; // or drop it","outputs":1,"noerr":0,"x":433.5,"y":1025,"wires":[["bd6caa17.447778"]]},{"id":"5bb586be.00a6a8","type":"inject","z":"d629259e.613838","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"x":268,"y":1067,"wires":[["c8edc66a.057cb8"]]},{"id":"bd6caa17.447778","type":"debug","z":"d629259e.613838","name":"","active":true,"console":"false","complete":"payload","x":644,"y":1026,"wires":[]},{"id":"415ff655.a1d8f8","type":"ui_group","z":"","name":"Default","tab":"622a3108.4411e","disp":true,"width":"6"},{"id":"622a3108.4411e","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]

Flow Info

Created 8 years, 3 months ago
Updated 8 years, 2 months ago
Rating: 5 1

Owner

Actions

Rate:

Node Types

Core
  • debug (x1)
  • function (x1)
  • inject (x1)
Other
  • ui_group (x1)
  • ui_switch (x1)
  • ui_tab (x1)

Tags

  • gate
  • control
  • switch
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option