RBE node is driving me crazy

I have been in this scenario before many times and it keeps biting me.

This is a cut down of the code:

[{"id":"49a576ab.8b2ca","type":"function","z":"28c631fa.7e866e","name":"","func":"msg1 = {};\n\nvar state = context.get(\"state\") || 0;\nvar ST = global.get(\"SCAN_TIME\") || 20000;\nST = ST * 3;\n\nnode.status({text:state});\n\nif (msg.payload == true)\n{\n    //  All good\n    msg.reset = true;\n    if (state == 0)\n    {\n        msg.delay = ST;\n        msg1.payload = \"UP\";\n        context.set(\"state\",1);\n        return [msg,msg1];\n    } else\n    {\n        //\n        return;\n    }\n} else\n{\n    //  Not good.\n    context.set(\"state\",0);\n    return [msg,null];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":2880,"y":3540,"wires":[["4a303edf.9aa9c","37dc2ac4.5548ee"],["4599ebcb.53e71c"]],"outputLabels":["down","up"]},{"id":"4a303edf.9aa9c","type":"trigger","z":"28c631fa.7e866e","name":"","op1":"","op2":"DOWN","op1type":"nul","op2type":"str","duration":"6","extend":false,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":3050,"y":3540,"wires":[["3158e797.e96b58","4599ebcb.53e71c"]]},{"id":"37dc2ac4.5548ee","type":"debug","z":"28c631fa.7e866e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":3040,"y":3490,"wires":[]},{"id":"857736ed.1d2248","type":"inject","z":"28c631fa.7e866e","name":"Set","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"false","payloadType":"bool","x":2780,"y":3610,"wires":[["49a576ab.8b2ca"]]},{"id":"4599ebcb.53e71c","type":"rbe","z":"28c631fa.7e866e","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":3175,"y":3600,"wires":[["650497f.77a79e8"]],"l":false},{"id":"4e386a22.f3a044","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":2590,"y":3500,"wires":[["eac9160a.7ca4e8","49a576ab.8b2ca"]]},{"id":"a6a8a370.b5112","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":2590,"y":3460,"wires":[["49a576ab.8b2ca","eac9160a.7ca4e8"]]},{"id":"3158e797.e96b58","type":"debug","z":"28c631fa.7e866e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":3250,"y":3520,"wires":[]},{"id":"650497f.77a79e8","type":"debug","z":"28c631fa.7e866e","name":"STATUS","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":3220,"y":3640,"wires":[]},{"id":"40cda74e.116b2","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"UP","payloadType":"str","x":2740,"y":3660,"wires":[["4599ebcb.53e71c"]]},{"id":"12f72dc3.7f50b2","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"DOWN","payloadType":"str","x":2740,"y":3700,"wires":[["4599ebcb.53e71c"]]},{"id":"faafb247.909de","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"FOO","payloadType":"str","x":2740,"y":3740,"wires":[["4599ebcb.53e71c"]]},{"id":"eac9160a.7ca4e8","type":"debug","z":"28c631fa.7e866e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2890,"y":3490,"wires":[]}]

Picture:

Basics:
A true or false signal is received denoting the condition. true is good. false is bad.

All things being good I get true signals every ..... (what ever).
the function node sees what is received and if true sends a msg.reset out to stop the trigger node if it was active. I'll explain that now.

So, if a false signal is received, the trigger node is activated and waits for a while before sending the message.
IF in the mean time, a true comes in, the trigger node is reset.

Great.

I am testing new stuff and so I am looking at this part of the code.

Or more so:

This part isn't working as expected.

Well, it is here, but not in the REAL part of the flow, and there is SFA difference. Just a rearrangement of the nodes and a couple of extra ones deleted. (FAN) Ok, one, not a couple.

Now, weirdly if I export the whole block and put it on another machine - more powerful - it works. As is.

If I duplicate it and put it else where on the same machine: It works.
I cut it down to basic nodes only to allow more people to be able to import it and (maybe) help me.

But that's just it! If I duplicate the code and put it else where on the machine - and simulate the input signals: It works.

As is it doesn't.

The RBE isn't letting the DOWN signal get through.

Here is a set of screen shots showing you what I see with the real code:

This has the IP set to fail and we are watching the code of interest on the screen.

Here you can see the trigger node has been started and waiting 60 seconds.

And the next message comes through.....

And now you can see the trigger node has timed out.
(No more blue dot under it.)
But the STATUS node still says UP.
It should say DOWN as that is the message send.

What is going on?

Here is a better picture showing better messages:

And for the sake of "all cards on the table", here is that part of the code:

[{"id":"d0d076af.aade6","type":"link in","z":"28c631fa.7e866e","name":"Uplink status 1","links":["99fec739.577a4","ca7b2a2f.da6688"],"x":1415,"y":860,"wires":[["d2c6f62.6b59b88","b98ad199.c3b2e"]]},{"id":"d2c6f62.6b59b88","type":"debug","z":"28c631fa.7e866e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1570,"y":830,"wires":[]},{"id":"b98ad199.c3b2e","type":"function","z":"28c631fa.7e866e","name":"","func":"msg1 = {};\n\nvar state = context.get(\"state\") || 0;\nvar ST = global.get(\"SCAN_TIME\") || 20000;\nST = ST * 3;\n\nnode.status({text:state});\n\nif (msg.payload == true)\n{\n    //  All good\n    msg.reset = true;\n    if (state == 0)\n    {\n        msg.delay = ST;\n        msg1.payload = \"UP\";\n        context.set(\"state\",1);\n        return [msg,msg1];\n    } else\n    {\n        //\n        return;\n    }\n} else\n{\n    //  Not good.\n    context.set(\"state\",0);\n    return [msg,null];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":1560,"y":880,"wires":[["c641c733.ddcf08","41bda798.8375c"],["975da5db.6f47f","7acbe605.7ed528"]],"outputLabels":["down","up"]},{"id":"c641c733.ddcf08","type":"trigger","z":"28c631fa.7e866e","name":"","op1":"","op2":"DOWN","op1type":"nul","op2type":"str","duration":"60","extend":false,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1740,"y":880,"wires":[["975da5db.6f47f","402174e8.1add24"]]},{"id":"41bda798.8375c","type":"debug","z":"28c631fa.7e866e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1720,"y":830,"wires":[]},{"id":"975da5db.6f47f","type":"fan","z":"28c631fa.7e866e","name":"","x":1615,"y":930,"wires":[["c7efedf1.7e7a8"]],"l":false},{"id":"f6d46866.3ebf28","type":"inject","z":"28c631fa.7e866e","name":"Set","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"false","payloadType":"bool","x":1460,"y":950,"wires":[["b98ad199.c3b2e"]]},{"id":"7acbe605.7ed528","type":"debug","z":"28c631fa.7e866e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1650,"y":1060,"wires":[]},{"id":"402174e8.1add24","type":"debug","z":"28c631fa.7e866e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1930,"y":860,"wires":[]},{"id":"c7efedf1.7e7a8","type":"rbe","z":"28c631fa.7e866e","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1685,"y":930,"wires":[["99f3baf.756be48","15467e2.0e01c82"]],"l":false},{"id":"68edec51.fb5b24","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"UP","payloadType":"str","x":1420,"y":1000,"wires":[["975da5db.6f47f"]]},{"id":"c0f5029e.6f1c1","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"DOWN","payloadType":"str","x":1420,"y":1040,"wires":[["975da5db.6f47f"]]},{"id":"68a0f3f2.511754","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"FOO","payloadType":"str","x":1420,"y":1080,"wires":[["975da5db.6f47f"]]},{"id":"99f3baf.756be48","type":"link out","z":"28c631fa.7e866e","name":"Get new public IP","links":["1723bf77.0e3771","49140757.4051e"],"x":1830,"y":930,"wires":[],"l":true},{"id":"15467e2.0e01c82","type":"debug","z":"28c631fa.7e866e","name":"STATUS","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1730,"y":970,"wires":[]}]

You will need node-red-contrib-fan for it to load.

Update:

Here is an update.

I suspect the RBE node and have little choice than to test this theory.

I replaced it with this node/code (a function block)

[{"id":"ebf6a97d.0ea5","type":"function","z":"28c631fa.7e866e","name":"RBE","func":"var old = context.get(\"OLD\") || 0;\nvar new_value = msg.payload;\nif (old != new_value)\n{\n    context.set(\"OLD\",new_value);\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1855,"y":970,"wires":[["99f3baf.756be48","15467e2.0e01c82"]],"l":false}]

Now look at what happens (screen shots)

Changed from good to bad.

Getting worse.

Now it is really bad.

And this is what should happen

So could someone who really knows how things work explain this to me - please.

can you break this down to a simple (minimal flow - just one) with injects numbered 1, 2, 3, 4 etc - that demonstrates the issue?

There is far too much text, changes, ifs, buts & maybes in your post. It is impossible to follow.

Standard nodes only if possible.

1 Like

There is no 1, 2, 3, input.

It is true and false inputs.

This code works:

[{"id":"49a576ab.8b2ca","type":"function","z":"28c631fa.7e866e","name":"","func":"msg1 = {};\n\nvar state = context.get(\"state\") || 0;\nvar ST = global.get(\"SCAN_TIME\") || 20000;\nST = ST * 3;\n\nnode.status({text:state});\n\nif (msg.payload == true)\n{\n    //  All good\n    msg.reset = true;\n    if (state == 0)\n    {\n        msg.delay = ST;\n        msg1.payload = \"UP\";\n        context.set(\"state\",1);\n        return [msg,msg1];\n    } else\n    {\n        //\n        return;\n    }\n} else\n{\n    //  Not good.\n    context.set(\"state\",0);\n    return [msg,null];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":2880,"y":3540,"wires":[["4a303edf.9aa9c","37dc2ac4.5548ee"],["4599ebcb.53e71c"]],"outputLabels":["down","up"]},{"id":"4a303edf.9aa9c","type":"trigger","z":"28c631fa.7e866e","name":"","op1":"","op2":"DOWN","op1type":"nul","op2type":"str","duration":"6","extend":false,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":3050,"y":3540,"wires":[["3158e797.e96b58","4599ebcb.53e71c"]]},{"id":"37dc2ac4.5548ee","type":"debug","z":"28c631fa.7e866e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":3040,"y":3490,"wires":[]},{"id":"857736ed.1d2248","type":"inject","z":"28c631fa.7e866e","name":"Set","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"false","payloadType":"bool","x":2780,"y":3610,"wires":[["49a576ab.8b2ca"]]},{"id":"4599ebcb.53e71c","type":"rbe","z":"28c631fa.7e866e","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":3175,"y":3600,"wires":[["650497f.77a79e8"]],"l":false},{"id":"4e386a22.f3a044","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":2590,"y":3500,"wires":[["eac9160a.7ca4e8","49a576ab.8b2ca"]]},{"id":"a6a8a370.b5112","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":2590,"y":3460,"wires":[["49a576ab.8b2ca","eac9160a.7ca4e8"]]},{"id":"3158e797.e96b58","type":"debug","z":"28c631fa.7e866e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":3250,"y":3520,"wires":[]},{"id":"650497f.77a79e8","type":"debug","z":"28c631fa.7e866e","name":"STATUS","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":3220,"y":3640,"wires":[]},{"id":"40cda74e.116b2","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"UP","payloadType":"str","x":2740,"y":3660,"wires":[["4599ebcb.53e71c"]]},{"id":"12f72dc3.7f50b2","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"DOWN","payloadType":"str","x":2740,"y":3700,"wires":[["4599ebcb.53e71c"]]},{"id":"faafb247.909de","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"FOO","payloadType":"str","x":2740,"y":3740,"wires":[["4599ebcb.53e71c"]]},{"id":"eac9160a.7ca4e8","type":"debug","z":"28c631fa.7e866e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2890,"y":3490,"wires":[]}]

(From the top of the first (only) post)

This one doesn't:

[{"id":"d0d076af.aade6","type":"link in","z":"28c631fa.7e866e","name":"Uplink status 1","links":["99fec739.577a4","ca7b2a2f.da6688"],"x":1415,"y":860,"wires":[["d2c6f62.6b59b88","b98ad199.c3b2e"]]},{"id":"d2c6f62.6b59b88","type":"debug","z":"28c631fa.7e866e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1570,"y":830,"wires":[]},{"id":"b98ad199.c3b2e","type":"function","z":"28c631fa.7e866e","name":"","func":"msg1 = {};\n\nvar state = context.get(\"state\") || 0;\nvar ST = global.get(\"SCAN_TIME\") || 20000;\nST = ST * 3;\n\nnode.status({text:state});\n\nif (msg.payload == true)\n{\n    //  All good\n    msg.reset = true;\n    if (state == 0)\n    {\n        msg.delay = ST;\n        msg1.payload = \"UP\";\n        context.set(\"state\",1);\n        return [msg,msg1];\n    } else\n    {\n        //\n        return;\n    }\n} else\n{\n    //  Not good.\n    context.set(\"state\",0);\n    return [msg,null];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":1560,"y":880,"wires":[["c641c733.ddcf08","41bda798.8375c"],["975da5db.6f47f","7acbe605.7ed528"]],"outputLabels":["down","up"]},{"id":"c641c733.ddcf08","type":"trigger","z":"28c631fa.7e866e","name":"","op1":"","op2":"DOWN","op1type":"nul","op2type":"str","duration":"60","extend":false,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1740,"y":880,"wires":[["975da5db.6f47f","402174e8.1add24"]]},{"id":"41bda798.8375c","type":"debug","z":"28c631fa.7e866e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1720,"y":830,"wires":[]},{"id":"975da5db.6f47f","type":"fan","z":"28c631fa.7e866e","name":"","x":1615,"y":930,"wires":[["c7efedf1.7e7a8"]],"l":false},{"id":"f6d46866.3ebf28","type":"inject","z":"28c631fa.7e866e","name":"Set","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"false","payloadType":"bool","x":1460,"y":950,"wires":[["b98ad199.c3b2e"]]},{"id":"7acbe605.7ed528","type":"debug","z":"28c631fa.7e866e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1650,"y":1060,"wires":[]},{"id":"402174e8.1add24","type":"debug","z":"28c631fa.7e866e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1930,"y":860,"wires":[]},{"id":"c7efedf1.7e7a8","type":"rbe","z":"28c631fa.7e866e","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1685,"y":930,"wires":[["99f3baf.756be48","15467e2.0e01c82"]],"l":false},{"id":"68edec51.fb5b24","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"UP","payloadType":"str","x":1420,"y":1000,"wires":[["975da5db.6f47f"]]},{"id":"c0f5029e.6f1c1","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"DOWN","payloadType":"str","x":1420,"y":1040,"wires":[["975da5db.6f47f"]]},{"id":"68a0f3f2.511754","type":"inject","z":"28c631fa.7e866e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"FOO","payloadType":"str","x":1420,"y":1080,"wires":[["975da5db.6f47f"]]},{"id":"99f3baf.756be48","type":"link out","z":"28c631fa.7e866e","name":"Get new public IP","links":["1723bf77.0e3771","49140757.4051e"],"x":1830,"y":930,"wires":[],"l":true},{"id":"15467e2.0e01c82","type":"debug","z":"28c631fa.7e866e","name":"STATUS","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1730,"y":970,"wires":[]}]

The node.red.contrib.fan is the only foreign node.

But, if I replace the RBE node with the code I posted:
and the RBE is not foreign.

[{"id":"ebf6a97d.0ea5","type":"function","z":"28c631fa.7e866e","name":"RBE","func":"var old = context.get(\"OLD\") || 0;\nvar new_value = msg.payload;\nif (old != new_value)\n{\n    context.set(\"OLD\",new_value);\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1855,"y":970,"wires":[["99f3baf.756be48","15467e2.0e01c82"]],"l":false}]

It works.

To me it is 100% pointing at the RBE node not doing what it should.

I meant label your injects 1, 2, 3 etc so i know how to repeat what you are doing (what order of clicking causes the issue you see)

Sorry. Ok. Hang on.

I see nothing wrong - it does as its supposed to (as far as I can tell).

As for the fan node - what a waste of bytes that is. You might as well have an empty change node.

Here is a (maybe) better showing of the problem.

(Wait for the one that works.... coming soon)

All good.

Note the condition of the STATUS node as UP.
and that the OUT OF RBE is also UP.
So: RBE's last message is UP. (OUT OF FAN)

Things start to go wrong.
No message into RBE that I can see. (OUT OF FAN)

They get worse.
ditto.

And worse.
ditto.

And now fail:
See the new message going into the RBE node? DOWN?

Note that STATUS hasn't changed from UP to DOWN yet you can see the message going into the RBE node quite clearly.

Now the working example:

Note the UP messages.

false received. trigger set off.

And now......

Note the DOWN message in STATUS.

This was NOT happening before with the RBE node.

Is that clear enough? I am at a loss how to show you any clearer.

wow - no haha

Make a flow with only the elements that matter, with injects that fire the EXACT TOPIC/PAYLOAD combinations that you see & that cause the issue you see. Number the injects in order of click - when you can reproduce your issue in a dedicated flow that we can import - that would be easier




This is definitely a case of not being able to see the wood for the trees.

I am convinced this is due to topic / payload combination.

Just checking (i'm sure you know this, but just in case...) - you do know that RBE works per topic?

e.g.

topic payload RBE passes?
empty UP
192.168.0.2 UP
192.168.0.2 DOWN
192.168.0.2 DOWN
empty DOWN
empty DOWN
empty UP
192.168.0.2 DOWN
empty UP
192.168.0.2 DOWN
empty UP
192.168.0.2 DOWN
empty UP
1 Like

Yeah, but reading the docs, the topic is.... optional.

I want to pass changes through it. So: irrespective of the topic if the message changes it is passed.

But to digress, honestly: you can't see how in the first set of screen grabs, the message is blocked and yet on the second set it is passed?

As I have decided to use the function node rather than the RBE node and it works with that, I guess I should just shut up and move on.

But I am repeatedly tripped on this and I have fallen for this trap many times in the past.

I am (obviously) missing something. Especially if I just replace the RBE node with a function node with the code I showed and it works.

It is optional - BUT...

  • EMPTY TOPIC + PAYLOAD is one combination,
  • TOPIC + PAYLOAD is a completely different combination.

again - this is what happens when you send payloads WITH and WITHOUT a topic through 1 RBE...

topic payload RBE passes?
empty UP
192.168.0.2 UP
192.168.0.2 DOWN
192.168.0.2 DOWN
empty DOWN
empty DOWN
empty UP
192.168.0.2 DOWN
empty UP
192.168.0.2 DOWN
empty UP
192.168.0.2 DOWN
empty UP

basically if you want RBE to work the same regardless of topic, change the topic to empty string "" before the RBE.

Well, to me that isn't optional.

Optional to me means it makes no difference if it is (or not) used.

When clearly it does make a difference.

There - maybe - should be an .... option (sorry) to include the topic in the filtering/parsing.

Perhaps - yes.

Your function...

var old = context.get("OLD") || 0;
var new_value = msg.payload;
if (old != new_value)
{
    context.set("OLD",new_value);
    return msg;
}

... works because you ignore topic altogether.

Where in the docs does it describe topic as optional?

The docs actually say:

topic
if specified the function will work on a per topic basis.

and

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

Sorry, but I think that is reasonably clear about how it handles msg.topic if it is set.

But the docs for the RBE node are (as I read them)

RBE mode will accept numbers, strings, and simple objects. Other modes must provide a parseable number.

Yes, below it says:

if specified the function will work on a per topic basis.

But what does specified mean here?

If it is set? If it is not blank?
To me - and believe me: I failed English - specified is the wrong word.

(Sorry: edit)

To me the topic is ALWAYS parsed (irrespective of if it is blank or set) and this needs to be clearly stated in the read me for the node.

if topic is not specified (empty) then that in itself is a topic - an empty topic.

All you have to remember is, if the topic changes, its a different comparison.

Say for arguments sake, each topic is a memory bank where the last payload is remembered (like your function uses context.old) then...

  • topic : "" - is one memory bank
  • topic : "x" - is another memory bank
  • topic : "y" - is yet another memory bank

Like i said before, if you want ALL payloads (regardless of topic) to be considered as the same compare, then set the topic to a consistent value before the RBE.

It means if msg.topic exists, then it will be used.

As Steve has said - if you want the node to act across all messages it receives, then all of those messages should either have msg.topic set to the same value, or not have msg.topic set at all (ie deleted from the message with a change node).

Yes, I can see that and kind of understand that.

At this particular stage in the flow, I guess it is academic and so the topic isn't needed.

So in that case: rather than complicating things by changing the topic, why not just have an option to IGNORE it?

I dont think its complicating things (just that it tripped you up)

However, I do see a benefit to this option you propose (for different reasons to you) - it would allow a topic to be kept while acting on the payload alone.

Maybe raise it as a feature request?

1 Like

Yes, Nick, I (now) agree with this.

But as I just posted to Steve, why complicate things?
(Adding an extra change node to delete the topic - as an example of getting what you said done)

It would be better if there was an option in the node to simply ignore topic.

Otherwise it isn't optional. It is part of the parsing mechanism.
By no means optional.

I think my confusion is that is says:

if the topic is set........

It would be (to me) a lot clearer if it said ... (let me think)

RBE mode will accept numbers, strings, and simple objects. Other modes must provide a parseable number.
The topic is also used to determine the likeness of the messages and used to determine if the messages are the same.

And/or have a tick box to just ignore the topic. (I'm hoping a bit there)

Having the topic's role in a whole different paragraph separates it's importance.
As it (the topic) isn't not part of the equation. Excuse the double negative there but I think it helps explain why/how I get confused with reading it.

The topic is just as important as the message, and so it needs to be included where/when this is stated.
Not in a different paragraph.