JSON Schema for custom plugin connector - TeamViewer Support
<main>
<article class="userContent">
<p><br></p><p>An example template:</p><pre class="code codeBlock" spellcheck="false" tabindex="0">{
"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": ""
}
]
},
...
]
}
</pre><p><br></p><h3></h3><h2 data-id="json-schema-for-sensor-objects">JSON Schema for sensor objects</h2><div class="embedExternal embedImage display-large float-none">
<div class="embedExternal-content">
<a class="embedImage-link" href="https://us.v-cdn.net/6032394/uploads/OFX1KG2CEWIY/teamviewer-iot-documentation-teamviewer-table-001.png" rel="nofollow noreferrer noopener ugc" target="_blank">
<img class="embedImage-img" src="https://us.v-cdn.net/6032394/uploads/OFX1KG2CEWIY/teamviewer-iot-documentation-teamviewer-table-001.png" alt="TeamViewer IoT Documentation - TeamViewer - Table 001.png" height="1039" width="1126" loading="lazy" data-display-size="large" data-float="none"></img></a>
</div>
</div>
<p><br></p><h3 data-id="-1"></h3><h2 data-id="json-schema-for-monitoringparams-objects">JSON Schema for monitoringParams objects</h2><div class="embedExternal embedImage display-large float-none">
<div class="embedExternal-content">
<a class="embedImage-link" href="https://us.v-cdn.net/6032394/uploads/FR12YS19KC4P/teamviewer-iot-documentation-teamviewer-table-002.png" rel="nofollow noreferrer noopener ugc" target="_blank">
<img class="embedImage-img" src="https://us.v-cdn.net/6032394/uploads/FR12YS19KC4P/teamviewer-iot-documentation-teamviewer-table-002.png" alt="TeamViewer IoT Documentation - TeamViewer - Table 002.png" height="523" width="1138" loading="lazy" data-display-size="large" data-float="none"></img></a>
</div>
</div>
<p><br></p><h3 data-id="-2"></h3><h2 data-id="json-schema-for-metric-objects">JSON Schema for metric objects</h2><div class="embedExternal embedImage display-large float-none">
<div class="embedExternal-content">
<a class="embedImage-link" href="https://us.v-cdn.net/6032394/uploads/OEIDUIJ1851D/teamviewer-iot-documentation-teamviewer-table-003.png" rel="nofollow noreferrer noopener ugc" target="_blank">
<img class="embedImage-img" src="https://us.v-cdn.net/6032394/uploads/OEIDUIJ1851D/teamviewer-iot-documentation-teamviewer-table-003.png" alt="TeamViewer IoT Documentation - TeamViewer - Table 003.png" height="564" width="961" loading="lazy" data-display-size="large" data-float="none"></img></a>
</div>
</div>
<p><br></p><h3 data-id="-3"></h3><h2 data-id="monitoring-configuration-file">Monitoring configuration file</h2><p>After the sensor/metric is registered by the agent, the agent auto-generates the parameters <code class="code codeInline" spellcheck="false" tabindex="0">sensorId</code> and <code class="code codeInline" spellcheck="false" tabindex="0">metricId</code> and adds them as properties to the configuration file.</p><p>📌<strong>Notes: </strong></p><ul><li>To avoid data loss. Before editing the configuration file, create a backup.</li><li>Avoid historical data loss. Do not change any <code class="code codeInline" spellcheck="false" tabindex="0">sensorId</code> or <code class="code codeInline" spellcheck="false" tabindex="0">metricId</code> after they are added to the configuration file.</li></ul><p><br></p><h3 data-id="-4"></h3><h2 data-id="monitoring-frequency">Monitoring frequency</h2><p>Monitoring frequency can be controlled either by the agent’s <strong>Monitoring Configuration File </strong>(parameter<code class="code codeInline" spellcheck="false" tabindex="0">frequency</code>) or by your custom script. In the JSON Sensor (see example below), the frequency is specified by the configuration property, causing the agent to run your script every 10 seconds.</p><pre class="code codeBlock" spellcheck="false" tabindex="0">{
"sensors": [{
"name": "temperature_humidity_sensor1",
"monitoringService": "/usr/local/teamvieweriot/sensors/temperature_humidity/monitor.sh",
"monitoringParams": "sensor1 sdkCredential",
"frequency": 10,
"metrics": [{
"name": "Temperature",
"key": "temperature",
"valueType": "double",
"valueAnnotation": "C"
}, {
"name": "Humidity",
"key": "humidity",
"valueType": "double",
"valueAnnotation": ""
}]
},
...
]
}
</pre><p>There may be scenarios where the frequency of the data collection should be set by your script rather than specified in the agent’s <strong>Monitoring Configuration File</strong>. In these scenarios, the parameter <code class="code codeInline" spellcheck="false" tabindex="0">frequency</code> in the configuration file should be left blank.</p><p><br></p><h3 data-id="-5"></h3><h2 data-id="use-case%3A-you-want-to-monitor-discrete-events-which-dont-have-a-defined-frequency-(event-based-metrics)">Use case: You want to monitor discrete events which don’t have a defined frequency (event-based metrics)</h2><ul><li>e.g. monitoring when a door is opened or closed</li><li>within your custom script, you subscribe to a message queue to get door movement events and print them to <code class="code codeInline" spellcheck="false" tabindex="0">stdout</code>.</li></ul><p>Generic example:</p><pre class="code codeBlock" spellcheck="false" tabindex="0">var queue = new Queue();
queue.openConnection();
queue.createSubscription(callback);
function callback(value) {
print {"key":value};
}
</pre><p><br></p><h3 data-id="-6"></h3><h2 data-id="use-case%3A-you-want-to-set-up-high-frequency-monitoring-(e.g.-1-second)">Use case: You want to set up high-frequency monitoring (e.g. 1 second)</h2><p>Although this can be done by configuring the parameter <code class="code codeInline" spellcheck="false" tabindex="0">frequency</code> in the agent’s <strong>Monitoring Configuration File</strong>, an optimal solution may be to use a loop in your script to print new metric values every second.</p><p>Generic example:</p><pre class="code codeBlock" spellcheck="false" tabindex="0">var networkObject = new NetworkObject();
networkObject.openConnection();
try {
while (true) {
var value = networkObject.getValue();
print {"key":value};
sleep(1000);
}
}
finally
{
connection.close()
}
</pre><p><br></p><h3 data-id="-7"></h3>
</article>
</main>