RBE not "working" as I thought


This is really hard to explain quickly and/or easily.

Really trying to keep it short:
I can change the colour of button backgrounds depending on things happening.

It is not CONSTANT. It is only when things change.

I am using a pulsed event to determine if devices are on or off line.

I have a "one off" event to set the colours of the buttons. Works, but I want to make it better.

If the device is OFF LINE, the colour changes accordingly.

To stop "flooding" with unneeded messages I put the RBE node in.

But it doesn't seem to be working as I expect.
I accept that if it receives two messages saying the device is OFF LINE it won't send the second.
So what I did to get around that (or so I thought) was to add an INJECT node just before the RBE.
Doesn't matter what it injects. It won't be the same as the previous packet so it should allow that packet through, and in so doing, allow the next of the WANTED packets through too.

It isn't.

This is THE part of the flow:

[{"id":"3e3949d5.1b3b26","type":"function","z":"381d953d.4cf092","name":"EXISTING NODE","func":"var colour = (msg.payload === \"On-line\")?\"lime\":\"brown\";\n//node.warn(\"Selected colour is \" + colour);\nnode.status({text:colour});\nmsg.background = colour;\nmsg.device_ID = \"ALL\";\nmsg.state = 0;\nreturn msg\n","outputs":1,"noerr":0,"x":1660,"y":3310,"wires":[["da102b23.c13568"]]},{"id":"da102b23.c13568","type":"rbe","z":"381d953d.4cf092","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1860,"y":3310,"wires":[[]]},{"id":"74f8d5df.cae62c","type":"inject","z":"381d953d.4cf092","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1710,"y":3260,"wires":[["da102b23.c13568"]]}]

The wanted data is coming in from the left to the "EXISTING" node. Goes through the RBE and out.

The messages are basically ON of OFF messages with colour information in them.

To get one of them to pass through, I press the INJECT button on the inject node and expect to see that come out and then the next ON/OFF signal (one of) go through.

It isn't happening.

Where's that elephant hiding?



It works for me. I have added an inject node in order to tell the function node to send something (it won't send anything ever otherwise) and a debug node to see what is happening. Click the lower inject and it passes on the msg from the function node. Click the inject again and nothing is passed on by the RBE. Click the upper inject and that message is passed on, click the lower one again and its message is passed on as expected.

[{"id":"d51868aa.28806","type":"function","z":"acd8202b.36972","name":"EXISTING NODE","func":"var colour = (msg.payload === \"On-line\")?\"lime\":\"brown\";\n//node.warn(\"Selected colour is \" + colour);\nnode.status({text:colour});\nmsg.background = colour;\nmsg.device_ID = \"ALL\";\nmsg.state = 0;\nreturn msg\n","outputs":1,"noerr":0,"x":181,"y":1334,"wires":[["9c210f9e.edfc9"]]},{"id":"9c210f9e.edfc9","type":"rbe","z":"acd8202b.36972","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":381,"y":1334,"wires":[["1ca38efa.594a01"]]},{"id":"69b94d3d.f06df4","type":"inject","z":"acd8202b.36972","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":231,"y":1284,"wires":[["9c210f9e.edfc9"]]},{"id":"e0f25755.f588a","type":"inject","z":"acd8202b.36972","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":116,"y":1428,"wires":[["d51868aa.28806"]]},{"id":"1ca38efa.594a01","type":"debug","z":"acd8202b.36972","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":573,"y":1298,"wires":[]}]
1 Like


What does the Note at the bottom of the RBE info tab say ?



Thanks Colin.

I'll look at it in a second.
I have been feverishly digging my self into a BIG HOLE for the last ...... 6 hours.

How ONE tiny winy spelling mistake can propagate thorough an ENTIRE flow! ARGH!

I have tried sitting down with paper and writing the ideas down, then applying them. No luck.



Ok, it says:

This works on a per msg.topic basis. This means that a single rbe node can handle multiple different topics at the same time.

Which is ok. Yet, when I open the node, there is the:
Property selector which can be set to payload. Sorry: IS set to payload. So I am guessing that payload is an option.

Given that it ONLY uses the msg.topic: that shouldn't be a problem.
The topic is set (the one that needs to be blocked because it happens at a timed frequency) and the one which can change at any time - which is the one I am wanting to see the changes of - also has a topic and is different to the other one.

So that shouldn't be a problem.
Should it?



If the problem is that messages arrives with different topics, why not to add a change node to set msg.topic to one specific just before the RBE and then will not be a problem anymore and will behave as you expect?




No it isn't the node gets different topics.

Let's try again: (Though I think I have it nutted now)

This is the code in the function block I HAD:

var colour = (msg.payload === "On-line")?"lime":"brown";
//node.warn("Selected colour is " + colour);
msg = null;
msg.background = colour;
msg.device_ID = "ALL";
msg.state = 0;
return msg

Pitiful way of colour setting by a message.
The set the msg.background to a colour, the device_ID and state.
Then send on the message.
The problem arose that all the other junk was included in the message.
So things I didn't want/need were there.

They were repeated (same data) over and over every (say) 6 seconds.
Only if a device changed state from ONLINE to OFFLINE did that change.

So ONLINE got LIME as the colour. OFFLINE got BROWN.

I (now can't be certain as SO MUCH) has happened these messages were/seemed to be blocked by the RBE node.

So, to simulate a machine changing state, I injected a timestamp. That would be different to the ongoing (repeated) OFFLINE/ONLINE data being seen by the RBE.
So it would let that message through. (no love lost for that message)
Then it would let through the real message I wanted with the device's status. ONLY ONE, but that's enough to set the colour.

I would inject timestamps and it just wasn't working.

Anyway, because of that problem I have changed the code in the function node to this now:

var colour = (msg.payload === "On-line")?"lime":"brown";
//node.warn("Selected colour is " + colour);
var msg2 = { payload:"", background:colour, device_ID:"ALL", state:0};
return msg2

And I am about to see if that makes a difference.



What if you add some msg.topic property on the message? Apparently is not set.....




In which is msg.topic not set?

I haven't sent any example data for either input, so I'm confused.



Did you look at my example and make sure you understand the way it works? If you still cannot get it to work setup an example with the inject and debug node as I did, post it here and explain what it does and what you expected. Note that the RBE node only blocks or lets through messages as they are received, it does not save messages and then pass them on later, if that is what you are expecting.



Sorry maybe I didn't understood well, there is too long..... If the problem is as the title of your post that RBE is not working as you expect maybe try to set a debug and copy us the messages that coming out of the RBE to be able to better understand why.




(This is getting frustrating. Not the replies: just what is happening.)

This is a cut from the flow:

[{"id":"c596bf8c.aa14d8","type":"function","z":"381d953d.4cf092","name":"","func":"var colour = (msg.payload === \"On-line\")?\"lime\":\"brown\";\n//node.warn(\"Selected colour is \" + colour);\nvar msg2 = { topic:colour,payload:\"\", background:colour, device_ID:\"PiFace\", state:0};\nnode.status({text:colour});\nreturn msg2\n","outputs":1,"noerr":0,"x":1290,"y":4630,"wires":[["b7a841af.98e3e8","b58ceebe.3845e8"]]},{"id":"b58ceebe.3845e8","type":"debug","z":"381d953d.4cf092","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1460,"y":4700,"wires":[]},{"id":"b7a841af.98e3e8","type":"rbe","z":"381d953d.4cf092","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1440,"y":4630,"wires":[["a069da7a.c3864"]]},{"id":"a069da7a.c3864","type":"debug","z":"381d953d.4cf092","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1530,"y":4550,"wires":[]}]

Let's say it has already got engaged to block.
This is being sent into the function block:

topic: "brown"
payload: ""
background: "brown"
device_ID: "PiFace"
state: 0

It happens say every 6 seconds.

It then changes to this:

topic: "lime"
payload: ""
background: "lime"
device_ID: "PiFace"
state: 0

That is seen going INTO the RBE.
Coming out?


I realise that I had to set the topic - Thanks David.

And this is the code is the function node:

var colour = (msg.payload === "On-line")?"lime":"brown";
//node.warn("Selected colour is " + colour);
var msg2 = { topic:colour,payload:"", background:colour, device_ID:"PiFace", state:0};
return msg2

Here is a screen shot to show.

You can see the red highlight around the first node which has the outputs shown on the right of the screen.
You can see 2 LIME topic nodes then it changed to BROWN.
No message passes the RBE node to the second green highlighted node.



As I suggested earlier, amend your earlier example with appropriate inject and debug nodes, inject the messages you describe, and see if that does what you expect. If not then post it here so we can try.
Also you still have not said whether the example I posted does what you expect.



Sorry Colin. Got distracted. Shall look now.

Ok, pressing the inject 0 node and it gets through once.

Pressing the timestamp the injections go through every time.



So is that what you expected? You said it didn't work, but all I have done is added the inject and debug.



Well, the original post had an inject node and pressing the inject node there was still no output.

I've tried topic changes, payload changes. I am stuck/confused.

Have you seen the later post with the screen shot and the new nodes?

I don't get that it says that the RBE node stops the payloads as per:
In RBE mode this node will block until the msg.payload is different to the previous one.

So....... I am not getting something.



You seem to be setting payload to ""

So once the 1st payload = "" has gone thru the RBE node, no other messages will go thru until payload <> ""

1 Like


I was told here that RBE works on msg.topic

As per stated at the bottom of the node's INFO page.


I shall look into that problem.

So can I change the node's setting looking at msg.topic to msg.payload (or vice versa?)
So it is looking at a changing part of the message.



It does

So 1st payload = "", topic = lime goes thru,
1st payload = "", topic = brown goes thru

No more messages on topic =lime or topic =brown will go thru until their respective payloads <> ""



Per msg.topic, not ON msg.topic. A very subtle difference!