Node-RED guide series
"RBE" stands for "Report by Exception".
This node will will only pass changes to its output,.
Suppose that you are sending on/off instructions to a motor or other actuator. The motor will turn on after it receives an "on" instruction, and any subsequent "on" instructions will have no effect.
In a Node-RED flow, this is case where you can use an "rbe" node to only propagate changes in the content of a message. With the "rbe" node, a message that is equal to the previous message will not be propagated, while a different message will.
With the motor example (which actually comes from the Terrarium controller project), the "rbe" flow will block new "on" messages if the last message was also "on", but will propagate an "off" message.
You will find the "rbe" node in the functions group of the left toolbar.
Setup the "rbe" node
To explain how to use the "rbe" node, I have created this simple flow:
This flow is triggered by the two "inject" nodes on the left. The "debug" node on the right will simply print out values "1" or "2", depending on which button was clicked.
Here's the interesting part: The message that arrives to the "debug" node is controlled by an "rbe" node. Only changes in the message payload will go through.
So, If you click the inject node named "1" multiple times, the output will show "1" only once.
You will get the same behavior by pressing inject node "2" multiple times.
However, if you alternate your clicks between "1" and "2", all of the messages will be printed in the debug pane.
Here is how I have setup the "rbe" node
I have set the mode to "block unless value changes", and the value that is evaluated to "msg.payload".
That's all there is to it.
To test it, deploy the flow and click on the two "inject" node buttons. Here is an example output:
Notice that the messages alternate between "1" and "2" even though I was frantically clicking on the same button multiple times.
The "rbe" node offers several mode options as you can see in the screenshot below. You can qualify for the kind of change that want to block or allow message propagation.
Learn Node-RED and how to use it with the ESP32
This course will guide you through the construction of an automated control system. The deliverable is a Terrarium controller.
Along the way, you will learn a great deal about useful technologies such as the Node Red programming environment and MQTT.
Jump to another article