Activate / deactivate a node with a dashboard switsch

How can I use a dashboard switch to enable or disable a node or program section

Hi Kiwi_gamer01.

I'm not an expert, but I'll reply.

You may need to explain this a bit more to what you mean.

Node-Red works with events (as I call them) happening and causing other events.
Nodes if you will.

So you will need a group of nodes (or: flow) doing something first.

Then you would get a switch or button (from the dashboard) and connect it into a part of the flow.

This would set a condition which the flow detects and then stops doing it until the value is reset to..... what it was before.


I am sure there are examples, but I am still close to the bottom of the ladder and so can't just produce an example.

Sorry, but good luck with your journey.

You cannot disable a flow or node, but as @Trying_to_learn (nearly) said node-red nodes do something when they receive a message. To stop a flow doing anything you need to stop the flow of messages feeding it. There are many ways to do that. For example node-red-contrib-simple-gate provides an easy way of blocking messages, you could feed the switch state in as the gate signal.
Have a look at that and if it does not do what you need then tell us a bit more about what you are trying to do.


You could also use a switch node of course to do the same thing if you don't want to install any more Nodes.

With the simple_gate node you can feed the ui_switch into the gate node (as well as the messages you want to allow through or block) to control the gate. I think with a Switch node you would need to use flow context which makes it more difficult to see what is going on.

1 Like

+1 for node-red-contrib-simple-gate
I use it on several flows, and especially as it's state persists a reboot.

1 Like