A lesson about using the `traffic` node for anyone using it

(This is posted with all honesty to be as helpful to people learning about writing flows. I have shot myself in the foot so many times with stupid mistakes REPEATEDLY! After a lot of wasted time because I didn't realise something, I am posting this based on what I was doing, what I wanted to happen and what I saw happening, and the conclusions based on that.)


I know it is not a standard node, but I have found a lot of use for the traffic node.

Basically it allows control of data flow. Like a traffic light. Basically STOP or GO.

Although it may be an unwritten rule, I just spent a lot of time (wasted may be a better term, but I'm not going to split hairs.) with this node and the settings I was using..

The node supports different modes to control the data flow.
You can specify letters, numbers, or the "basic" true and false logic states.

Unless you are actually wanting to control the data flow of true and false:
I strongly advise you to use the true and false to control the state of the node.

I was sending text through the node and had A and B to start and stop the flow.
Oh the fun I had trying to work out why it wasn't doing what I expected.

Because the text that I was sending through as real data had A and B in it, all sorts of fun ensued.
Or so it seems. Because when I switched to using true and false, the problem went away.

Unless the data flow is actual true and false signals, please save yourself a lot of grief and use those two as the on/off signals.

Likewise: If you are sending true and false as the data flow, use either letters/numbers.

But suffice to say:
When switching text/numbers/alphanumeric stuff....... Use true and false to switch the node.

Hi @Trying_to_learn,

<self-promotion> you might take a look at node-red-contrib-simple-gate. It avoids some of the difficulties you are having. </self-promotion>. :slightly_smiling_face:

1 Like

I actually have that installed too.

No problems with the self promo. :wink:

I was just putting it out there the problem/s I had and explained how it happened as a warning for anyone new to the game.

Very good node. Well written.

I feel your pain. Good tips on the traffic node.