This webservice allows sohisticated conversions. I prepared some templates for it to do common conversions. Follow the steps below and then choose the right template.json and format the input for the different use cades as outlined below.
Import the according template JSON in Load Form
Paste the list of sensors into the input field
There is no feedback that the form was loaded successfully after uploading the template but it works. |
This generates a config without severities or sensor classes.
Insert the symbol list with the format as pre loaded in Input
ErsterSensor zweiterSensor DritterSensor |
This generates the action rule block from a list of sensor names and comments. The comments will be transformed and used as rule name.
Insert the symbol list with the format as pre loaded in Input
ErsterSensor;This sensor does smth bla zweiterSensor;Whatever i type her ebecomes the new sensor name DritterSensor;evene special chars like (/&(/& will be replaced with _ |
The following snippet creates a part of a sensor_config.xml
from an CSV file and saved it into a file named generated_sensor_config.xml. It is not creating a full configuration but the sensor related parts necessary.
Change the variables sensor_name,register (MODBUS register) and device_name to match the column number of the CSV. For example if you set sensor_name=$5, it will use column number five to extract the sensor name |
#!/bin/sh # # This is just a bare snippet, you have to change below parameters to work for other files. # # It creates the <sensor></sensor> part of a sensor config XML from a CSV list # printf "\n\n\nCopy below this line.\n---------------------------------------------------\n" && \ awk -F\; '{ device_name="gw_Wago_Modbus_TCP"; sensor_name=$1; register=$7; \ print \ "<sensor sensor_id=\"" sensor_name "\">\ \t<sensor_class>unknown</sensor_class>\ \t<sensor_gateway sensor_gateway_id=\"" device_name "\">\ \t\t<demux>\ \t\t\t<keys>\ \t\t\t\t<key>"register"</key>\ \t\t\t</keys>\n\t\t</demux>\ \t</sensor_gateway>\ </sensor>"};' wagomodbus2.csv > sensor_config_Sebastian.xml |
The script uses three variables that have to be set to match your CSV.
device_name
The vendor or model of the actual device that provides the sensors, e.g. a Advantech_ADAM or a B_and_R_BC0087. This is a custom string that you can define individually.
Pro Tip: A best practice is toi prefix the device name with |
sensor_name=<column>
The column number that holds the string to be used as the sensor name for each register, typically the description or human friendly name of the register.
register=<column>
The column number that holds the numeric register. This will be used within the demux section of the sensor config.
<demux> <keys> <key> REGISTER </key> </keys> </demux> |
Root.750_494.rMinimumRmsCurrentL1;MD42;1000;0;System.Single;255;412372;2;0 Root.750_494.rAverageRmsCurrentL1;MD43;1000;0;System.Single;255;412374;2;0 Root.750_494.rPeakCurrentL1;MD44;1000;0;System.Single;255;412376;2;0 |
In this example, we'll find the sensor name in column one, the Modbus register in column seven. The registers come from a Wago Modbus device, so we set this as our device name.
#!/bin/sh # # This is just a bare snippet, you have to change below parameters to work for other files. # # It creates the <sensor></sensor> part of a sensor config XML from a CSV list # printf "\n\n\nCopy below this line.\n---------------------------------------------------\n" && \ awk -F\; '{ device_name="gw_Wago_Modbus_TCP"; sensor_name=$1; register=$7; \ print \ "<sensor sensor_id=\"" sensor_name "\">\ \t<sensor_class>unknown</sensor_class>\ \t<sensor_gateway sensor_gateway_id=\"" device_name "\">\ \t\t<demux>\ \t\t\t<keys>\ \t\t\t\t<key>"register"</key>\ \t\t\t</keys>\n\t\t</demux>\ \t</sensor_gateway>\ </sensor>"};' wagomodbus2.csv > sensor_config_Sebastian.xml |
<sensor sensor_id="Root.750_494.rMinimumRmsCurrentL1"> <sensor_class>unknown</sensor_class> <sensor_gateway sensor_gateway_id="gw_Wago_Modbus_TCP"> <demux> <keys> <key>412372</key> </keys> </demux> </sensor_gateway> </sensor> <sensor sensor_id="Root.750_494.rAverageRmsCurrentL1"> <sensor_class>unknown</sensor_class> <sensor_gateway sensor_gateway_id="gw_Wago_Modbus_TCP"> <demux> <keys> <key>412374</key> </keys> </demux> </sensor_gateway> </sensor> <sensor sensor_id="Root.750_494.rPeakCurrentL1"> <sensor_class>unknown</sensor_class> <sensor_gateway sensor_gateway_id="gw_Wago_Modbus_TCP"> <demux> <keys> <key>412376</key> </keys> </demux> </sensor_gateway> </sensor> |
The script only creates the sensor components for the final config. It will need to be embedded into a full /wiki/spaces/SOD/pages/24379410 that has the device section as well as a sensor gateway in it.