Configuring OPC UA NodeID Topics for Siemens Comfort Panels in Node-RED
When a Node-RED Inject node is wired into an node-red-contrib-opcua Read or Subscribe node, the msg.topic property must contain a syntactically correct OPC UA NodeID. A malformed or placeholder string is the most common reason the OPC UA client returns the BadNodeIdUnknown status code (0x80340000) or the read operation is silently dropped. This reference documents the exact ns=4;s=<TagName> addressing convention used by SIMATIC HMI Comfort Panels, the steps to discover NodeIDs without trial-and-error, and the verification path on the IOT2020 gateway.
1. The OPC UA NodeID Addressing Scheme
The NodeID is the unique address of any node in an OPC UA server's address space. The OPC UA Modelling Concepts specification (OPC-11030) defines six possible identifier shapes. The two encountered on Comfort Panels are the string identifier and the numeric identifier:
| Syntax | Identifier type | Example | Typical use |
|---|---|---|---|
ns=<i>;s=<string> |
String | ns=4;s=Tag1 |
HMI tags, PLC data blocks, method arguments |
ns=<i>;i=<numeric> |
Numeric | ns=0;i=2253 |
OPC UA base information model (Server, ServerStatus, etc.) |
nsu=<uri>;s=<string> |
URI + string | nsu=http://siemens.com/ia/...;s=Tag1 |
Server-defined namespace URI when the index is unknown |
Three fields are mandatory for every NodeID written into a Node-RED topic:
- Namespace index – zero-based integer prefixing the address. Index 0 is reserved for the OPC UA base namespace; index 1 is the server's own internal namespace; user-defined tag namespaces start at 2.
-
Identifier type –
s=for string,i=for integer,g=for GUID,b=for opaque. - Identifier value – the symbolic tag name as it appears in the TIA Portal tag table.
2. Namespace Layout of a SIMATIC Comfort Panel
Comfort Panels expose their internal tag table through an embedded OPC UA server. The address space is published as soon as the OPC UA Server option is activated in the panel project. The published namespace layout follows Siemens' IA namespace assignment:
| Index | URI | Contents |
|---|---|---|
| 0 | http://opcfoundation.org/UA/ |
OPC UA base types (Object, Variable, Method, ReferenceType, DataType) |
| 1 | Server URI (e.g. urn:siemens:simatic:hmi:opcua) |
Server object, namespaces folder, vendor info |
| 2 | Reserved for vendor extensions | Siemens-specific diagnostic nodes |
| 3 | Reserved for vendor extensions | Alarms & conditions |
| 4 | Project URI (default application namespace) | HMI tags from the standard tag table and any connected PLC tags exposed by the panel |
Because HMI tags land in namespace index 4 by default, the canonical NodeID for a tag named Tag1 is:
ns=4;s=Tag1
If the project owner has reassigned the application namespace URI, use the URI form to remain portable across panel variants:
nsu=http://www.siemens.com/simatic-hmi/Tag1;s=Tag1
3. Prerequisites
- SIMATIC IOT2020 or IOT2040 with the IOT2000 SD card image, Node.js 14.x or 18.x, Node-RED v3.x.
-
node-red-contrib-opcuav0.2.x or later installed via the palette manager. - SIMATIC HMI Comfort Panel (KP700 Comfort, TP900 Comfort, TP1200 Comfort, or similar) with firmware V14.0.0.4 or later. The OPC UA server feature requires a WinCC RT license with the OPC UA Server option activated.
- TIA Portal V16 or later engineering station, project file containing the panel, at least one HMI tag defined in the standard tag table.
- Ethernet connectivity between the IOT2020 and the panel on the same subnet; the panel's OPC UA Server Port (default
4840) must be reachable. - OPC UA client for discovery – the Unified Automation UA Expert is the de-facto reference browser and is free for non-commercial use.
4. Enabling the OPC UA Server on a Comfort Panel
Open the panel project in TIA Portal and follow the activation steps before attempting any external read.
- Select the Comfort Panel device in the project tree.
- Open Properties → General → OPC UA Server.
- Set Activate OPC UA Server =
true. - Confirm the Server port (default
4840) and Discovery URL; the resulting endpoint becomesopc.tcp://<Panel-IP>:4840. - Under Security policies, at minimum allow None for commissioning; tighten to Basic128Rsa15 or Basic256Sha256 with SignAndEncrypt for production.
- Compile and download the project to the panel. The OPC UA Server runtime must be running – check the panel's Diagnostics → Runtime view.
- Verify the server is reachable:
telnet <Panel-IP> 4840from the IOT2020 shell should open a TCP connection.
5. Discovering NodeIDs without Guesswork
5.1 Using UA Expert (recommended)
UA Expert performs a complete address-space browse, removing any ambiguity about namespace index, identifier type, and casing.
- Add a new server: Add Server → Custom Discovery, enter
opc.tcp://<Panel-IP>:4840. - Trust the endpoint and connect.
- Expand Root → Objects → Server; the project namespace appears as a folder named after the project URI.
- Drill into the project folder to expose every HMI tag from the standard tag table.
- Drag a tag into the Data Access View; the NodeId column shows the canonical form, e.g.
ns=4;s=Tag1. Right-click → Copy NodeId for use in Node-RED.
5.2 Exporting an OPC UA XML file from TIA Portal
For S7-1500 PLCs, TIA Portal exposes PLC properties → OPC UA → Server interfaces → Export OPC UA XML. The exported file lists every NodeID and its data type. Comfort Panels historically do not provide this menu path. The two reliable alternatives are:
- Browse with UA Expert as described above.
- Use the TIA Portal Cross-references and Tag table export (CSV) and prepend
ns=4;s=to each tag name manually. This works because the standard tag table is the source of truth for namespace 4.
5.3 Programmatic discovery with a UA client library
For higher-channel-count applications, run a one-off Browse service from any OPC UA client library (open62541, python-opcua, node-opcua) and write the resulting NodeIDs to a CSV that the Node-RED flow consumes at startup.
6. Step-by-Step: Wiring the Node-RED Flow
The complete flow consists of three nodes: an Inject that sets the topic, an OpcUa-Client configured as Read, and a Debug tab to display the response.
-
Inject node. Drag Inject from the function palette. Set Payload =
timestamp(or any value – it is ignored by the Read node). Open msg properties and addtopic=ns=4;s=Tag1. Multiple tags are supported by entering one NodeID per line. -
OpcUa-Client (Read) node. Create a new Endpoint:
opc.tcp://<Panel-IP>:4840, set Security Policy and Security Mode to match the panel, leave Authentication as Anonymous during commissioning. Set Action = read and check Use topic from input message so the Injectmsg.topicdrives the read list. - Debug node. Set Output = complete msg object to expose the StatusCodes, timestamps, and DataValue objects returned by the server.
- Wire Inject → OpcUa-Read → Debug and deploy.
The Inject payload in JSON form:
{
"payload": 1700000000000,
"topic": "ns=4;s=Tag1"
}
For batch reads, the topic accepts a line-delimited list:
ns=4;s=Tag1
ns=4;s=Tag2
ns=4;s=TemperatureSensor
7. Verification
Confirm the flow is reading real values, not status placeholders:
- Click the Inject button. The Debug pane must show a
msg.payloadobject containingStatusCode: Good (0x00000000)and a numericvaluematching the live tag. - Change the tag value in the panel runtime or in the TIA simulation; a second Inject click must reflect the new value within the configured sampling interval (default 1000 ms).
- Cross-check with UA Expert: read the same NodeID in the Data Access View; values must agree to the bit.
- Force a malformed read by setting
topic=ns=4;s=DoesNotExist. The Debug pane must surfaceStatusCode: BadNodeIdUnknown (0x80340000), proving the read path is functional and the error is purely a string issue.
8. Node-RED Function-Node Patterns
When the topic is built dynamically from upstream context (e.g. a dashboard dropdown or a CSV lookup), place a function node between the Inject and the OpcUa-Read node to assemble the NodeID:
// Build NodeID from a human-readable tag name
const tagName = msg.payload.name; // e.g. "MotorSpeed"
msg.topic = "ns=4;s=" + tagName;
return msg;
For Subscribe-mode use cases (continuous monitoring), the same topic format applies, but the action on the OpcUa-Client node is set to Subscribe and the Interval is set in milliseconds.
9. Troubleshooting Matrix
| Symptom | Status code | Likely cause | Corrective action |
|---|---|---|---|
| Debug pane empty; gauge grey | No response | Inject msg.topic missing or blank |
Set msg.topic to a valid NodeID; enable Use topic from input message on the OpcUa-Read node |
| Bad status from server | BadNodeIdUnknown (0x80340000) |
Namespace index wrong, tag name misspelled, or tag not in standard tag table | Browse with UA Expert; confirm tag exists in the panel project |
| Connect timeout | BadCommunicationError |
Port 4840 blocked, panel server not running, certificate not trusted | Test with telnet; verify runtime; exchange certificates |
| Connect refused | BadConnectionClosed |
OPC UA server option not activated in panel project | Enable OPC UA Server in TIA Portal, recompile, download |
| Auth required | BadIdentityTokenRejected |
Server requires Username/Password, client set to Anonymous | Set the OpcUa-Client endpoint to UserName and supply credentials |
| Wrong value type | BadTypeMismatch |
Reading a string tag as a number or vice versa | Match the data type in the Inject payload and the OpcUa-Read node configuration |
| Stale value |
Good (0x00000000) but no update |
Subscribe interval too long, or tag is not updated in the panel | Lower the sampling interval, force a tag change, check panel scan cycle |
| Intermittent disconnects | BadServerNotConnected |
Keep-alive timeout; security policy mismatch | Match the Security Policy / Mode on both sides; check firmware compatibility |
10. Security Considerations for Production
Anonymous-Plus-None is convenient for commissioning but exposes every tag to any device on the network. Hardening steps:
- Move to Security Policy = Basic256Sha256 with SignAndEncrypt. Both the panel firmware and the IOT2020 must support the cipher; Comfort Panels support it from V14.0.0.4 onwards.
- Issue an OPC UA user credential on the panel under Properties → OPC UA Server → User administration and assign only the read access level required by the gateway.
- Restrict the OPC UA port at the network layer. The IOT2020 can apply an iptables rule limiting the source IP range:
iptables -A INPUT -p tcp --dport 4840 -s 192.168.0.0/24 -j ACCEPT
iptables -A INPUT -p tcp --dport 4840 -j DROP
- Replace the panel's self-signed certificate with one issued by the plant PKI; both the OPC UA client and the OPC UA server certificate stores must be updated accordingly.
- For industrial edge-to-cloud scenarios, the panel can serve as the OPC UA data source for a downstream Azure IoT Operations OPC UA Connector; the same
ns=4;s=<TagName>addressing is used when mapping the asset endpoint profile.
11. Extending the Flow
Once the basic Read flow is operational, the same NodeID format extends to:
- Subscribe – set the OpcUa-Client action to Subscribe, specify the Interval in milliseconds, and the Debug pane emits a new message on every change of value within the server's sampling cycle.
-
Write – set the action to Write and provide a
msg.payloadwhosevaluefield matches the tag's data type. Used to drive setpoints from the IOT2020 back into the panel. -
Browse – set the action to Browse with no
msg.topicto enumerate the full address space, then cache the results in a function node for diagnostic dashboards. -
Multi-server aggregation – configure one OpcUa-Client endpoint per panel and use a function node to merge results; the topic carries the same
ns=4;s=<Tag>shape across all panels.
12. Validation Checklist
- [ ] OPC UA Server is activated in the panel project and the runtime reports OPC UA server running.
- [ ] Port 4840 is reachable from the IOT2020 (confirmed by
telnet). - [ ] Certificates are mutually trusted on both sides.
- [ ] UA Expert can browse and read the target tag with the same NodeID that Node-RED uses.
- [ ] Inject node carries a non-empty
msg.topicin the formns=4;s=<TagName>. - [ ] OpcUa-Read node has Use topic from input message enabled.
- [ ] Debug pane shows
StatusCode: Good (0x00000000)and a numericvalue. - [ ] Forcing a known-bad NodeID returns
BadNodeIdUnknown (0x80340000), confirming the read path is functional.
13. Frequently Asked Questions
What is the exact Inject node topic for a tag called Tag1 on a Comfort Panel?
Use ns=4;s=Tag1. The ns=4 namespace is the default application namespace used by the panel's OPC UA server, and s= declares a string identifier equal to the symbolic tag name in the standard tag table.
Why does my read return BadNodeIdUnknown even though the tag exists in TIA Portal?
Either the namespace index is wrong (browse with UA Expert to confirm the live index), the identifier type prefix s= is missing, or the tag is in a user-defined tag table that is not flagged as standard. Recompile the panel project after moving the tag to the standard tag table.
How can I find the NodeIDs of every HMI tag at once?
Connect with UA Expert, browse Root → Objects → Server → <Project URI>, and right-click → Copy NodeId for each tag. For PLC projects an Export OPC UA XML action is available in TIA Portal, but it is not exposed on Comfort Panels; the CSV export of the tag table is the closest equivalent and can be post-processed to prepend ns=4;s=.
Can I write values back to the panel from the IOT2020?
Yes. Configure the OpcUa-Client node with action write, send msg.topic = ns=4;s=TagName and a typed msg.payload.value (number, boolean, or string) that matches the tag's data type. The panel must be configured to accept external writes; restrict the access level in the panel's OPC UA user administration for production.
Is ns=4 the same for every Comfort Panel?
No, it is the default, but TIA Portal can re-map namespace indices when the OPC UA server interface is customised. The robust way to address a tag without depending on the index is the URI form nsu=<project-uri>;s=<TagName>, which the node-red-contrib-opcua client also accepts.