OPC-UA String to InfluxDB Object: Data conversion

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:
image

"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:
image

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":[]}]

Add function node to transform msg to newmsg:

// msg.payload = timestamp; // new Date()
// msg.topic = ns=3;s="M_WaterSystem_Ctrl"."Ctrl"."53FT01";
// msg.OPCU = {"y":0,"y Filtered":0,"YF":false,"AHH":false,"ALL":false};

var mea = msg.topic.substring(7);
var l = msg.topic.lastIndexOf(".");
var loc = msg.topic.substring(l+1);
var fields = JSON.parse(msg.OPC);

var newmsg = {};

newmsg.topic = 'ns=3;s="M_WaterSystem_Ctrl"."Ctrl".53FT01';

var payload =
{
measurement: mea,
tags:{
location: loc
},
fields: {
Y: fields.y,
Y_Filtered: fields["y Filtered"],
YF: fields.YF,
AHH: fields.AHH ,
ALL: fields.ALL
},
timestamp: new Date()
};
newmsg.payload = ;
newmsg.payload[0] = payload;

return newmsg;

[{"id":"9a3c1db7.d762b","type":"tab","label":"Flow ","disabled":false,"info":""},{"id":"69ef9b23.eb4224","type":"debug","z":"9a3c1db7.d762b","name":"WANTED","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":720,"y":520,"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":460,"y":520,"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":210,"y":520,"wires":[["9aeebc5.ad6994"]]},{"id":"f812dfbc.ab6d8","type":"debug","z":"9a3c1db7.d762b","name":"OPC","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"OPC","targetType":"msg","statusVal":"","statusType":"auto","x":710,"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","0262c68aa0f98207"]]},{"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":320,"y":480,"wires":},{"id":"0262c68aa0f98207","type":"function","z":"9a3c1db7.d762b","name":"","func":"// msg.payload = timestamp; // new Date()\n// msg.topic = ns=3;s="M_WaterSystem_Ctrl"."Ctrl"."53FT01";\n// msg.OPCU = {"y":0,"y Filtered":0,"YF":false,"AHH":false,"ALL":false};\n\nvar mea = msg.topic.substring(7);\nvar l = msg.topic.lastIndexOf(".");\nvar loc = msg.topic.substring(l+1);\nvar fields = JSON.parse(msg.OPC);\n\n\nvar newmsg = {};\n\nnewmsg.topic = 'ns=3;s="M_WaterSystem_Ctrl"."Ctrl".53FT01';\n\nvar payload =\n {\n measurement: mea,\n tags:{\n location: loc\n },\n fields: {\n Y: fields.y,\n Y_Filtered: fields["y Filtered"],\n YF: fields.YF,\n AHH: fields.AHH ,\n ALL: fields.ALL \n },\n timestamp: new Date()\n };\nnewmsg.payload = ;\nnewmsg.payload[0] = payload;\n\nreturn newmsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":510,"y":360,"wires":[["d546b2c09c7f0316"]]},{"id":"d546b2c09c7f0316","type":"debug","z":"9a3c1db7.d762b","name":"FIX","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":360,"wires":}]

This JSON is incorrect by copying and pasting it