Today was an example of something I don't like happening.
But it did.
As much as that was an eye opener, it is also stumping me.
(To digress)
I have made my own special RBE nodes.
AFAIK they work.
Haven't seen problems with them but today threw a big spanner in the works.
They failed - or did they?
Yeah, it isn't helping the error catching is not RAW and a routine handles them.
But it was giving me enough information that I am sure that these node are the problem.
So, back to the story:
Lots of piccies.
The error.
Searching for the node.
What's going in to it.
So:
Work the problem.
On my main machine I made a flow that does the same.
(code below)
[{"id":"5a6ca5972b0f9e7b","type":"subflow","name":"Adv blocker","info":"2024 07 01\n==========\n\nTidied up code in `function` node - replaced `var` with `let`.\n\n2024 06 17\n==========\n\nDefine `TOPIC` to control how the gate filters messages.\n(All commands are all uppercase)\nYou need to set the `env` variable `TOPIC` to set the control topic.\nInput values:\n - STOP - basically don't pass ANY message.\n - ALL - pass all messages.\n - BLOCK - block repeats of same message.\n - ONE - pass ONLY the next message to arrive. (ONE)\n\nAdded error catching - may be better.","category":"","in":[{"x":170,"y":130,"wires":[{"id":"685360a3.c08db8"}]}],"out":[{"x":550,"y":130,"wires":[{"id":"685360a3.c08db8","port":0}]}],"env":[{"name":"TOPIC","type":"str","value":""},{"name":"DEFAULT_MODE","type":"str","value":"","ui":{"label":{"en-US":"Default Mode"},"type":"select","opts":{"opts":[{"l":{"en-US":"All"},"v":"ALL"},{"l":{"en-US":"Stop"},"v":"STOP"},{"l":{"en-US":"Block"},"v":"BLOCK"},{"l":{"en-US":"One only"},"v":"ONE"}]}}},{"name":"topic_mode","type":"bool","value":"false","ui":{"type":"input","opts":{"types":["bool"]}}},{"name":"msg_part_to_scan","type":"str","value":"","ui":{"label":{"en-US":"Message part"},"type":"input","opts":{"types":["str"]}}}],"meta":{},"color":"#3FADB5","icon":"node-red/function.svg","status":{"x":550,"y":190,"wires":[{"id":"197b01d950cf86b4","port":0}]}},{"id":"685360a3.c08db8","type":"function","z":"5a6ca5972b0f9e7b","name":"My blocker node. V6.3c","func":"// Version 6.3.1\n// 2024 07 01\n// Replaced `var` with `let`\n\n// Version 6.3\n// 2022 04 25\n// Added topic specific blocking or generic\n// This is mentiond below on earlier update but not applied.\n// 2023 10 03\n// Problem with control_topic fixed.\n\n// The shape property can be: ring or dot.\n// The fill property can be: red, green, yellow, blue or grey\n\n////////////////////////////////////////////////////////////////////////////////\n// 2022 04 27\n// Added env(msg_part_to_scan) to determine which part of the message is used\n// to detect repeats.\n\n\n// These are the three commands accepted.\nconst all = \"ALL\"; // Allow all message to pass\nconst block = \"BLOCK\"; // Block repeat message (of same topic)\nconst one = \"ONE\"; // Allow ONE message to pass. (may not be perfect)\nconst stop = \"STOP\"; // Block ALL message... ALL!\n\nlet previousMode;\nlet newval;\n\n// Get topic. Set to `BLANK` if nothing else.\nlet topic = msg.topic;\nif (topic == \"\")\n topic = \"BLANK\";\nif (topic == null)\n topic = \"BLANK\";\nif (msg.topic == undefined)\n topic = \"BLANK\";\n\n////////////////////////////////////////////////////////////////////////////////\n////////////////////////////////////////////////////////////////////////////////\n// Get all `env` letiables working here.\n// Get which part of the message to use.\n\n// Get the topic used to determine which messages are to control the mode.\nlet CTLTopic = env.get(\"TOPIC\");\nif (CTLTopic.length < 1)\n throw \"You must define a TOPIC for controlling the node\";\n//------------------\n\n// Get which part of the message is to be used.\nconst part = env.get(\"msg_part_to_scan\");\nif (part.length < 1)\n throw \"You must define which part of the message to scan\";\n// Set `newval` from incoming message.\n//newval = msg[part]; // Extract the desired part of the message.\nnewval = RED.util.getMessageProperty(msg,part); // Extract the desired part of the message.\n//------------------\n\n// Get the topic_mode. This means that the msg.topic is used in filtering if `true`.\nlet topic_mode = env.get(\"topic_mode\");\nif (topic_mode.length < 1) // If it is not set...\n topic_mode = \"false\";\nif (topic_mode == \"false\")\n topic = \"BLANK\"; // Set to \"BLANK\" to give it at least a constant topic.\n//------------------\n\n// Error is `MODE` is not set.\nlet mode = context.get(\"MODE\");\nif (mode.length < 1)\n throw \"You must set a MODE: ALL, STOP, BLOCK or ONE\";\n//------------------\n\n\n\n//&&//&&//&&//&&//&& End of setup\n\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n// Change node's MODE.\nif (msg.topic == CTLTopic) {\n //\n // Set how node works.\n //\n\n if (msg.payload == stop) {\n node.status({ text: \"Set to stop\" });\n context.set(\"MODE\", msg.payload);\n node.warn(\"Set to STOP\");\n } else if (msg.payload == block) {\n node.status({ text: \"Set to block\" });\n context.set(\"MODE\", msg.payload);\n node.warn(\"Set to BLOCK\");\n } else if (msg.payload == all) {\n node.status({ text: \"Set to allow\" });\n context.set(\"MODE\", msg.payload);\n node.warn(\"Set to ALL\");\n } else if (msg.payload == one) {\n // context.set(\"previousMode\",context.get(\"MODE\"));\n context.set(\"previousMode\", mode);\n // node.warn(\"132 Previous mode \" + context.get(\"MODE\"));\n node.status({ text: \"Set to one\" });\n context.set(\"MODE\", msg.payload);\n mode = context.get(\"MODE\");\n }\n return;\n}\n////////////////////////////////////////////////////////////////////////////////\n\n\n// Used to determine if a message was received to change the mode.\nlet updated_mode = context.get(\"updated_mode\") || 0;\n\n// Get the previous stored value.\nlet lastval = context.get(topic);\n\n\n// -- Main code starts here.\n\n// =============== STOP\nif (mode == stop) {\n return;\n}\n// =============== ALL\nelse if (mode == all) {\n node.status({ fill: \"blue\", shape: \"dot\", text: \"All\" });\n context.set(topic, newval);\n return msg;\n}\n// =============== BLOCK\nelse if (mode == block) {\n //\n // See if the new value is different to the old value.\n //\n if (newval != lastval) {\n context.set(topic, newval);\n node.status({ fill: \"green\", shape: \"dot\", text: \"Passed\" });\n return msg;\n }\n node.status({ fill: \"red\", shape: \"dot\", text: \"Blocked\" });\n return;\n}\n// =============== ONE\nelse if (mode == one) {\n //\n // Allow only 1 message to pass\n //\n // mode = context.get(\"MODE\");\n previousMode = context.get(\"previousMode\");\n // context.set(\"MODE\",context.get(\"previousMode\"));\n context.set(\"MODE\", previousMode);\n context.set(topic, newval);\n //\n node.status({ text: \"Set to \" + previousMode });\n return msg;\n}\n","outputs":1,"timeout":"","noerr":0,"initialize":"let default_mode = env.get(\"DEFAULT_MODE\");\ncontext.set(\"MODE\", default_mode);\nnode.status({ text:default_mode });","finalize":"","libs":[],"x":360,"y":130,"wires":[[]]},{"id":"197b01d950cf86b4","type":"status","z":"5a6ca5972b0f9e7b","name":"","scope":["685360a3.c08db8"],"x":310,"y":190,"wires":[[]]},{"id":"a1f2cad54a9a24b1","type":"catch","z":"5a6ca5972b0f9e7b","name":"","scope":["685360a3.c08db8"],"uncaught":false,"x":320,"y":240,"wires":[["9b815fe0cfb88e40"]]},{"id":"9b815fe0cfb88e40","type":"function","z":"5a6ca5972b0f9e7b","name":"Upsend error message","func":"const id = env.get(\"NR_NODE_PATH\");\nconst ids = id.split(\"/\");\nconst errr = `Something went wrong in subflow (See source number below).\\nopen the _error.source object (below) to get more details`;\nmsg.source = ids[1];\nnode.error(errr, msg);\n \n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":240,"wires":[[]]},{"id":"7bc21e6578052640","type":"function","z":"d65ab744.465758","name":"function 56","func":"msg = {\"payload\":\"Offline\",\"topic\":\"1.144.25.184\",\"_msgid\":\"99c94b6499d64b62\",\"device\":\"UpLink\",\"IP\":\"1.144.25.184\",\"_event\":\"node:ca7b2a2f.da6688\"}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":1760,"wires":[["9883153d1bbb687d"]]},{"id":"0cde48fcad47998d","type":"inject","z":"d65ab744.465758","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":1760,"wires":[["7bc21e6578052640"]]},{"id":"9883153d1bbb687d","type":"subflow:5a6ca5972b0f9e7b","z":"d65ab744.465758","name":"","env":[{"name":"TOPIC","value":"MODE","type":"str"},{"name":"DEFAULT_MODE","value":"ALL","type":"str"},{"name":"msg_part_to_scan","value":"payload","type":"str"}],"x":650,"y":1760,"wires":[["f2e39c2f0ed71175"]]},{"id":"47615e8b9b5ed5c0","type":"function","z":"d65ab744.465758","name":"function 57","func":"msg = {\"payload\":\"1.144.25.184\",\n \"topic\":\"1.144.25.184\",\n \"device\":\"UpLink\",\n \"IP\":\"1.144.25.184\",\n \"_event\":\"node:99f3baf.756be48\",\n \"filename\":\"/home/pi/.node-red/public/uplink.txt\"}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":1820,"wires":[["9883153d1bbb687d"]]},{"id":"cdb430dcc2c4f89a","type":"inject","z":"d65ab744.465758","name":"BLOCK","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"MODE","payload":"BLOCK","payloadType":"str","x":490,"y":1630,"wires":[["9883153d1bbb687d"]]},{"id":"c3d3c4280707c5c0","type":"inject","z":"d65ab744.465758","name":"ALL","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"MODE","payload":"ALL","payloadType":"str","x":490,"y":1660,"wires":[["9883153d1bbb687d"]]},{"id":"33678f1f777e371f","type":"inject","z":"d65ab744.465758","name":"STOP","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"MODE","payload":"STOP","payloadType":"str","x":490,"y":1690,"wires":[["9883153d1bbb687d"]]},{"id":"76e48f9f6cb39de8","type":"inject","z":"d65ab744.465758","name":"ONE","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"MODE","payload":"ONE","payloadType":"str","x":490,"y":1720,"wires":[["9883153d1bbb687d"]]},{"id":"f2e39c2f0ed71175","type":"debug","z":"d65ab744.465758","name":"debug 2537","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":840,"y":1760,"wires":[]},{"id":"f0cfc9d0a0689a8c","type":"inject","z":"d65ab744.465758","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":1820,"wires":[["47615e8b9b5ed5c0"]]}]
Setting the node to ALL
or BLOCK
makes no difference.
NO ERRORS happen.
It works fine.
Yeah, ok. NR versions?
Faulty machine:
3.0.2
Working machine
3.1.5
Node versions:
Faulty machine,
Working machine,
Same:
16.20.2
Ok, I shall do tests on the Faulty machine - and that is not fair on it, as I am not sure it is. But for the sake of distinguishing the two.....
There is a SUBFLOW (yeah, sorry) but it isn't rocket science what it does.
It is just a slightly tweaked controllable that either lets messages through, blocks repeats, lets only ONE through or blocks all.
I'm stuck how to track down the problem.
Anyone?
And yes, I've stuck debug nodes all over the place, but it is kinda difficult on the faulty machine when it is LIVE and doing a lot more other stuff to diagnose the problem.
UPDATE
I copied that example flow into a spare page/tab on the faulty machine.
It works.
So, now it raises the question:
WHAT'S GOING ON with the msg.payload
I copied from the (as best I could get) source?
(Third picture)
Ok, it may not be THAT message, but what goes in wasn't changing.
Just it was not the usual message when my UPLINK is working.
P.S.
Could/would you mind checking the subflow
that it is sending the correct information up to the parent flow?
that is done in the upsend error message
function
node that is connected to the catch
node in the subflow
.
As, if it is not giving me the right information, that's probably half/most of the problem.