Adding items to opc-ua server contrib-opcua

Hi all,

we installed counters for compressed-air-usage here in our factory, after getting their values into nodered,
now i want to make their values available for third party software by opc-ua.

I set up a OPC-UA server using contrib opc-ua. Now i am having trouble to add items/variables to the server.

this is what my flow looks like:

Item Node:



Available tree in third party software:


Are there additonal things in my flow needed to have the variables appear in the tree?
Maybe somebody can provide a sample flow, where variables are added to the OPC-server.
Server connection works fine.

Look examples folder and file OPCUA-TEST-NODES.json
It contains multiple examples and also addFolder and addVariable commands.

You meant the examples section in the nodered GUI? OPCUA doesn´t appear there for me.
Would you be so kind and copy paste a flow here for me?

Edit: Found it on your github :slight_smile:

1 Like

After some playing around I was able to create a folder on the OPCUA-Server and store variables/values there. So first progress :smiley: Now I am curious about the servers behaviour in case of powerloss/ nodered crash.
I adressed the variables by their indentifiers after creating them on serverside.


Are these identifiers persistent after being created once or am I going to run into trouble?
Because I tried restarting the server and saw that it initially came back "empty", and all folders and variables had to be set again?

Use inject node that will always inject once as flow starts.
Another option is to save XML and then load it always as server starts.
Study examples and OPCUA-TEST-NODES.json there is tab with server.

Hi Mika,

I am trying the XML-way right now, but when try to save the xml, i get a warning and nothing is written to the xml:


This one works, so check your path that folder is existing and you have access rights to write file.


I tried again and made sure there is access to the file, but i´m still stuck with the same error.

I know the following screenshot is in german but it says: Access: Read & Write


Try relative path as I have tested this case.

Code checks only msg.payload & msg.filename are defined. Optional msg.topic is used to save different namespaces.

 case "saveAddressSpace":
                        if (msg.payload && msg.filename) {
                            // Save current server namespace objects to file
                            var namespace = addressSpace.getOwnNamespace(); 
                            // Use msg.topic to select namespace
                            if (msg.topic) {
                                verbose_log("Saving namespace index: " + msg.topic);
                                namespace = addressSpace.getNamespace(parseInt(msg.topic));
                            if (namespace) {
                                const xmlstr = namespace.toNodeset2XML();
                                fs.writeFileSync(msg.filename, xmlstr.toString(), {encoding: "utf8"});
                            else {
                                verbose_warn("No namespace to save to XML file, check namespace index: " + msg.topic);
                        else {
                            verbose_warn("Check msg object, it must contain msg.filename for the address space in XML format!");

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.