I'm using an injection node with timestamp, 6 opcua item nodes and OpcUa Client node to read the values from that ID ns=2;s=@blablabla. So I used a join node to combine each msg.payload and then a function node and template node that I shared the code before.
I can see the data values in my database with timestamp but the 6 values are storing together in each column, I mean each column have the 6 values instead of 1 per column.
[
{
"id": "788edd9e.90d464",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": ""
},
{
"id": "6b44502a.129e7",
"type": "mysql",
"z": "788edd9e.90d464",
"mydb": "",
"name": "Mysql",
"x": 690,
"y": 320,
"wires": [
[
"2ac5c830e053c98b"
]
]
},
{
"id": "b95eecf0ea19f418",
"type": "OpcUa-Client",
"z": "788edd9e.90d464",
"endpoint": "",
"action": "read",
"deadbandtype": "a",
"deadbandvalue": 1,
"time": 10,
"timeUnit": "s",
"certificate": "n",
"localfile": "",
"localkeyfile": "",
"folderName4PKI": "",
"useTransport": false,
"maxChunkCount": "",
"maxMessageSize": "",
"receiveBufferSize": "",
"sendBufferSize": "",
"name": "",
"x": 400,
"y": 120,
"wires": [
[
"3e5dba4292a1de0d"
]
]
},
{
"id": "968e722e7e67d33c",
"type": "template",
"z": "788edd9e.90d464",
"name": "",
"field": "topic",
"fieldType": "msg",
"format": "sql",
"syntax": "mustache",
"template": "INSERT INTO `digitalizacao`.`Milacron`(`temperatureZone0`,`temperatureZone1`,`temperatureZone2`,`temperatureZone3`,`temperatureZone4`,`temperatureZone5`) VALUES (\"{{Msg}}\",\"{{Msg}}\",\"{{Msg}}\",\"{{Msg}}\",\"{{Msg}}\",\"{{Msg}}\");\n",
"output": "str",
"x": 540,
"y": 320,
"wires": [
[
"822dd7607299a65c"
]
]
},
{
"id": "429467aece67eaa1",
"type": "function",
"z": "788edd9e.90d464",
"name": "function 1",
"func": "//ObtĂ©m o valor de msg.payload proveniente dos sensores\nvar sensorvalue = msg.payload;\n\n//Cria um objeto para armazenar os valores de todos os sensores\nvar sensorsvalues = {};\n\n//Verifica qual sensor está enviando a mensagem e define a saĂda correspondente\nif(msg.topic === \"ns=2;s=@ActTmpBrlFeed[1]\"){\n sensorsvalues.temperatureZone0 = sensorvalue;\n}\nelse if(msg.topic === \"ns=2;s=@ActTmpBrlZone[1,1]\"){\n sensorsvalues.temperatureZone1 = sensorvalue;\n}\nelse if(msg.topic === \"ns=2;s=@ActTmpBrlZone[1,2]\"){\n sensorsvalues.temperatureZone2 = sensorvalue;\n}\nelse if(msg.topic === \"ns=2;s=@ActTmpBrlZone[1,3]\"){\n sensorsvalues.temperatureZone3 = sensorvalue;\n}\nelse if(msg.topic === \"ns=2;s=@ActTmpBrlZone[1,4]\"){\n sensorsvalues.temperatureZone4 = sensorvalue;\n}\nelse if(msg.topic === \"ns=2;s=@ActTmpBrlNozzle[1]\"){\n sensorsvalues.temperatureZone5 = sensorvalue;\n}\n\n//Adiciona os valores dos sensores ao objeto msg\nmsg.sensorsvalues = sensorsvalues;\n\n//Retorna a mensagem modificada\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 200,
"wires": [
[
"e7cbaa78094d3a68",
"b2e29cbf80e7a1b5"
]
]
},
{
"id": "2ac5c830e053c98b",
"type": "debug",
"z": "788edd9e.90d464",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 680,
"y": 380,
"wires": []
},
{
"id": "822dd7607299a65c",
"type": "debug",
"z": "788edd9e.90d464",
"name": "debug 2",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 680,
"y": 220,
"wires": []
},
{
"id": "e7cbaa78094d3a68",
"type": "debug",
"z": "788edd9e.90d464",
"name": "debug 3",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 680,
"y": 180,
"wires": []
},
{
"id": "dbf668c30bd7dfbf",
"type": "OpcUa-Item",
"z": "788edd9e.90d464",
"item": "ns=2;s=@ActTmpBrlFeed[1]",
"datatype": "Double",
"value": "",
"name": "temperatureZone0",
"x": 270,
"y": 300,
"wires": [
[
"b95eecf0ea19f418"
]
]
},
{
"id": "87f6136bcf09973a",
"type": "inject",
"z": "788edd9e.90d464",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 80,
"y": 300,
"wires": [
[
"dbf668c30bd7dfbf",
"ace44828f9018116",
"cdea5bec5218fd40",
"146c50872e7b3ca8",
"2ad69ea8e45aab5f",
"894f5867a3128a9c"
]
]
},
{
"id": "ace44828f9018116",
"type": "OpcUa-Item",
"z": "788edd9e.90d464",
"item": "ns=2;s=@ActTmpBrlZone[1,1]",
"datatype": "Double",
"value": "",
"name": "temperatureZone1",
"x": 270,
"y": 340,
"wires": [
[
"b95eecf0ea19f418"
]
]
},
{
"id": "cdea5bec5218fd40",
"type": "OpcUa-Item",
"z": "788edd9e.90d464",
"item": "ns=2;s=@ActTmpBrlZone[1,2]",
"datatype": "Double",
"value": "",
"name": "temperatureZone2",
"x": 270,
"y": 380,
"wires": [
[
"b95eecf0ea19f418"
]
]
},
{
"id": "146c50872e7b3ca8",
"type": "OpcUa-Item",
"z": "788edd9e.90d464",
"item": "ns=2;s=@ActTmpBrlZone[1,3]",
"datatype": "Double",
"value": "",
"name": "temperatureZone3",
"x": 270,
"y": 420,
"wires": [
[
"b95eecf0ea19f418"
]
]
},
{
"id": "2ad69ea8e45aab5f",
"type": "OpcUa-Item",
"z": "788edd9e.90d464",
"item": "ns=2;s=@ActTmpBrlZone[1,4]",
"datatype": "Double",
"value": "",
"name": "temperatureZone4",
"x": 270,
"y": 460,
"wires": [
[
"b95eecf0ea19f418"
]
]
},
{
"id": "894f5867a3128a9c",
"type": "OpcUa-Item",
"z": "788edd9e.90d464",
"item": "ns=2;s=@ActTmpBrlNozzle[1]",
"datatype": "Double",
"value": "",
"name": "temperatureZone5",
"x": 270,
"y": 500,
"wires": [
[
"b95eecf0ea19f418"
]
]
},
{
"id": "b2e29cbf80e7a1b5",
"type": "change",
"z": "788edd9e.90d464",
"name": "",
"rules": [
{
"t": "set",
"p": "Msg",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "delete",
"p": "payload",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 260,
"wires": [
[
"968e722e7e67d33c"
]
]
},
{
"id": "5a26fcff.2a60d4",
"type": "inject",
"z": "788edd9e.90d464",
"name": "temperatureZone0",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": "1",
"topic": "ns=2;s=@ActTmpBrlFeed[1]",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 20,
"wires": [
[]
]
},
{
"id": "dbf96360ca7e3141",
"type": "inject",
"z": "788edd9e.90d464",
"name": "temperatureZone1",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": "1",
"topic": "ns=2;s=@ActTmpBrlZone[1,1]",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 60,
"wires": [
[]
]
},
{
"id": "4b88a0c117223198",
"type": "inject",
"z": "788edd9e.90d464",
"name": "temperatureZone2",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": "1",
"topic": "ns=2;s=@ActTmpBrlZone[1,2]",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 100,
"wires": [
[]
]
},
{
"id": "02c82d8601ae0c9d",
"type": "inject",
"z": "788edd9e.90d464",
"name": "temperatureZone3",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": "1",
"topic": "ns=2;s=@ActTmpBrlZone[1,3]",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 140,
"wires": [
[]
]
},
{
"id": "edb8ff25ddf6bd76",
"type": "inject",
"z": "788edd9e.90d464",
"name": "temperatureZone4",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": "1",
"topic": "ns=2;s=@ActTmpBrlZone[1,4]",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 180,
"wires": [
[]
]
},
{
"id": "188d14ba012c441f",
"type": "inject",
"z": "788edd9e.90d464",
"name": "temperatureZone5",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": "1",
"topic": "ns=2;s=@ActTmpBrlNozzle[1]",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 220,
"wires": [
[]
]
},
{
"id": "e36c5490823880c7",
"type": "function",
"z": "788edd9e.90d464",
"name": "function 2",
"func": "//ObtĂ©m o valor de msg.payload proveniente dos sensores\n/*var temperatureZone0 = msg.payload.temperatureZone0;\nvar temperatureZone1 = msg.payload.temperatureZone1;\nvar temperatureZone2 = msg.payload.temperatureZone2;\nvar temperatureZone3 = msg.payload.temperatureZone3;\nvar temperatureZone4 = msg.payload.temperatureZone4;\nvar temperatureZone5 = msg.payload.temperatureZone5;\n\nvar sql = \"INSERT INTO digitalizacao.Milacron (temperatureZone0,temperatureZone1,temperatureZone2,temperatureZone3,temperatureZone4,temperatureZone5) VALUES (\"+temperatureZone0+\",\"+temperatureZone1+\",\"+temperatureZone2+\",\"+temperatureZone3+\",\"+temperatureZone4+\",\"+temperatureZone5+\")\";\nmsg.payload = sql;\n\nreturn msg;*/\n\n/*let {temperatureZone0,temperatureZone1,temperatureZone2,temperatureZone3,temperatureZone4,temperatureZone5} = msg.payload;\n\nlet sql = `INSERT INTO digitalizacao.Milacron(temperatureZone0,temperatureZone1,temperatureZone2,temperatureZone3,temperatureZone4,temperatureZone5) VALUES (${temperatureZone0},${temperatureZone1},${temperatureZone2},${temperatureZone3},${temperatureZone4},${temperatureZone5},)`;\n\nmsg.payload = sql;\nreturn msg;*/\n\n//ObtĂ©m o valor de msg.payload proveniente dos sensores\nvar sensorvalue = msg.payload;\n\n\n\n//Verifica qual sensor está enviando a mensagem e define a saĂda correspondente\nif (msg.topic === \"ns=2;s=@ActTmpBrlFeed[1]\") {\n msg.payload.temperatureZone0 = sensorvalue;\n}\nelse if (msg.topic === \"ns=2;s=@ActTmpBrlZone[1,1]\") {\n msg.payload.temperatureZone1 = sensorvalue;\n}\nelse if (msg.topic === \"ns=2;s=@ActTmpBrlZone[1,2]\") {\n msg.payload.temperatureZone2 = sensorvalue;\n}\nelse if (msg.topic === \"ns=2;s=@ActTmpBrlZone[1,3]\") {\n msg.payload.temperatureZone3 = sensorvalue;\n}\nelse if (msg.topic === \"ns=2;s=@ActTmpBrlZone[1,4]\") {\n msg.payload.temperatureZone4 = sensorvalue;\n}\nelse if (msg.topic === \"ns=2;s=@ActTmpBrlNozzle[1]\") {\n msg.payload.temperatureZone5 = sensorvalue;\n}\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 500,
"y": 500,
"wires": [
[
"b34f4dbe0d916aeb"
]
]
},
{
"id": "b34f4dbe0d916aeb",
"type": "template",
"z": "788edd9e.90d464",
"name": "",
"field": "topic",
"fieldType": "msg",
"format": "sql",
"syntax": "mustache",
"template": "INSERT INTO `digitalizacao`.`Milacron`(`temperatureZone0`,`temperatureZone1`,`temperatureZone2`,`temperatureZone3`,`temperatureZone4`,`temperatureZone5`) VALUES ('{{payload.temperatureZone0}}','{{payload.temperatureZone1}}','{{payload.temperatureZone2}}','{{payload.temperatureZone3}}','{{payload.temperatureZone4}}','{{payload.temperatureZone5}}');\n",
"output": "str",
"x": 640,
"y": 500,
"wires": [
[]
]
},
{
"id": "6ddb1ac547f559dc",
"type": "function",
"z": "788edd9e.90d464",
"name": "function 3",
"func": "//ObtĂ©m o valor de msg.payload proveniente dos sensores\nvar sensorvalue = msg.payload;\n\n//Verifica qual sensor está enviando a mensagem e define a saĂda correspondente\nif(msg.topic === \"ns=2;s=@ActTmpBrlFeed[1]\"){\n msg.temperatureZone0 = parseFloat(sensorvalue);\n}\n\n//Retorna a mensagem modificada\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 160,
"y": 560,
"wires": [
[
"4fe27f79a428f3f1"
]
]
},
{
"id": "4b4ff719e1f9862f",
"type": "function",
"z": "788edd9e.90d464",
"name": "function 4",
"func": "//Obtém o valor de msg.payload proveniente dos sensores\nvar sensorvalue = msg.payload;\n\nif(msg.topic === \"ns=2;s=@ActTmpBrlZone[1,1]\"){\n msg.temperatureZone1 = parseFloat(sensorvalue);\n}\n\n//Retorna a mensagem modificada\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 160,
"y": 600,
"wires": [
[
"cfafcd2ca38e9e8e"
]
]
},
{
"id": "1efc1ef2c9176ba5",
"type": "template",
"z": "788edd9e.90d464",
"name": "",
"field": "topic",
"fieldType": "msg",
"format": "sql",
"syntax": "mustache",
"template": "INSERT INTO `digitalizacao`.`Milacron`(`temperatureZone0`) VALUES ({{Msg0}});\n",
"output": "str",
"x": 500,
"y": 560,
"wires": [
[
"6dc7d1928bbdee2e"
]
]
},
{
"id": "ca15650a118aa040",
"type": "template",
"z": "788edd9e.90d464",
"name": "",
"field": "topic",
"fieldType": "msg",
"format": "sql",
"syntax": "mustache",
"template": "INSERT INTO `digitalizacao`.`Milacron`(`temperatureZone1`) VALUES ({{Msg1}});\n",
"output": "str",
"x": 500,
"y": 600,
"wires": [
[
"6dc7d1928bbdee2e"
]
]
},
{
"id": "24f176abbce316d0",
"type": "function",
"z": "788edd9e.90d464",
"name": "function 5",
"func": "//Obtém o valor de msg.payload proveniente dos sensores\nvar sensorvalue = msg.payload;\n\nif(msg.topic === \"ns=2;s=@ActTmpBrlZone[1,2]\"){\n msg.temperatureZone2 = parseFloat(sensorvalue);\n}\n\n//Retorna a mensagem modificada\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 160,
"y": 640,
"wires": [
[
"3365f1a13e7c2a96"
]
]
},
{
"id": "e8b3f747c6d0872a",
"type": "function",
"z": "788edd9e.90d464",
"name": "function 6",
"func": "//Obtém o valor de msg.payload proveniente dos sensores\nvar sensorvalue = msg.payload;\n\nif(msg.topic === \"ns=2;s=@ActTmpBrlZone[1,3]\"){\n msg.temperatureZone3 = parseFloat(sensorvalue);\n}\n\n//Retorna a mensagem modificada\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 160,
"y": 680,
"wires": [
[
"37dd688af68d8b20"
]
]
},
{
"id": "d6c8be535a70ba3a",
"type": "function",
"z": "788edd9e.90d464",
"name": "function 7",
"func": "//Obtém o valor de msg.payload proveniente dos sensores\nvar sensorvalue = msg.payload;\n\nif(msg.topic === \"ns=2;s=@ActTmpBrlZone[1,4]\"){\n msg.temperatureZone4 = parseFloat(sensorvalue);\n}\n\n//Retorna a mensagem modificada\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 160,
"y": 720,
"wires": [
[
"199718568d191f8b"
]
]
},
{
"id": "bd4123f4bfc2132e",
"type": "function",
"z": "788edd9e.90d464",
"name": "function 8",
"func": "//Obtém o valor de msg.payload proveniente dos sensores\nvar sensorvalue = msg.payload;\n\nif(msg.topic === \"ns=2;s=@ActTmpBrlZone[1,1]\"){\n msg.temperatureZone1 = parseFloat(sensorvalue);\n}\n\n//Retorna a mensagem modificada\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 160,
"y": 760,
"wires": [
[
"17f73edf67b2b937"
]
]
},
{
"id": "540053aab91cb16d",
"type": "template",
"z": "788edd9e.90d464",
"name": "",
"field": "topic",
"fieldType": "msg",
"format": "sql",
"syntax": "mustache",
"template": "INSERT INTO `digitalizacao`.`Milacron`(`temperatureZone2`) VALUES ({{Msg2}});\n",
"output": "str",
"x": 500,
"y": 640,
"wires": [
[
"6dc7d1928bbdee2e"
]
]
},
{
"id": "90ef15840b06b993",
"type": "template",
"z": "788edd9e.90d464",
"name": "",
"field": "topic",
"fieldType": "msg",
"format": "sql",
"syntax": "mustache",
"template": "INSERT INTO `digitalizacao`.`Milacron`(`temperatureZone3`) VALUES ({{Msg3}});\n",
"output": "str",
"x": 500,
"y": 680,
"wires": [
[
"6dc7d1928bbdee2e"
]
]
},
{
"id": "21e965406c3ead57",
"type": "template",
"z": "788edd9e.90d464",
"name": "",
"field": "topic",
"fieldType": "msg",
"format": "sql",
"syntax": "mustache",
"template": "INSERT INTO `digitalizacao`.`Milacron`(`temperatureZone4`) VALUES ({{Msg4}});\n",
"output": "str",
"x": 500,
"y": 720,
"wires": [
[
"6dc7d1928bbdee2e"
]
]
},
{
"id": "5cc98767cc4b23d9",
"type": "template",
"z": "788edd9e.90d464",
"name": "",
"field": "topic",
"fieldType": "msg",
"format": "sql",
"syntax": "mustache",
"template": "INSERT INTO `digitalizacao`.`Milacron`(`temperatureZone5`) VALUES ({{Msg5}});\n",
"output": "str",
"x": 500,
"y": 760,
"wires": [
[
"6dc7d1928bbdee2e"
]
]
},
{
"id": "6dc7d1928bbdee2e",
"type": "debug",
"z": "788edd9e.90d464",
"name": "debug 4",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 680,
"y": 580,
"wires": []
},
{
"id": "3e5dba4292a1de0d",
"type": "join",
"z": "788edd9e.90d464",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": true,
"timeout": "",
"count": "6",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 90,
"y": 480,
"wires": [
[
"6ddb1ac547f559dc",
"4b4ff719e1f9862f",
"24f176abbce316d0",
"e8b3f747c6d0872a",
"d6c8be535a70ba3a",
"bd4123f4bfc2132e",
"8b08096ed7226546"
]
]
},
{
"id": "4fe27f79a428f3f1",
"type": "change",
"z": "788edd9e.90d464",
"name": "",
"rules": [
{
"t": "set",
"p": "Msg0",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "delete",
"p": "payload",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 320,
"y": 560,
"wires": [
[
"1efc1ef2c9176ba5"
]
]
},
{
"id": "cfafcd2ca38e9e8e",
"type": "change",
"z": "788edd9e.90d464",
"name": "",
"rules": [
{
"t": "set",
"p": "Msg1",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "delete",
"p": "payload",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 320,
"y": 600,
"wires": [
[
"ca15650a118aa040"
]
]
},
{
"id": "3365f1a13e7c2a96",
"type": "change",
"z": "788edd9e.90d464",
"name": "",
"rules": [
{
"t": "set",
"p": "Msg2",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "delete",
"p": "payload",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 320,
"y": 640,
"wires": [
[
"540053aab91cb16d"
]
]
},
{
"id": "37dd688af68d8b20",
"type": "change",
"z": "788edd9e.90d464",
"name": "",
"rules": [
{
"t": "set",
"p": "Msg3",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "delete",
"p": "payload",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 340,
"y": 680,
"wires": [
[
"90ef15840b06b993"
]
]
},
{
"id": "199718568d191f8b",
"type": "change",
"z": "788edd9e.90d464",
"name": "",
"rules": [
{
"t": "set",
"p": "Msg4",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "delete",
"p": "payload",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 320,
"y": 720,
"wires": [
[
"21e965406c3ead57"
]
]
},
{
"id": "17f73edf67b2b937",
"type": "change",
"z": "788edd9e.90d464",
"name": "",
"rules": [
{
"t": "set",
"p": "Msg5",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "delete",
"p": "payload",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 320,
"y": 760,
"wires": [
[
"5cc98767cc4b23d9"
]
]
},
{
"id": "22fe35b54015744f",
"type": "debug",
"z": "788edd9e.90d464",
"name": "debug 5",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 620,
"y": 820,
"wires": []
},
{
"id": "63f66d4fe275d318",
"type": "function",
"z": "788edd9e.90d464",
"name": "function 9",
"func": "if (typeof msg.payload !== 'object' || msg.payload === null){\n msg.payload={};\n}\n\nswitch(msg.topic){\n case \"ns=2;s=@ActTmpBrlFeed[1]\":msg.payload.temperatureZone0=msg.value;\n break;\n case \"ns=2;s=@ActTmpBrlZone[1,1]\": msg.payload.temperatureZone1 = msg.value;\n break;\n case \"ns=2;s=@ActTmpBrlZone[1,2]\": msg.payload.temperatureZone2 = msg.value;\n break;\n case \"ns=2;s=@ActTmpBrlZone[1,3]\": msg.payload.temperatureZone3 = msg.value;\n break;\n case \"ns=2;s=@ActTmpBrlZone[1,4]\": msg.payload.temperatureZone4 = msg.value;\n break;\n case \"ns=2;s=@ActTmpBrlNozzle[1]\": msg.payload.temperatureZone5 = msg.value;\n break;\n}\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 260,
"y": 860,
"wires": [
[]
]
},
{
"id": "a6a95cc7073657cb",
"type": "template",
"z": "788edd9e.90d464",
"name": "",
"field": "topic",
"fieldType": "msg",
"format": "sql",
"syntax": "mustache",
"template": "INSERT INTO `digitalizacao`.`Milacron`(`temperatureZone0`,`temperatureZone1`,`temperatureZone2`,`temperatureZone3`,`temperatureZone4`,`temperatureZone5`) VALUES (\"{{sensorsvalues.temperatureZone0}}\",\"{{sensorsvalues.temperatureZone1}}\",\"{{sensorsvalues.temperatureZone2}}\",\"{{sensorsvalues.temperatureZone3}}\",\"{{sensorsvalues.temperatureZone4}}\",\"{{sensorsvalues.temperatureZone5}}\");\n",
"output": "str",
"x": 440,
"y": 860,
"wires": [
[
"22fe35b54015744f"
]
]
},
{
"id": "8b08096ed7226546",
"type": "function",
"z": "788edd9e.90d464",
"name": "function 10",
"func": "//ObtĂ©m o valor de msg.payload proveniente dos sensores\nvar sensorvalue = msg.payload;\n\n//Cria um objeto para armazenar os valores de todos os sensores\nvar sensorsvalues = {};\n\n//Verifica qual sensor está enviando a mensagem e define a saĂda correspondente\nif(msg.topic === \"ns=2;s=@ActTmpBrlFeed[1]\"){\n sensorsvalues.temperatureZone0 = sensorvalue;\n}\nelse if(msg.topic === \"ns=2;s=@ActTmpBrlZone[1,1]\"){\n sensorsvalues.temperatureZone1 = sensorvalue;\n}\nelse if(msg.topic === \"ns=2;s=@ActTmpBrlZone[1,2]\"){\n sensorsvalues.temperatureZone2 = sensorvalue;\n}\nelse if(msg.topic === \"ns=2;s=@ActTmpBrlZone[1,3]\"){\n sensorsvalues.temperatureZone3 = sensorvalue;\n}\nelse if(msg.topic === \"ns=2;s=@ActTmpBrlZone[1,4]\"){\n sensorsvalues.temperatureZone4 = sensorvalue;\n}\nelse if(msg.topic === \"ns=2;s=@ActTmpBrlNozzle[1]\"){\n sensorsvalues.temperatureZone5 = sensorvalue;\n}\n\n//Adiciona os valores dos sensores ao objeto msg\nmsg.sensorsvalues = sensorsvalues;\n\n//Retorna a mensagem modificada\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 250,
"y": 920,
"wires": [
[
"a6a95cc7073657cb"
]
]
}
]