This article applies to TeamViewer Embedded users who monitor their OPC-UA IoT networks.
The solution presented in this article requires TeamViewer Embedded Agent v 1.1.102 (or higher). To identify the version of your agent, run: sudo teamviewer-iot-agent info (an error, or no result, indicates an older version of the agent is installed).
As described in the Custom Plugin Connector article, it's quite easy to monitor your sensor network via TeamViewer Embedded. This article extends the integration approach to monitor OPC-UA server node values. For more about OPC-UA reference the OPC Foundation.
The connector requires the following to be installed on the device:
To identify the installed version, run the following command: (an error, or no result, indicates an older version of the agent is installed)sudo teamviewer-iot-agent info
python -m pip install --upgrade pip setuptools wheel
pip install freeopcua
wget https://download.teamviewer-iot.com/connectors/teamviewer-iot-opcua/1.0.0/teamviewer_iot_opcua-1.0.0.tar.gz
sudo mkdir -p /usr/local/teamviewer-iot-agent/monitoring/ tar -xzvf teamviewer_iot_opcua-1.0.0.tar.gz -C /usr/local/teamviewer-iot-agent/monitoring/opc-ua
The TeamViewer Embedded Agent includes its own system monitoring configuration file. This configuration file will be extended to include the opc-ua monitoring script. As you are going to maually edit a system configuration file, ensure to create a backup of the file in the case the file gets corrupted by user error.
Use the following template to add your OPC-UA sensor nodes to the monitoring configuration file. Ensure to replace the following placeholders with the specifics of your OPC-UA node:
More details about the JSON schema can be found in the Custom Plugin Connector article.
{ "sensors": [ { "name": "opcua_node_aa", "monitoringService": "python /usr/local/teamviewer-iot-agent/monitoring/opc-ua/opc_ua_connect.py", "monitoringParams": "--url opc.tcp://myopcuahost:26543 --nodeId \"opcua_node_id\" --frequency 2", "metrics": [ { "name": "opcua_node_id", "key": "opcua_node_id", "valueType": "double", "valueAnnotation": "" } ] }, ... ] }
The monitoringParams field contains additional arguments required by the script. Here is the table of available arguments.
Paramater
Type
Required
Description
url
String
True
OPC UA server url
nodeId
String
True
Id of the node specified by the given OPC UA server.
frequency
Integer
False
The frequency (in seconds) to poll for new node values.
If not set, frequency defaults to 1-time execution.
As described in the Monitoring Frequency section of the Custom Plugin Connector article, monitoring frequency can be either managed by the agent by specifying it as a standalone parameter, or managed by the opc-ua monitoring script itself by passing the parameter directly to the script.
In the template above, frequency is set within the monitoringParams as part of the script parameter. This approach is recommended for monitoring frequencies of less than 1 minute. The TeamViewer Embedded Agent will execute the opc-ua monitoring script once - at startup, allowing the script to run indefinitely; while the script itself will execute in a loop polling for new data every 2 seconds (as specified by the frequency parameter).
In cases where the monitoring frequency is slower than 1 per minute, the frequency can be specified as part of the template, which will result in the TeamViewer Embedded Agent executing the referenced script at the frequency specified.
In the example below, the frequency parameter is set to 120, which will trigger the agent to execute the script referenced by monitoringScript every 120 seconds.
{ "sensors": [ { "name": "opcua_node_aa", "monitoringScript": "python /usr/local/teamviewer-iot-agent/monitoring/opc-ua/opc_ua_connect.py", "monitoringParams": "--url opc.tcp://myopcuahost:26543 --nodeId \"opcua_node_id"", "frequency": 120, "metrics": [ { "name": "opcua_node_id", "key": "opcua_node_id", "valueType": "double", "valueAnnotation": "" } ] }, ... ] }