Dynamic tag lists with OPC UA
When getting data from OPC UA servers into a flow using the OPC UA Subscriber or Reader modules there are 3 ways to specify which tags (nodeIds) to get:
- List them in the module settings.
- List them in a resource file.
- Provide them dynamically as part of the flow.
The first two are the most common, but sometimes the third option is useful and this is the focus of this article.
The OPC UA Reader/Subscriber modules can receive a list of nodeIds on the incoming messages, by assigning a list on a specific property (same format as the resource files):
"opcuareader": { "nodeids": [ { "nodeId": "ns=2;i=4", "name": "test1" }, { "nodeId": "ns=2;i=5", "name": "test2" } ] }
These lists can be updated at any time and the data to get will be a combination of all nodeIds defined through any of the three methods mentioned above.
Some examples of using this functionality:
- You want to automatically update the list of tags based on changes in the OPC UA server, e.g. tags are added or removed. To do this you can use the OPC UA Browser module to get an updated list, optionally filter the list using the Array Filter module, and send the updated list to the OPC UA Reader/Subscriber module. Based on the expected frequency of updates you can decide when to run this part of the flow.
- You have the list of nodeIds stored somewhere else, e.g. in a database. Then add modules to get data from the external system and feed it into the OPC UA modules. Trigger the extraction of the external data using an external trigger, or do periodic updates to make sure the latest tag list is being used by the flow.