Node for switching flow on and off


Have been searching for days now but can't seem to find a node that fits my needs. So I am about to write a function instead. But then I thought that I can't be the only one in need of this function. So is there node that I cant find that works like this:

Two inputs, one output.
The first input is simply for switching the flow on and off.
The second input just passes the message through to the output.

So for example if a message is sent to the first input with payload "off" then all messages to the second input will be dropped, until a message sent to the first input with payload "on". Then all messages will be just passed on to the output.

Have one flow that sets a context variable with the on/off

Have a switch in the second flow that checks the context variable

1 Like

This recipe in the cookbook shows how you can do that with a Change and Switch node using context

(edit: just as @ukmoose suggests)

1 Like


That is what I'm writing in a function right now. And of course I could use both your examples instead.
Just thought it would be more intuitive with the node I tried to describe.

There are contrib nodes already - such as the simple-gate node that do a similar thing. Personally I think the approach with the core nodes is simple enough.

The key thing to remember is nodes only have one input.

1 Like

Ok. I thought you could write nodes with more than one input, just like outputs. That explains why I was not able to find one.

The node you suggested is exactly what I am trying to write my on function for.

Thanks a lot. I will see which I end up using.