OPC-UA
This documentation will help you set up the OPC-UA connector for the ThingsBoard IoT Gateway. We’ll explain the configuration parameters in simple terms to make it easy for you to understand and follow. The OPC-UA (Open Platform Communications Unified Architecture) is a machine-to-machine communication protocol for industrial automation, and this connector allows seamless integration with the ThingsBoard platform. Use general configuration to enable this connector.
Also, if you are new to ThingsBoard IoT Gateway, we recommend you to read the Getting Started guide to understand the basic concepts of ThingsBoard IoT Gateway and how it works with OPC-UA protocol.
The connector can be configured via the user interface form, which helps you set up a connection to the OPC-UA server, collect data and write data to nodes. Let’s look at all the available settings and explain each one clearly. This will help you understand how everything works.
Configuration modes
Section titled “Configuration modes”The OPC-UA connector can be configured in two modes: Basic and Advanced.
- Basic mode is designed for users who are new to ThingsBoard IoT Gateway and want to quickly set up the connector with minimal configuration. It provides a simplified interface with essential settings.
- Advanced mode is intended for experienced users who need more control over the configuration. It offers additional options and flexibility for advanced use cases.
You can switch between these modes using the toggle button at the top of the configuration page:
General settings
Section titled “General settings”This configuration section contains general connector settings, such as:
- Name - connector name used for logs and saving to persistent devices;
- Logs configuration - settings for local and remote logging:
- Enable remote logging - enables remote logging for the connector;
- Logging level - logging level for local and remote logs: NONE, ERROR, CRITICAL, WARNING, INFO, DEBUG, TRACE;
- Report strategy - strategy for sending data to ThingsBoard:
- Report period - period for sending data to ThingsBoard in milliseconds;
- Type - type of the report strategy:
- On report period - sends data to ThingsBoard after the report period;
- On value change - sends data to ThingsBoard when the value changes;
- On value change or report period - sends data to ThingsBoard when the value changes or after the report period;
- On received - sends data to ThingsBoard after receiving data from the device (default strategy).
Connection settings
Section titled “Connection settings”Connection settings define how the OPC-UA connector establishes and maintains communication with the OPC-UA server. These settings cover the basic connection parameters, server discovery behavior, security configuration, and authentication modes.
Server
Section titled “Server”This subsection specifies the target OPC-UA server and how the gateway interacts with it. It includes the server’s URL, timeout settings, scan intervals, and the option to use either subscriptions or polling to monitor data nodes.
This configuration section contains settings of the OPC-UA server connection, such as:
- Server endpoint url - hostname or ip address of OPC-UA server;
- Timeout in milliseconds - timeout in milliseconds for connecting to OPC-UA server;
- Security policy - security policy (Basic128Rsa15, Basic256, Basic256Sha256);
- Scan period in milliseconds - period in milliseconds to rescan the server;
- Poll period - period in milliseconds to poll the server;
- Subscription check period in milliseconds - period to check the subscriptions in the OPC-UA server;
- Enable subscription - if true - the gateway will subscribe to interesting nodes and wait for data update and if false - the gateway will rescan OPC-UA server every scanPeriodInMillis;
- Show map - show nodes on scanning true or false.
Security
Section titled “Security”OPC-UA server connections offer three distinct security types:
-
Anonymous - the simplest option of identity;
-
Basic - using this option, you can provide the username and password to connect to the OPC-UA server;
-
Certificates - the safest option of identity. Using this option, you can also provide path on machine with the gateway to certificate, private key and CA certificate. Optionally, you can provide the username/password pair.
Data mapping
Section titled “Data mapping”Data mapping is a section that allows you to configure which node from the OPC-UA server will be assigned to which device in ThingsBoard. You can also use this section to configure which data will be sent as device attributes or telemetry. Data mapping contains all the necessary settings for flexible device and data management.
The following parameters are used to configure the base node of the device, its name and profile, as well as for report strategy:
- Device node - the base node for the device. Paths to the device name, profile, attributes, and telemetry can be specified relative to this node.
- Device name - the name of the device in ThingsBoard. It can be specified as a path or identifier to the node or as a static value (more information about types can be found in the Additional information section).
- Device profile - the profile of the device in ThingsBoard. It can be specified as a path or identifier to the node or as a static value (more information about types can be found in the Additional information section).
- Report strategy - strategy for sending data to ThingsBoard:
- Report period - period for sending data to ThingsBoard in milliseconds;
- Type - type of the report strategy:
- On report period - sends data to ThingsBoard after the report period;
- On value change - sends data to ThingsBoard when the value changes;
- On value change or report period - sends data to ThingsBoard when the value changes or after the report period;
- On received - sends data to ThingsBoard after receiving data from the device (default strategy).
To add a new device, use the following steps:
-
Click the + Add mapping button.
-
Provide the following fields in the opened model window: Device node, Device name and Profile name (all of them can be
pathoridentifier).
Subsection “Attributes” and “Time series”
Section titled “Subsection “Attributes” and “Time series””The configuration in this subsection provides settings for processing data from the OPC-UA node. These settings will be interpreted in ThingsBoard platform instance as attributes/time series of the device.
The following parameters are used to configure device attributes and time series:
- Key - the key of the attribute/time series in ThingsBoard. It can be specified as a static value.
- Type - the type of expression in the Value field (more information about types can be found in the Additional information section):
- Path - can be absolute or relative path to the node in the OPC-UA server. The value will be taken from the node with the specified path.
- Identifier - can be numeric, string, byte string or GUID identifier of the node in the OPC-UA server. The value will be taken from the node with the specified identifier.
- Constant - a static value that will be sent to the device as an attribute/time series key.
- Value - the value of the attribute/time series that will be sent to the platform device. It should be specified depending on the selected type (Path, Identifier or Constant).
To add new time series or attribute key, follow these steps:
-
Click the “pencil” icon in the “Attributes” section to add new attribute key;
-
Click on “Add attribute” in the opened window;
-
Enter the “Key” field, select the “Type” (can be path, identifier or constant), enter “Value” and click “Apply” button;
-
Now click on the “pencil” icon in the “Time series” section to add new time series key;
-
Click on “Add time series” in the opened window;
-
Enter the “Key” field, select the “Type” (can be path, identifier or constant), enter “Value” and click “Apply” button.
You can enable a specific report strategy for each time series or attribute. This strategy defines how often data is sent to the ThingsBoard server. The following strategies are available:
- On report period - sends data to ThingsBoard after the report period;
- On value change - sends data to ThingsBoard when the value changes;
- On value change or report period - sends data to ThingsBoard when the value changes or after the report period;
- On received - sends data to ThingsBoard after receiving data from the device (default strategy).
Usage examples
Section titled “Usage examples”- Device name/profile with Absolute Path
- Device name/profile with Relative Path
- Device name/profile with Identifier
- Attributes/Time series with Relative Path
- Attributes/Time series with Relative Path and Identifier device node
- Attributes/Time series with Absolute Path
- Attributes/Time series with Identifier
The device name and profile can be set dynamically using node values. In this example, we will use an absolute path to specify the device name and profile.
As an example, we will use Prosys OPC-UA Simulation Server, which is available at
opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer. The server has the following structure:
We are interested in nodes: “DeviceModelName” and “DeviceSeries”. We will use these nodes to set the device name and profile, respectively.
Let’s configure the device name and profile in the OPC-UA connector. For this purpose, follow these steps:
Go to “Entities” → “Gateways” in the right sidebar and select your gateway.
Click on the “Connectors configuration” button on the right side menu.
Select the created OPC-UA connector, click on the “Data mapping” tab. Firstly, we need to configure parent (or device) node. Click on the ”+ Add mapping” button.
In the opened window, fill in “Device node” field with
Root\.Objects\.DemoDevice, also select “Path” in “Source” field. This is an absolute path to the parent node of the device we want to create.In the “Name” field, enter
${Root\.Objects\.DemoDeviceInfo\.DeviceModelName}, also select “Path” in “Source” field. This is an absolute path to the node that contains the device name.In the “Profile name” field, enter
${Root\.Objects\.DemoDeviceInfo\.DeviceSeries}, also select “Path” in “Source” field. This is an absolute path to the node that contains the device profile.Also, we need to add one attribute/time series because the connector will not add a device without any data to read (you can use any pre-installed Prosys OPC-UA Simulation Server node). Click on the “pencil” icon next to the “Attributes” section.
In the opened window, click on the “Add attribute” button and fill the fields as on the corresponding image.
Remember to save your changes by clicking the “Save” button.
Now we can check if the device name and profile are set correctly. Go to “Entities” > “Devices” and as you can see, the device
name is set to Demo Device and the profile is set to Demo Series.
If you are using advanced configuration mode and want to set the device name and profile using an absolute path, you can use the following configuration:
{ "name": "OPC-UA", "server": { "url": "opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "pollPeriodInMillis": 5000, "enableSubscriptions": false, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" } }, "mapping": [ { "deviceNodeSource": "path", "deviceNodePattern": "Root\\.Objects\\.DemoDevice", "deviceInfo": { "deviceNameExpression": "${Root\\.Objects\\.DemoDeviceInfo\\.DeviceModelName}", "deviceNameExpressionSource": "path", "deviceProfileExpressionSource": "path", "deviceProfileExpression": "${Root\\.Objects\\.DemoDeviceInfo\\.DeviceSeries}" }, "attributes": [ { "key": "some_key", "type": "identifier", "value": "${ns=3;i=1001}" } ], "timeseries": [], "rpc_methods": [], "attributes_updates": [] } ]}The device name and profile can be set dynamically using node values. In this example, we will use a relative path to specify the device name and profile.
As an example, we will use Prosys OPC-UA Simulation Server, which is available at
opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer. The server has the following structure:
We are interested in nodes: “DeviceModelName” and “DeviceSeries”. We will use these nodes to set the device name and profile, respectively.
Let’s configure the device name and profile in the OPC-UA connector. For this purpose, follow these steps:
Go to “Entities” → “Gateways” in the right sidebar and select your gateway.
Click on the “Connectors configuration” button on the right side menu.
Select the created OPC-UA connector, click on the “Data mapping” tab. Firstly, we need to configure parent (or device) node. Click on the ”+ Add mapping” button.
In the opened window, fill in “Device node” field with
Root\.Objects\.DemoDevice, also select “Path” in “Source” field. This is an absolute path to the parent node of the device we want to create.In the “Name” field, enter
${DeviceModelName}, also select “Path” in “Source” field. This is a relative path to the node that contains the device name.In the “Profile name” field, enter
${DeviceSeries}, also select “Path” in “Source” field. This is a relative path to the node that contains the device profile.Also, we need to add one attribute/time series because the connector will not add a device without any data to read (you can use any pre-installed Prosys OPC-UA Simulation Server node). Click on the “pencil” icon next to the “Attributes” section.
In the opened window, click on the “Add attribute” button and fill the fields as on the corresponding image.
Remember to save your changes by clicking the “Save” button.
Now we can check if the device name and profile are set correctly. Go to “Entities” > “Devices” and as you can see, the device
name is set to Demo Device and the profile is set to Demo Series.
If you are using advanced configuration mode and want to set the device name and profile using a relative path, you can use the following configuration:
{ "name": "OPCUA", "server": { "url": "opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "pollPeriodInMillis": 5000, "enableSubscriptions": false, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" } }, "mapping": [ { "deviceNodeSource": "path", "deviceNodePattern": "Root\\.Objects\\.DemoDevice", "deviceInfo": { "deviceNameExpression": "${DeviceModelName}", "deviceNameExpressionSource": "path", "deviceProfileExpressionSource": "path", "deviceProfileExpression": "${DeviceSeries}" }, "attributes": [ { "key": "some_key", "type": "identifier", "value": "${ns=3;i=1001}" } ], "timeseries": [], "rpc_methods": [], "attributes_updates": [] } ]}The device name and profile can be set dynamically using node values. In this example, we will use identifier to specify the device name and profile. Identifier can be numeric, string, byte string or GUID identifier of the node in the OPC-UA server.
As an example, we will use Prosys OPC-UA Simulation Server, which is available at
opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer. The server has the following structure:
We are interested in nodes: “DeviceModelName” that have ns=3;i=1014 identifier and “DeviceSeries” that
have ns=3;i=1015 identifier. We will use these nodes to set the device name and profile, respectively.
Let’s configure the device name and profile in the OPC-UA connector. For this purpose, follow these steps:
Go to “Entities” → “Gateways” in the right sidebar and select your gateway.
Click on the “Connectors configuration” button on the right side menu.
Select the created OPC-UA connector, click on the “Data mapping” tab. Firstly, we need to configure parent (or device) node. Click on the ”+ Add mapping” button.
In the opened window, fill in “Device node” field with
Root\.Objects\.DemoDevice, also select “Path” in “Source” field. This is an absolute path to the parent node of the device we want to create.In the “Name” field, enter
${ns=3;i=1014}, also select “Identifier” in “Source” field.In the “Profile name” field, enter
${ns=3;i=1015}, also select “Identifier” in “Source” field. This is an absolute path to the node that contains the device profile.Also, we need to add one attribute/time series because the connector will not add a device without any data to read (you can use any pre-installed Prosys OPC-UA Simulation Server node). Click on the “pencil” icon next to the “Attributes” section.
In the opened window, click on the “Add attribute” button and fill the fields as on the corresponding image.
Remember to save your changes by clicking the “Save” button.
Now we can check if the device name and profile are set correctly. Go to “Entities” > “Devices” and as you can see, the device
name is set to Demo Device and the profile is set to Demo Series.
If you are using advanced configuration mode and want to set the device name and profile using an identifier, you can use the following configuration:
{ "name": "OPCUA", "server": { "url": "opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "pollPeriodInMillis": 5000, "enableSubscriptions": false, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" } }, "mapping": [ { "deviceNodeSource": "path", "deviceNodePattern": "Root\\.Objects\\.DemoDevice", "deviceInfo": { "deviceNameExpression": "${ns=3;i=1014}", "deviceNameExpressionSource": "identifier", "deviceProfileExpressionSource": "identifier", "deviceProfileExpression": "${ns=3;i=1015}" }, "attributes": [ { "key": "some_key", "type": "identifier", "value": "${ns=3;i=1003}" } ], "timeseries": [], "rpc_methods": [], "attributes_updates": [] } ]}Attributes and time series data can be accessed using relative paths in the OPC UA Connector. This allows you to retrieve data without needing to specify the full path to the node.
As an example, we will use Prosys OPC-UA Simulation Server, which is available at
opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer. The server has the following structure:
We are interested in node “Humidity”. We will use this node to retrieve the humidity data.
Let’s configure the humidity data in the OPC-UA connector. For this purpose, follow these steps:
Go to “Entities” → “Gateways” in the right sidebar and select your gateway.
Click on the “Connectors configuration” button on the right side menu.
Select the OPC-UA connector, click on the “Data mapping” tab. Select data mapping with device to which you want to add time series data (if you do not know how to add a new device, see the Getting Started guide or Data mapping section of this guide with respective examples).
In the opened data mapping windows, click on the “pencil” icon next to the “Time series” or “Attributes” section.
Click on the “Add time series” button. Fill in the “Key” field with
Humidity, also select “Path” in “Type” field, and fill in the “Value” field with${Humidity}. This is a relative path to the node that contains the humidity data.Remember to save your changes by clicking the “Apply” button.
Now we can check if the humidity data is sending correctly. Go to “Entities” > “Devices”, select a created device and as you can see, the humidity data is available in the “Time series” section:
If you are using advanced configuration mode and want to set the humidity data using a relative path, you can use the following configuration:
{ "name": "OPCUA", "server": { "url": "opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "pollPeriodInMillis": 5000, "enableSubscriptions": false, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" } }, "mapping": [ { "deviceNodeSource": "path", "deviceNodePattern": "Root\\.Objects\\.DemoDevice", "deviceInfo": { "deviceNameExpression": "Demo Device", "deviceNameExpressionSource": "constant", "deviceProfileExpressionSource": "constant", "deviceProfileExpression": "default" }, "attributes": [], "timeseries": [ { "key": "Humidity", "type": "path", "value": "${Humidity}" } ], "rpc_methods": [], "attributes_updates": [] } ]}Attributes and time series data can be accessed using relative paths in the OPC UA Connector. This allows you to retrieve data without needing to specify the full path to the node. Additionally, we may use identifiers for “Device node”.
As an example, we will use Prosys OPC-UA Simulation Server, which is available at
opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer. The server has the following structure:
We are interested in node “Humidity”. We will use this node to retrieve the humidity data.
Let’s configure the humidity data in the OPC-UA connector, using relative paths. For this purpose, follow these steps:
Go to “Entities” → “Gateways” in the left sidebar and select your gateway.
Click on the “Connectors configuration” button on the right side menu.
Select the OPC-UA connector, click on the “Data mapping” tab. Select data mapping with device to which you want to add time series data (if you do not know how to add a new device, see the Getting Started guide or Data mapping section of this guide with respective examples).
In the opened data mapping windows, click on the “pencil” icon next to the “Time series” or “Attributes” section.
Click on the “Add time series” button. Fill in the “Key” field with
Humidity, also select “Path” in “Type” field, and fill in the “Value” field with${Humidity}. This is a relative path to the node that contains the humidity data.Remember to save your changes by clicking the “Apply” button.
Now we can check if the humidity data is sending correctly. Go to “Entities” > “Devices”, select a created device and as you can see, the humidity data is available in the “Time series” section:
If you are using advanced configuration mode and want to set the humidity data using a relative path, you can use the following configuration:
{ "name": "OPCUA", "server": { "url": "opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "pollPeriodInMillis": 5000, "enableSubscriptions": false, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" } }, "mapping": [ { "deviceNodeSource": "identifier", "deviceNodePattern": "ns=3;i=1008", "deviceInfo": { "deviceNameExpression": "Demo Device", "deviceNameExpressionSource": "constant", "deviceProfileExpressionSource": "constant", "deviceProfileExpression": "default" }, "attributes": [], "timeseries": [ { "key": "Humidity", "type": "path", "value": "${Humidity}" } ], "rpc_methods": [], "attributes_updates": [] } ]}Attributes and time series data can be accessed using absolute paths in the OPC UA Connector. This will allow you to get data from a node that does not refer to the parent (device) node.
As an example, we will use Prosys OPC-UA Simulation Server, which is available at
opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer. The server has the following structure:
We are interested in node “Humidity”. We will use this node to retrieve the humidity data.
Let’s configure the humidity data in the OPC-UA connector. For this purpose, follow these steps:
Go to “Entities” → “Gateways” in the right sidebar and select your gateway.
Click on the “Connectors configuration” button on the right side menu.
Select the OPC-UA connector, click on the “Data mapping” tab. Select data mapping with device to which you want to add time series data (if you do not know how to add a new device, see the Getting Started guide or Data mapping section of this guide with respective examples).
In the opened data mapping windows, click on the “pencil” icon next to the “Time series” or “Attributes” section.
Click on the “Add time series” button. Fill in the “Key” field with
Humidity, also select “Path” in “Type” field, and fill in the “Value” field with${Root\.Objects\.DemoDevice\.Humidity}. This is an absolute path to the node that contains the humidity data.Remember to save your changes by clicking the “Apply” button.
Now we can check if the humidity data is sending correctly. Go to “Entities” > “Devices”, select a created device and as you can see, the humidity data is available in the “Time series” section:
If you are using advanced configuration mode and want to set the humidity data using an absolute path, you can use the following configuration:
{ "name": "OPCUA", "server": { "url": "opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "pollPeriodInMillis": 5000, "enableSubscriptions": false, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" } }, "mapping": [ { "deviceNodeSource": "path", "deviceNodePattern": "Root\\.Objects\\.DemoDevice", "deviceInfo": { "deviceNameExpression": "Demo Device", "deviceNameExpressionSource": "constant", "deviceProfileExpressionSource": "constant", "deviceProfileExpression": "default" }, "attributes": [], "timeseries": [ { "key": "Humidity", "type": "path", "value": "${Root\\.Objects\\.DemoDevice\\.Humidity}" } ], "rpc_methods": [], "attributes_updates": [] } ]}Attributes and time series data can be accessed using identifiers in the OPC UA Connector. This will allow you to get data from a node that does not refer to the parent (device) node by identifier.
As an example, we will use Prosys OPC-UA Simulation Server, which is available at
opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer. The server has the following structure:
We are interested in node “Humidity” that have ns=3;i=1011 identifier. We will use this node to retrieve the
humidity data.
Let’s configure the humidity data in the OPC-UA connector. For this purpose, follow these steps:
Go to “Entities” → “Gateways” in the left sidebar and select your gateway.
Click on the “Connectors configuration” button on the right side menu.
Select the OPC-UA connector, click on the “Data mapping” tab. Select data mapping with device to which you want to add time series data (if you do not know how to add a new device, see the Getting Started guide or Data mapping section of this guide with respective examples).
In the opened data mapping windows, click on the “pencil” icon next to the “Time series” or “Attributes” section.
Click on the “Add time series” button. Fill in the “Key” field with
Humidity, also select “Identifier” in “Type” field, and fill in the “Value” field with${ns=3;i=1011}. This is a relative path to the node that contains the humidity data.Remember to save your changes by clicking the “Apply” button.
Now we can check if the humidity data is sending correctly. Go to “Entities” > “Devices”, select a created device and as you can see, the humidity data is available in the “Time series” section:
If you are using advanced configuration mode and want to set the humidity data using an identifier, you can use the following configuration:
{ "name": "OPCUA", "server": { "url": "opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "pollPeriodInMillis": 5000, "enableSubscriptions": false, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" } }, "mapping": [ { "deviceNodeSource": "path", "deviceNodePattern": "Root\\.Objects\\.DemoDevice", "deviceInfo": { "deviceNameExpression": "Demo Device", "deviceNameExpressionSource": "constant", "deviceProfileExpressionSource": "constant", "deviceProfileExpression": "default" }, "attributes": [], "timeseries": [ { "key": "Humidity", "type": "identifier", "value": "${ns=3;i=1011}" } ], "rpc_methods": [], "attributes_updates": [] } ]}Requests mapping
Section titled “Requests mapping”The Requests mapping section allows you to configure how the ThingsBoard platform instance will interact with the devices. That is, how the platform will request data from the devices, how it will update device attributes, and how it will send RPC commands to the devices.
OPC-UA connector supports the following requests mapping:
- Attribute updates - allows update device nodes values from ThingsBoard platform instance.
- RPC methods - allows sending RPC commands to devices. Using RPC methods, you can get or set values of the OPC-UA nodes.
OPC-UA connector supports different types of RPC methods, such as:
- Reserved GET/SET methods - these methods are automatically created for each attribute and time series parameter. You can use them to get or set values of the OPC-UA nodes.
- RPC method to connector - this method allows you to send a command to the connector from the ThingsBoard IoT Gateway UI. The command will be processed by the connector, and the result will be sent back to the ThingsBoard platform instance.
- Configurable RPC methods to device - these methods allow you to configure custom RPC commands in connector configuration that can be sent to the devices.
Subsection “Attribute updates”
Section titled “Subsection “Attribute updates””This subsection contains configuration for attribute updates request from ThingsBoard platform instance.
ThingsBoard allows the provisioning of device attributes and fetches some of them from the device application. You can treat this as a remote configuration for devices, enabling them to request shared attributes from ThingsBoard. See user guide for more details.
The following parameters are used to configure attribute updates:
- Key - the key of the shared attribute in ThingsBoard. It can be specified as a static value.
- Type - the type of expression in the Value field (more information about types can be found in the Additional information section):
- Path - can be absolute or relative path to the node in the OPC-UA server. The value will be taken from the node with the specified path.
- Identifier - can be numeric, string, byte string or GUID identifier of the node in the OPC-UA server. The value will be taken from the node with the specified identifier.
- Constant - a static value that will be sent to the device.
- Value - the node in which the shared attribute value will be written. It should be specified depending on the selected type (Path, Identifier or Constant).
In order to add new attribute update, follow these steps:
-
Click the “pencil” icon in the “Attribute updates” section to add new attribute update;
-
Click on “Add attribute update” in the opened window;
-
Enter the “Key” field, select the “Type” (can be path, identifier or constant), enter “Value” and click “Apply” button.
Subsection “RPC methods”
Section titled “Subsection “RPC methods””ThingsBoard allows sending RPC commands to devices connected directly to ThingsBoard or via Gateway. The following parameters are used to configure RPC methods:
- Method name - the name of the method on OPC-UA server.
- Arguments - list of arguments that will pass to OPC-UA server method.
In order to add new RPC method, follow these steps:
-
Click the “pencil” icon in the “RPC methods” section to add new RPC method;
-
Click on “Add method” in the opened window;
-
Fill in “Method name” field. If the method has arguments, click on “Add argument” button and select the type of argument. Fill in the “Value” field and click “Apply” button.
Usage examples
Section titled “Usage examples”Attribute updates allow you to update node values in the OPC-UA server. You can add new attribute updates in the “Attribute updates” section of the device configuration page.
As an example, we will use Prosys OPC-UA Simulation Server, which is available at opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer.
The server has the following structure:
Example: Relay Controlling (Relative Path)
Section titled “Example: Relay Controlling (Relative Path)”We are interested in node “Relay”, we added this node as a telemetry parameter with the key relay. We used
telemetry so that later it would be convenient for us to see if the value we changed using the attribute update
has changed. You, also, can add this telemetry datapoint to the device configuration or use the reserved get RPC
method to check the value of the node.
Let’s add an attribute update to our configuration. For this purpose, follow these steps:
Go to “Entities” → “Gateways” in the right sidebar and select your gateway.
Click on the “Connectors configuration” button on the right side menu.
Select the created OPC-UA connector, click on the “Data mapping” tab. Make sure you have configured and connected device (if you do not know how to do it, see Getting Started guide or Connection settings and Data mapping sections of this guide). Click on the “Pencil” icon on a device you want to configure attribute updates for.
Scroll down to the “Attribute updates” section and click on the “Pencil” icon to edit the attribute updates.
Click on the “Add attribute update” button. In our case, we will add
relayattribute update, so the “Key” field, enterrelay, select the “Type” as Path, and in the “Value” field enter${Relay}. This is a relative path to the device node we want to update.Remember to save your changes by clicking the “Apply” button.
Now we can check if the attribute update works. Go to “Entities” → “Devices” → select a created device → “Attributes” tab →
select “Shared attributes” → click on the ”+” icon and add relay attribute with type “Boolean” set it
to “True”.
Now, let’s check the value of the relay node. In the selected device, go to the “Last telemetry” tab and check the
value of the relay telemetry. It should be true since we set the shared attribute to true.
Try to change the value of the relay shared attribute to false. After a few seconds, you should see that the
relay telemetry value has changed to false, which means that the attribute update worked correctly.
Full configuration for OPC-UA connector for the examples above will look like this:
{ "server": { "url": "opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "enableSubscriptions": true, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" }, "pollPeriodInMillis": 5000 }, "mapping": [ { "deviceNodePattern": "Root\\.Objects\\.DemoDevice", "deviceNodeSource": "path", "deviceInfo": { "deviceNameExpression": "Demo Device", "deviceNameExpressionSource": "constant", "deviceProfileExpression": "default", "deviceProfileExpressionSource": "constant" }, "attributes": [], "attributes_updates": [ { "key": "relay", "type": "path", "value": "${Relay}" } ], "timeseries": [ { "key": "relay", "type": "identifier", "value": "${ns=3;i=1012}" } ], "rpc_methods": [] } ]}Attribute updates allow you to update node values in the OPC-UA server. You can add new attribute updates in the “Attribute updates” section of the device configuration page.
As an example, we will use Prosys OPC-UA Simulation Server, which is available at opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer.
The server has the following structure:
Example: Fan Speed (Absolute Path)
Section titled “Example: Fan Speed (Absolute Path)”We are interested in node “FanSpeed”, we added this node as a telemetry parameter with the key fan_speed. We used
telemetry so that later it would be convenient for us to see if the value we changed using the attribute update
has changed. You, also, can add this telemetry datapoint to the device configuration or use the reserved get method
to check the value of the node.
Let’s add an attribute update to our configuration. For this purpose, follow these steps:
Go to “Entities” → “Gateways” in the left sidebar and select your gateway.
Click on the “Connectors configuration” button on the right side menu.
Select the created OPC-UA connector, click on the “Data mapping” tab. Make sure you have configured and connected device (if you do not know how to do it, see Getting Started guide or Connection settings and Data mapping sections of this guide). Click on the “Pencil” icon on a device you want to configure attribute updates for.
Scroll down to the “Attribute updates” section and click on the “Pencil” icon to edit the attribute updates.
Click on the “Add attribute update” button. In our case, we will add
fan_speedattribute update, so the “Key” field, enterfan_speed, select the “Type” as Path, and in the “Value” field enter${Root\.Objects\.DemoDeviceInfo\.FanSpeed}. This is an absolute path to the OPC-UA server node we want to update.Remember to save your changes by clicking the “Apply” button.
Now we can check if the attribute update works. Go to “Devices” → select a created device → “Attributes” tab →
select “Shared attributes” → click on the ”+” icon and add fan_speed attribute with type “Integer” set it
to “90”.
Now, let’s check the value of the fan speed node. In the selected device, go to the “Last telemetry” tab and check the
value of the fan_speed telemetry. It should be 90 since we set the shared attribute to 90.
Try to change the value of the fan_speed shared attribute to 30. After a few seconds, you should see that the
fan_speed telemetry value has changed to 30, which means that the attribute update worked correctly.
Full configuration for OPC-UA connector for the examples above will look like this:
{ "server": { "url": "opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "enableSubscriptions": true, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" }, "pollPeriodInMillis": 5000 }, "mapping": [ { "deviceNodePattern": "Root\\.Objects\\.DemoDevice", "deviceNodeSource": "path", "deviceInfo": { "deviceNameExpression": "Demo Device", "deviceNameExpressionSource": "constant", "deviceProfileExpression": "default", "deviceProfileExpressionSource": "constant" }, "attributes": [], "attributes_updates": [ { "key": "fan_speed", "type": "path", "value": "${Root\\.Objects\\.DemoDeviceInfo\\.FanSpeed}" } ], "timeseries": [ { "key": "fan_speed", "type": "identifier", "value": "${ns=3;i=1017}" } ], "rpc_methods": [] } ]}Attribute updates allow you to update node values in the OPC-UA server. You can add new attribute updates in the “Attribute updates” section of the device configuration page.
As an example, we will use Prosys OPC-UA Simulation Server, which is available at opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer.
The server has the following structure:
Example: Text Message Editing (Identifier)
Section titled “Example: Text Message Editing (Identifier)”We are interested in node “TextMessage”, we added this node as a telemetry parameter with the key text_message.
We used telemetry so that later it would be convenient for us to see if the value we changed using the attribute update
has changed. You, also, can add this telemetry datapoint to the device configuration or use the reserved get method
to check the value of the node.
Let’s add an attribute update to our configuration. For this purpose, follow these steps:
- Go to “Entities” → “Gateways” in the right sidebar.
- Select your gateway.
- Click on the “Connectors” tab.
- Select the OPC-UA connector and click on the “Data mapping” tab.
- Make sure you have configured and connected device (if you don’t know how to do it, see Getting Started guide or Connection settings and Data mapping sections of this guide). Click on the “Pencil” icon on a device you want to configure attribute updates for.
- Scroll down to the “Attribute updates” section and click on the “Pencil” icon to edit the attribute updates.
- Click on the “Add attribute update” button. In our case, we will add
text_messageattribute update, so the “Key” field, entertext_message, select the “Type” as Identifier, and in the “Value” field enter${ns=2;i=1005}. This is an identifier of the OPC-UA server node we want to update. - Remember to save your changes by clicking the “Apply” button.
Go to “Entities” → “Gateways” in the right sidebar and select your gateway.
Click on the “Connectors configuration” button on the right side menu.
Select the created OPC-UA connector, click on the “Data mapping” tab. Make sure you have configured and connected device (if you do not know how to do it, see Getting Started guide or Connection settings and Data mapping sections of this guide). Click on the “Pencil” icon on a device you want to configure attribute updates for.
Scroll down to the “Attribute updates” section and click on the “Pencil” icon to edit the attribute updates.
Click on the “Add attribute update” button. In our case, we will add
text_messageattribute update, so the “Key” field, entertext_message, select the “Type” as Identifier, and in the “Value” field enter${ns=2;i=1005}. This is an identifier of the OPC-UA server node we want to update.Remember to save your changes by clicking the “Apply” button.
Now we can check if the attribute update works. Go to “Devices” → select a created device → “Attributes” tab →
select “Shared attributes” → click on the ”+” icon and add text_message attribute with type “String” set
it to “Hello from Gateway!”.
Now, let’s check the value of the text message node. In the selected device, go to the “Last telemetry” tab and check the
value of the text_message telemetry. It should be Hello from Gateway! since we set the shared attribute to Hello from Gateway!.
Try to change the value of the text_message shared attribute to Hello from <your_name>!. After a few seconds,
you should see that the text_message telemetry value has changed to Hello from <your_name>!, which means that the
attribute update worked correctly.
Full configuration for OPC-UA connector for the examples above will look like this:
{ "server": { "url": "opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "enableSubscriptions": true, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" }, "pollPeriodInMillis": 5000 }, "mapping": [ { "deviceNodeSource": "path", "deviceNodePattern": "Root\\.Objects\\.DemoDevice", "deviceInfo": { "deviceNameExpression": "Demo Device", "deviceNameExpressionSource": "constant", "deviceProfileExpression": "default", "deviceProfileExpressionSource": "constant" }, "attributes": [], "timeseries": [ { "key": "text_message", "type": "identifier", "value": "${ns=3;i=1018}" } ], "rpc_methods": [], "attributes_updates": [ { "key": "text_message", "type": "identifier", "value": "${ns=3;i=1018}" } ] } ]}RPC to Device allows you to execute an OPC-UA server method on a specific device. It is important to note that the method you are calling must be defined on the OPC-UA server.
As an example, we will use ThingsBoard OPC-UA Demo Server, which can be run using Docker and the following command:
docker run -it -p 4840:4840 thingsboard/tb-gw-opcua-server:latestThe server has the following endpoint URL: opc.tcp://0.0.0.0:4840/freeopcua/server/.
Example: Multiplying Numbers
Section titled “Example: Multiplying Numbers”We are interested in “multiply” method node which will multiply two numbers that we will pass as arguments. To call this method, first we need to configure the OPC-UA connector to support RPC calls. For this purpose, follow these steps:
Go to “Entities” → “Gateways” in the right sidebar and select your gateway.
Click on the “Connectors configuration” button on the right side menu.
Select the created OPC-UA connector, click on the “Data mapping” tab. Make sure you have configured and connected device (if you do not know how to do it, see Getting Started guide or Connection settings and Data mapping sections of this guide). Click on the “Pencil” icon on a device you want to configure RPC method for.
Scroll down to the “RPC methods” section and click on the “Pencil” icon to edit the RPC methods.
Click on the “Add method” button. In our case, we will add the
multiplymethod, so fill in the “Method” field withmultiplyand in the “Arguments” field, enter the arguments that the method accepts, in our case it is two numbers, feel free to enter any numbers.Remember to save your changes by clicking the “Apply” button.
We are done with configuration, so let’s check how to call the method. In the RPC Debug Terminal widget, run the following command:
multiplyIn this case, the method will be called with the arguments that we specified in the configuration (default arguments). As you remember, in our case, we enter 5 and 4, so the result is:
Also, we can pass arguments to the method directly from the RPC Debug Terminal widget using the following command:
multiply [3,4]Response:
Full configuration for OPC-UA connector for the example above will look like this:
{ "name": "OPCUA", "server": { "url": "opc.tcp://0.0.0.0:4840/freeopcua/server/", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "pollPeriodInMillis": 5000, "enableSubscriptions": false, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" } }, "mapping": [ { "deviceNodeSource": "path", "deviceNodePattern": "Root\\.Objects\\.MyObject", "deviceInfo": { "deviceNameExpression": "Demo Device", "deviceNameExpressionSource": "constant", "deviceProfileExpression": "default", "deviceProfileExpressionSource": "constant" }, "attributes": [], "timeseries": [ { "key": "some_key", "type": "path", "value": "${some_key}" } ], "rpc_methods": [ { "method": "multiply", "arguments": [ { "type": "integer", "value": 5 }, { "type": "integer", "value": 4 } ] } ], "attributes_updates": [] } ]}Every telemetry and attribute parameter has GET and SET RPC methods out of the box, so you don’t need to configure
them manually.
As an example, we will use Prosys OPC-UA Simulation Server, which is
available at opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer. The server has the following structure:
We are interested in node “Relay” that have ns=3;i=1012 identifier, we added this node as a telemetry parameter
with the key relay and as a path we used the node identifier ${ns=3;i=1012}, so the configuration for this
telemetry will look like this:
"timeseries": [ { "key": "relay", "type": "identifier", "value": "${ns=3;i=1012}" }]Let’s check the value of the relay node using the reserved get method. To get the current value of relay node,
run the query in RPC debug terminal:
get ns=3;i=1012;Response:
{"result": {"value": false}}So, the get method returns the current value of the relay node, and we can see that the relay is off.
To set the value of the relay node and turn it on, run the query:
set ns=3;i=1012; trueResponse:
{"result": {"value": true}}And as you can see, from the screenshot below, the relay telemetry value has changed to true:
Also, let’s check the value of the relay telemetry again:
get ns=3;i=1012;Response:
{"result": {"value": true}}Full configuration for OPC-UA connector for the examples above will look like this:
{ "server": { "url": "opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "enableSubscriptions": true, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" }, "pollPeriodInMillis": 5000 }, "mapping": [ { "deviceNodePattern": "Root\\.Objects\\.DemoDevice", "deviceNodeSource": "path", "deviceInfo": { "deviceNameExpression": "Demo Device", "deviceNameExpressionSource": "constant", "deviceProfileExpression": "default", "deviceProfileExpressionSource": "constant" }, "attributes": [], "attributes_updates": [], "timeseries": [ { "key": "relay", "type": "identifier", "value": "${ns=3;i=1012}" } ], "rpc_methods": [] } ]}Every telemetry and attribute parameter comes with built-in get and set RPC methods, so you don’t need to configure them manually.
Additionally, you can use the reserved RPC methods to access any node on the OPC-UA server - even if it doesn’t belong to a specific device. This is especially useful when management or control nodes are located outside the device’s node tree.
We will set the device node to Root\.Objects\.DemoDevice, but we will access the TextMessage node located at Root\.Objects\.DemoDeviceInfo\.TextMessage, which is outside the device node tree.
As an example, we will use Prosys OPC-UA Simulation Server, which is
available at opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer. The server has the following structure:
We’re interested in the “TextMessage” which has the “Path” - Root\.Objects\.DemoDeviceInfo\.TextMessage,
and does not belong to the device node tree. We added this node as a telemetry parameter
with the key textmessage, so it would be easy to verify later whether the value changed after calling the reserved set RPC method.
"timeseries": [ { "key": "textmessage", "type": "path", "value": "${Root\\.Objects\\.DemoDeviceInfo\\.TextMessage}" }]Let’s check the value of the textmessage node using the reserved get method. To get the current value of textmessage node,
run the query in RPC debug terminal:
get Root\\.Objects\\.DemoDeviceInfo\\.TextMessage;Response:
{"result":{"value":"HI"}}So, the get method returns the current value of the textmessage node, and we can see that the textmessage is HI.
To set the value of the textmessage node and change its value, run the query:
set Root\\.Objects\\.DemoDeviceInfo\\.TextMessage; New MessageResponse:
{"result":{"value":"New Message"}}And as you can see, from the screenshot below, the textmessage telemetry value has changed to New Message:
Also, let’s check the value of the textmessage telemetry again:
get Root\\.Objects\\.DemoDeviceInfo\\.TextMessage;Response:
{"result":{"value":"New Message"}}Full configuration for OPC-UA connector for the examples above will look like this:
{ "server": { "url": "opc.tcp://0.0.0.0:53530/OPCUA/SimulationServer", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "enableSubscriptions": true, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" }, "pollPeriodInMillis": 5000 }, "mapping": [ { "deviceNodePattern": "Root\\.Objects\\.DemoDevice", "deviceNodeSource": "path", "deviceInfo": { "deviceNameExpression": "Demo Device", "deviceNameExpressionSource": "constant", "deviceProfileExpression": "default", "deviceProfileExpressionSource": "constant" }, "attributes": [], "attributes_updates": [], "timeseries": [ { "key": "textmessage", "type": "path", "value": "${Root\\.Objects\\.DemoDeviceInfo\\.TextMessage}" } ], "rpc_methods": [] } ]}RPC To Connector allows you to send a command to the connector from the ThingsBoard IoT Gateway UI. It is important to note that the method you are calling must be defined on the OPC-UA server.
As an example, we will use ThingsBoard OPC-UA Demo Server, which can be run using Docker and the following command:
docker run -it -p 4840:4840 thingsboard/tb-gw-opcua-server:latestThe server has the following endpoint URL: opc.tcp://0.0.0.0:4840/freeopcua/server/.
Example: Relay Controlling
Section titled “Example: Relay Controlling”Let’s see a practical example of using RPC To Connector. On our OPC-UA server, we have “set_relay” method that
turns on or off the relay. The method accepts a boolean argument, where true turns on the relay and false turns
it off. To call this method, use the following steps:
Go to “Entities” → “Gateways” in the right sidebar and select your gateway.
Click on the “Connectors configuration” button on the right side menu.
Select the created OPC-UA connector, click on the “RPC” icon. Make sure you have configured and connected device (if you do not know how to do it, see Getting Started guide or Connection settings and Data mapping sections of this guide).
Let’s first turn on the relay. To do this, fill in the “Method” field with set_relay and in the “Arguments” field
enter true, then click on the “Send” button.
As you can see, the response contains true, which means that the method was executed successfully and the relay is
now on:
And finally, let’s turn off the relay. To do this, fill in the “Method” field with set_relay and in the
“Arguments” field enter false, then click on the “Send” button:
Result:
Full configuration for OPC-UA connector for the example above will look like this:
{ "server": { "url": "opc.tcp://0.0.0.0:4840/freeopcua/server/", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "enableSubscriptions": true, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" }, "pollPeriodInMillis": 5000 }, "mapping": [ { "deviceNodePattern": "Root\\.Objects\\.MyObject", "deviceNodeSource": "path", "deviceInfo": { "deviceNameExpression": "Demo Device", "deviceNameExpressionSource": "constant", "deviceProfileExpression": "default", "deviceProfileExpressionSource": "constant" }, "attributes": [], "attributes_updates": [], "timeseries": [ { "key": "Frequency", "type": "path", "value": "${Frequency}" } ], "rpc_methods": [] } ]}Advanced configuration
Section titled “Advanced configuration”The advanced configuration section provides a detailed overview of all available parameters for the OPC-UA connector.
Server
Section titled “Server”The server object specifies the target OPC-UA server and how the gateway interacts with it.
| Parameter | Default value | Description |
|---|---|---|
| server | The server object specifies the target OPC-UA server and how the gateway interacts with it. | |
| server.url | Hostname or ip address of OPC-UA server. | |
| server.timeoutInMillis (in ms) | 5000 | Timeout in seconds for connecting to OPC-UA server. |
| server.scanPeriodInMillis (in ms) | 3600000 | Period in milliseconds for scanning the OPC-UA server for changes. If your OPC-UA server structure doesn’t change often, you can set a big period for gateway resource saving. |
| server.pollPeriodInMillis (in ms) | 5000 | Period in milliseconds to poll the server. If enableSubscriptions is set to true, pollPeriodInMillis does not affect data reading. |
| server.enableSubscriptions | true | If true - the gateway will subscribe to interesting nodes and wait for data update and if false - the gateway will rescan OPC-UA server every scanPeriodInMillis. |
| server.subCheckPeriodInMillis (in ms) | 100 | Defines the publishing/check interval that the connector requests when creating OPC-UA subscriptions. |
| server.subKeepAlivePeriodInSeconds (in seconds) ** | 0 | The interval at which the connector checks whether OPC-UA subscriptions are still “alive” (i.e., the publish/data-change flow is not stalled). This check is disabled by default (set to 0). If a subscription shows no activity longer than this threshold, the connector treats it as expired and triggers resubscription to restore updates. |
| server.subDataMaxBatchSize | 1000 | Maximum number of data items in a single subscription update. This is useful for performance optimization. |
| server.subDataMinBatchCreationTimeMs (in ms) | 200 | Minimum time in milliseconds to wait before creating a new batch of data items in a subscription update. This helps to reduce the number of updates sent to ThingsBoard. |
| server.subscriptionProcessBatchSize | 2000 | Maximum number of data items to process in a single batch when handling subscription updates. This is useful for performance optimization. |
| server.sessionTimeoutInMillis (in ms) | 120000 | Session timeout in milliseconds. This is the maximum time the session can be inactive before it is closed by the server. |
| server.showMap | false | If true - the gateway will show a map of OPC-UA server nodes in the terminal. This is useful for debugging and understanding the structure of the OPC-UA server. |
| server.security | Basic128Rsa15 | Security policy (Basic128Rsa15, Basic256, Basic256Sha256). |
Example of the server configuration:
"server": { "url": "localhost:4840/freeopcua/server/", "timeoutInMillis": 5000, "scanPeriodInMillis": 3600000, "pollPeriodInMillis": 5000, "enableSubscriptions": true, "subCheckPeriodInMillis": 100, "subDataMaxBatchSize": 1000, "subDataMinBatchCreationTimeMs": 200, "subscriptionProcessBatchSize": 2000, "sessionTimeoutInMillis": 120000, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" }}Server identity
Section titled “Server identity”The identity object specifies the authentication method used to connect to the OPC-UA server. It can be one of the following: anonymous, basic, certificates.
Anonymous identity
Section titled “Anonymous identity”| Parameter | Default value | Description |
|---|---|---|
| server.identity.type | anonymous | Type of identity on OPC-UA server. |
Basic identity
Section titled “Basic identity”| Parameter | Default value | Description |
|---|---|---|
| server.identity.type | basic | Type of identity on OPC-UA server. |
| server.identity.username | Username for logging into the OPC-UA server. | |
| server.identity.password | Password for logging into the OPC-UA server. |
Example of the basic identity configuration:
"identity": { "type": "basic", "username": "user", "password": "5Tr0nG?@$sW0rD"},Certificates identity
Section titled “Certificates identity”| Parameter | Default value | Description |
|---|---|---|
| server.identity.type | cert.PEM | Type of identity on OPC-UA server. |
| server.identity.caCert | Path to the CA certificate. | |
| server.identity.cert | Path to the client certificate. | |
| server.identity.privateKey | Path to the client private key. | |
| server.identity.mode | SignAndEncrypt | Security mode, there are 2 options – Sign and SignAndEncrypt. |
| username | (Optional) Username for logging into the OPC-UA server. | |
| password | (Optional) Password for logging into the OPC-UA server. |
Example of the basic certificates configuration:
"identity": { "type": "cert.PEM", "caCert": "etc/thingsboard-gateway/ca.pem", "privateKey": "etc/thingsboard-gateway/private_key.pem", "cert": "etc/thingsboard-gateway/cert.pem", "mode": "SignAndEncrypt", "username": "user", "password": "5Tr0nG?@$sW0rD"},Mapping
Section titled “Mapping”The Mapping list is used to configure how the OPC-UA connector will map data from the OPC-UA server to ThingsBoard devices. It allows you to specify which nodes from the OPC-UA server will be used as device names, device profiles, device attributes, and telemetry data.
Device mapping
Section titled “Device mapping”| Parameter | Description |
|---|---|
| mapping[].deviceNodeSource | Source of the device node, can be: path, identifier or constant. |
| mapping[].deviceNodePattern | Absolute or relative path, or identifier, which is used for looking up the node for a current device. Paths to the device name, profile, attributes, and telemetry can be specified relative to this node. |
| mapping[].deviceInfo | Device info object using for configuring device name and profile. |
| mapping[].deviceInfo.deviceNameExpressionSource | Source of the device name (can be path, identifier or constant). |
| mapping[].deviceInfo.deviceNameExpression | Path to a variable with device name, which is used for looking up the device name in a variable. |
| mapping[].deviceInfo.deviceProfileSource | Source of the device profile (can be path, identifier or constant). |
| mapping[].deviceInfo.deviceProfileExpression | Path to a variable with device profile, is used for looking the device profile in some variable. |
| mapping[].reportStrategy | Report strategy object using for configuring report strategy for device. |
Example of the device mapping configuration:
"mapping": [ { "deviceNodeSource": "path", "deviceNodePattern": "Root\\.Objects\\.MyObject", "deviceInfo": { "deviceNameExpression": "OPCUA New Advanced Device", "deviceNameExpressionSource": "path", "deviceProfileExpression": "some other default 1", "deviceProfileExpressionSource": "constant" }, "attributes": [], "timeseries": [], "attributes_updates": [], "rpc_methods": [], },]Device attributes and time series
Section titled “Device attributes and time series”| Parameter | Description |
|---|---|
| mapping[].attributes[] | List of attributes that will be sent to the ThingsBoard platform instance. |
| mapping[].attributes[].key | Key name of the attribute in ThingsBoard. It can be specified as a static value. |
| mapping[].attributes[].type | Type of the expression in the value field (can be path, identifier or constant). |
| mapping[].attributes[].value | Value of the attribute that will be sent to the platform. It should be specified depending on the selected type (path, identifier or constant). |
| mapping[].attributes[].reportStrategy | (Optional) Report strategy for the attributes data. If not specified, the device report strategy will be used. |
| mapping[].timeseries[] | List of telemetry data that will be sent to the ThingsBoard platform instance. |
| mapping[].timeseries[].key | Key name of the telemetry data in ThingsBoard. It can be specified as a static value. |
| mapping[].timeseries[].type | Type of the expression in the value field (can be path, identifier or constant). |
| mapping[].timeseries[].value | Value of the telemetry data that will be sent to the platform. It should be specified depending on the selected type (path, identifier or constant). |
| mapping[].timeseries[].timestampLocation | (Optional) Location of the timestamp for the attribute. If not specified, the current time will be used. Can be: sourcetimestamp, servertimestamp |
| mapping[].timeseries[].reportStrategy | (Optional) Report strategy for the time series data. If not specified, the device report strategy will be used. |
Example of the attributes and telemetry configuration:
"attributes": [ { "key": "Power", "type": "path", "value": "${Power}" }, { "key": "Frequency", "type": "path", "value": "${Frequency}" }],"timeseries": [ { "key": "Humidity", "type": "path", "value": "${ns=2;i=16}" }, { "key": "Temperature", "type": "path", "value": "${Root\\.Objects\\.MyObject\\.Temperature}" }],Device attributes updates
Section titled “Device attributes updates”| Parameter | Default value | Description |
|---|---|---|
| mapping[].attributes_updates[] | List of attributes that will be updated on the device. | |
| mapping[].attributes_updates[].key | Key name of the shared attribute in ThingsBoard. It can be specified as a static value. | |
| mapping[].attributes_updates[].type | Type of the expression in the value field (can be path, identifier or constant). | |
| mapping[].attributes_updates[].value | Value of the attribute that will be sent to the device. It should be specified depending on the selected type (path, identifier or constant). | |
| mapping[].attributes_updates[].timeout (in ms) | 5000 | Timeout in milliseconds for the attribute update request. |
Example of the attributes updates configuration:
"attributes_updates": [ { "key": "nodeById", "type": "path", "value": "ns=2;i=23" "timeout": 5000 },]Device RPC methods
Section titled “Device RPC methods”| Parameter | Default value | Description |
|---|---|---|
| mapping[].rpc_methods[] | List of RPC methods that will be sent to the device. | |
| mapping[].rpc_methods[].method | Name of the method on the OPC-UA server. | |
| mapping[].rpc_methods[].arguments | (Optional) List of default arguments that will pass to the OPC-UA server method. | |
| mapping[].rpc_methods[].arguments[].type | Type of the argument. | |
| mapping[].rpc_methods[].arguments[].value | (Optional) Value of the argument. | |
| mapping[].rpc_methods[].timeout (in ms) | 5000 | Timeout in milliseconds for the RPC method execution. |
Example of the RPC methods configuration:
"rpc_methods": [ { "timeout": 3000, "method": "multiply", "arguments": [ { "type": "integer", "value": 2 }, { "type": "integer", "value": 4 } ] },]Additional information
Section titled “Additional information”Path types
Section titled “Path types”A Path type refers to the hierarchical address within the OPC-UA server’s namespace. It is used to navigate to specific nodes in the server.
The path for the attribute value can be absolute or relative.
Absolute path
Section titled “Absolute path”An absolute path specifies the full hierarchical address from the root of the OPC-UA server’s namespace to the target node.
Example:
Gateway expects the node to exist and the value of “Root.Objects.TempSensor.Temperature” to be 23.54.
Expression:
${Root\\.Objects\\.TempSensor\\.Temperature}
Converted data:
23.54
Relative path
Section titled “Relative path”A relative path specifies the address relative to a predefined starting point in the OPC-UA server’s namespace.
Example:
Gateway expects the node to exist and the value of “Root.Objects.TempSensor.Temperature” to be 23.56.
Device Node Expression:
Root\\.Objects\\.TempSensor
Expression:
${Temperature}
Converted data:
23.56
Identifier types
Section titled “Identifier types”An Identifier type is a unique ID assigned to a node within the OPC-UA server. It is used to directly reference specific nodes without navigating through the namespace hierarchy.
The Identifier type in the OPC-UA connector configuration can take various forms to uniquely reference nodes
in the OPC-UA server’s address space. Identifiers can be of different types, such as numeric (i), string (s),
byte string (b), and GUID (g). Below is an explanation of each identifier type with examples.
-
Numeric Identifier (
i)A numeric identifier uses an integer value to uniquely reference a node in the OPC-UA server.
Expression:
${ns=2;i=1235}Converted data:
21.34 -
String Identifier (
s)A string identifier uses a string value to uniquely reference a node in the OPC-UA server.
Expression:
${ns=3;s=TemperatureSensor}Converted data:
21.34 -
Byte String Identifier (
b)A byte string identifier uses a byte string to uniquely reference a node in the OPC-UA server. This is useful for binary data that can be converted to a byte string.
Expression:
${ns=3;b=Q2xpZW50RGF0YQ==}Converted data:
21.34 -
GUID Identifier (
g)A GUID identifier uses a globally unique identifier (GUID) to uniquely reference a node in the OPC-UA server.
Expression:
${ns=3;g=550e8400-e29b-41d4-a716-446655440000}Converted data:
21.34