Hi,
Im working on a project where I am trying to log some data from a Siemens PLC to influx DB and then Grafana. In this setup - Node-Red gets the data from the PLC through OPC-UA. Since we are talking about 500+ signals, the inject node is configured to read a struct(UDT) from the PLC.
When I read from a flow sensor, i get the following result:
"53FT01" is my target in this example. This sensor is located in my control datablock "Ctr" within my "WaterSystem". The "53FT01" containes 5 signals:
y - with the value of 0 [real]
y filtered - with the value of 0 [real]
YF - false [bool]
AHH - false [bool]
ALL - false [bool]
The problem I have is that i cant figure out how i can convert this string to a format that InfluxDB supports. Ideally, this data should be converted to the following:
Does anyone know how to do that?
[{"id":"9a3c1db7.d762b","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"69ef9b23.eb4224","type":"debug","z":"9a3c1db7.d762b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":380,"wires":[]},{"id":"9aeebc5.ad6994","type":"function","z":"9a3c1db7.d762b","name":"multiple measurement points","func":"\n\nmsg.payload = [\n {\n measurement: \"M_WaterSystem_Ctrl\",\n tags:{\n location:\"53FT01 \"\n },\n fields: {\n Y: 0 ,\n Y_Filtered:0,\n YF: false,\n AHH:false ,\n ALL:false \n },\n timestamp: new Date()\n },\n\n];\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":380,"wires":[["69ef9b23.eb4224"]]},{"id":"483fb851.b5b168","type":"inject","z":"9a3c1db7.d762b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"ns=3;s=\"M_WaterSystem_Ctrl\".\"Ctrl\".53FT01","payload":"","payloadType":"date","x":130,"y":380,"wires":[["9aeebc5.ad6994"]]},{"id":"f812dfbc.ab6d8","type":"debug","z":"9a3c1db7.d762b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"OPC","targetType":"msg","statusVal":"","statusType":"auto","x":320,"y":280,"wires":[]},{"id":"e1553bc2.fc21d8","type":"inject","z":"9a3c1db7.d762b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"OPC","v":"{\"y\":0,\"y Filtered\":0,\"YF\":false,\"AHH\":false,\"ALL\":false}","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"ns=3;s=\"M_WaterSystem_Ctrl\".\"Ctrl\".\"53FT01\"","payload":"","payloadType":"date","x":130,"y":280,"wires":[["f812dfbc.ab6d8"]]},{"id":"d15033e4.36f9f","type":"comment","z":"9a3c1db7.d762b","name":"This is the output string i get from my OPCUA block","info":"This is the output string i get from my OPCUA block","x":230,"y":240,"wires":[]},{"id":"86d5cb47.3d3fe8","type":"comment","z":"9a3c1db7.d762b","name":"This is what i ideally should convert the OPC output to","info":"","x":240,"y":340,"wires":[]}]