This data is received from a sensor. I will attach the original script to import it into your node red. The general idea is that the msg payload of the script I am attaching is giving the outcome shown in the first figure.
What I would like to do is to convert the msg payload outcome to be like the second figure as this data should be sent to a private cloud and the cloud receives the data in a certain format.
If the msg payload remain the same as the first figure, the cloud will reject the data and will never receive and store it. therefore, I want the msg payload outcome to like the second example.
Note that: there is no connection between the outcome of the two figures. the two figures are just examples of the data format I am having right now and the data format wanted
here is the full code and you can import it directly to your node-red
[{"id":"26a6bafe.355f36","type":"ui_template","z":"350d6959.0572c6","group":"b91de5f.d4f6018","name":"table for Device","order":2,"width":"9","height":"7","format":"\n th{\n border-bottom: 3px solid white;\n }\n caption, th, td {\n padding: 5px;\n text-align: left; \n }\n\n<table style="width:100%">\n \n \n Device
address\n Power
source\n Battery
voltage (V) \n <th colspan="2">Timestamp\n \n \n \n {{msg.payload[1]}}\n {{msg.payload[2]}}\n {{msg.payload[3]}}\n <td colspan="2">{{msg.payload[7]}}
\n {{msg.payload[8]}} \n \n \n Fcnt\n U/L SNR\n U/L RSSI\n \n {{msg.payload[4]}}\n {{msg.payload[5]}}\n {{msg.payload[6]}} \n \n \n","storeOutMessages":true,"fwdInMessages":true,"x":957,"y":200,"wires":[]},{"id":"d57e518d.d5999","type":"mqtt in","z":"350d6959.0572c6","name":"WISE-2410_UpLink","topic":"uplink/#","qos":"2","broker":"bdb9800e.62a88","x":208,"y":170.00000190734863,"wires":[["4ac8176.067a5e8"]]},{"id":"6373bec.d91b44","type":"mqtt in","z":"350d6959.0572c6","name":"WISE-2410","topic":"Advantech/#","qos":"0","broker":"bdb9800e.62a88","x":186,"y":251.00000190734863,"wires":[["b81e76d6.f6cba8"]]},{"id":"b81e76d6.f6cba8","type":"json","z":"350d6959.0572c6","name":"","x":366,"y":251.00000190734863,"wires":[["1edc6145.beb50f","f795ec88.cfc4f","1192206d.84723","c05c7892.122fe8","92e143d8.0a773","612e7df1.96f314"]]},{"id":"4ac8176.067a5e8","type":"json","z":"350d6959.0572c6","name":"","x":429,"y":171.00000190734863,"wires":[["92e143d8.0a773"]]},{"id":"1edc6145.beb50f","type":"function","z":"350d6959.0572c6","name":"TempHumi","func":"var TempHumi = [2];\ntempEvents = msg.payload.TempHumi.Event\nTempHumi[1] = msg.payload.TempHumi.SenVal/1000;\ntempRange = msg.payload.TempHumi.Range;\n\nswitch (tempEvents){\n case 0:\n TempHumi[0] = ("Status normal");\n break;\n case 1:\n TempHumi[0] = ("High alarm!");\n break;\n default:\n TempHumi[0] = ("Reading error!");\n}\n\nmsg.color = ((TempHumi[0]==="Status normal")? "White" : "Red");\n\nswitch (tempRange){\n case 0:\n tempRange = (" \'C");\n break;\n default:\n tempRange = ("\nRange parsing error!");\n}\n\nTempHumi[1] = TempHumi[1] + tempRange;\nmsg.payload = TempHumi;\nreturn msg;\n","outputs":"1","noerr":0,"x":627,"y":438,"wires":[["d04cdd16.167e4","ec83835f.9c06a"]]},{"id":"ad2a796f.07fe48","type":"ui_template","z":"350d6959.0572c6","group":"ee55d72.8bcad28","name":"table for Accelerometer","order":0,"width":"10","height":"4","format":"<table style="width:100%">\n \n \n Sensor Event\n Velocity RMS (mm/s) \n Acceloratioin RMS (g) \n Acceloratioin Peak (g) \n \n \n X-Axis\n {{msg.payload[0]}}\n {{msg.payload[1]}} \n {{msg.payload[2]}} \n {{msg.payload[3]}} \n \n \n Y-Axis\n {{msg.payload[4]}}\n {{msg.payload[5]}} \n {{msg.payload[6]}} \n {{msg.payload[7]}} \n \n \n Z-Axis\n {{msg.payload[8]}}\n {{msg.payload[9]}} \n {{msg.payload[10]}} \n {{msg.payload[11]}} \n \n","storeOutMessages":true,"fwdInMessages":true,"x":901,"y":255,"wires":[]},{"id":"f795ec88.cfc4f","type":"function","z":"350d6959.0572c6","name":"Accelerometer","func":"var aryAccel=[12];\nvar aryAccelColor=[3];\n\n//X-axis\naryAccel [0] = msg.payload.Accelerometer['X-Axis'].SenEvent;\nswitch (aryAccel [0]){\n case 0:\n aryAccel[0] = ("Status normal");\n break;\n case 1:\n aryAccel[0] = ("High alarm!!!");\n break;\n default:\n aryAccel[0] = ("Reading error!!!");\n}\n\naryAccelColor[0] = ((aryAccel[0]==="Status normal")? "White" : "Red");\naryAccel [1] = msg.payload.Accelerometer['X-Axis'].OAVelocity/100;\naryAccel [2] = msg.payload.Accelerometer['X-Axis'].Peakmg/1000;\naryAccel [3] = msg.payload.Accelerometer['X-Axis'].RMSmg/1000;\n\n//Y-axis\naryAccel [4] = msg.payload.Accelerometer['Y-Axis'].SenEvent;\nswitch (aryAccel [4]){\n case 0:\n aryAccel[4] = ("Status normal");\n break;\n case 1:\n aryAccel[4] = ("High alarm!!!");\n break;\n default:\n aryAccel[4] = ("Reading error!!!");\n}\n\naryAccelColor[1] = ((aryAccel[4]==="Status normal")? "White" : "Red");\naryAccel [5] = msg.payload.Accelerometer['Y-Axis'].OAVelocity/100;\naryAccel [6] = msg.payload.Accelerometer['Y-Axis'].Peakmg/1000;\naryAccel [7] = msg.payload.Accelerometer['Y-Axis'].RMSmg/1000;\n\n//Z-axis\naryAccel [8] = msg.payload.Accelerometer['Z-Axis'].SenEvent;\nswitch (aryAccel [8]){\n case 0:\n aryAccel[8] = ("Status normal");\n break;\n case 1:\n aryAccel[8] = ("High alarm!!!");\n break;\n default:\n aryAccel[8] = ("Reading error!!!");\n}\n\naryAccelColor[2] = ((aryAccel[8]==="Status normal")? "White" : "Red");\naryAccel [9] = msg.payload.Accelerometer['Z-Axis'].OAVelocity/100;\naryAccel [10] = msg.payload.Accelerometer['Z-Axis'].Peakmg/1000;\naryAccel [11] = msg.payload.Accelerometer['Z-Axis'].RMSmg/1000;\n\nmsg.payload = aryAccel;\nmsg.color = aryAccelColor;\nreturn msg;","outputs":1,"noerr":0,"x":635,"y":282.00000190734863,"wires":[["ad2a796f.07fe48","b164d3b8.428dd","c4a0262a.112098","87e7c1e4.be359"]]},{"id":"d04cdd16.167e4","type":"ui_template","z":"350d6959.0572c6","group":"c9d732f5.4d951","name":"table for Temparature","order":0,"width":"10","height":"2","format":"<table style="width:100%">\n \n Event\n Temparature\n \n \n {{msg.payload[0]}}\n {{msg.payload[1]}} <i class="fa fa-thermometer-three-quarters fa-2x" aria-hidden="true">\n \n\n","storeOutMessages":true,"fwdInMessages":true,"x":897,"y":445,"wires":[]},{"id":"1192206d.84723","type":"function","z":"350d6959.0572c6","name":"OAVelocityChart","func":"msg.payload = msg.payload.Accelerometer['X-Axis'].OAVelocity/100;\n\nreturn msg;","outputs":1,"noerr":0,"x":648,"y":536,"wires":[["99275ab2.5a66e8"]]},{"id":"99275ab2.5a66e8","type":"ui_chart","z":"350d6959.0572c6","name":"","group":"1eec8fb4.9e1aa","order":0,"width":"11","height":"4","label":"Velocity RMS (Root-Mean-Squar)","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"1000","removeOlderUnit":"3600","cutout":0,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":847,"y":539,"wires":[,]},{"id":"c05c7892.122fe8","type":"function","z":"350d6959.0572c6","name":"TempHumiChart","func":"msg.payload = msg.payload.TempHumi.SenVal/1000;\n\nreturn msg;","outputs":1,"noerr":0,"x":648,"y":605,"wires":[["b973abc0.57d728"]]},{"id":"b973abc0.57d728","type":"ui_chart","z":"350d6959.0572c6","name":"","group":"1eec8fb4.9e1aa","order":0,"width":"11","height":"5","label":"Temperature","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"1000","removeOlderUnit":"3600","cutout":0,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":855,"y":603,"wires":[,]},{"id":"92e143d8.0a773","type":"join","z":"350d6959.0572c6","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\n","timeout":"","count":"2","x":605,"y":210.00000190734863,"wires":[["bb36241.378c0d8"]]},{"id":"bb36241.378c0d8","type":"function","z":"350d6959.0572c6","name":"Device","func":"var aryDevice = ;\n\nvar tempEvents = msg.payload['Advantech/FFFFFFFF/data'].Device.Events;\nswitch (tempEvents){\n case 0:\n aryDevice[0] = ("Status normal");\n break;\n case 1:\n aryDevice [0] = ("High alarm!!!");\n break;\n default:\n aryDevice [0] = ("Reading error!!!");\n}\naryDevice[1] = msg.payload['uplink/FFFFFFFF'].devaddr;\nvar tempPowerSrc = msg.payload['Advantech/FFFFFFFF/data'].Device.PowerSrc;\nswitch (tempPowerSrc){\n case 0:\n aryDevice [2] = ("NA");\n break;\n case 1:\n aryDevice [2] = ("Line power");\n break;\n case 2:\n aryDevice [2] = ("Device battery");\n break;\n case 3:\n aryDevice [2] = ("Line power+Device battery");\n break;\n default:\n aryDevice [2] = ("Reading error!!!");\n}\naryDevice[3] = msg.payload['Advantech/FFFFFFFF/data'].Device.BatteryVolt/1000;\naryDevice[4] = msg.payload['uplink/FFFFFFFF'].fcnt;\naryDevice[5] = msg.payload['uplink/FFFFFFFF'].lsnr;\naryDevice[6] = msg.payload['uplink/FFFFFFFF'].rssi;\naryDevice[7] = msg.payload['Advantech/FFFFFFFF/data'].Device.Time;\nvar tempDate = new Date();\naryDevice[8] = tempDate.toGMTString(aryDevice[7]);\naryDevice[7] = aryDevice[7] + " UTC";\n\nmsg.payload = aryDevice;\nreturn msg;\n\n\n\n","outputs":1,"noerr":0,"x":769,"y":209.00000190734863,"wires":[["26a6bafe.355f36"]]},{"id":"612e7df1.96f314","type":"debug","z":"350d6959.0572c6","name":"","active":true,"console":"false","complete":"false","x":389,"y":417.00000190734863,"wires":},{"id":"b164d3b8.428dd","type":"ui_text","z":"350d6959.0572c6","group":"b305b0.10f3da5","order":0,"width":"4","height":"1","name":"","label":"","format":" <font color=" {{msg.color[0]}}"><i class="fa fa-exclamation fa-3x" aria-hidden="true">","layout":"col-center","x":882,"y":304,"wires":},{"id":"c4a0262a.112098","type":"ui_text","z":"350d6959.0572c6","group":"c284b9b9.f3f458","order":0,"width":"4","height":"1","name":"","label":"","format":" <font color=" {{msg.color[1]}}"><i class="fa fa-exclamation fa-3x" aria-hidden="true">","layout":"col-center","x":880,"y":344,"wires":},{"id":"87e7c1e4.be359","type":"ui_text","z":"350d6959.0572c6","group":"86daea8a.539478","order":0,"width":"4","height":"1","name":"","label":"","format":" <font color=" {{msg.color[2]}}"><i class="fa fa-exclamation fa-3x" aria-hidden="true">","layout":"col-center","x":881,"y":389,"wires":},{"id":"ec83835f.9c06a","type":"ui_text","z":"350d6959.0572c6","group":"3097e8ea.629bb8","order":0,"width":"4","height":"1","name":"","label":"","format":" <font color=" {{msg.color}}"><i class="fa fa-exclamation fa-3x" aria-hidden="true">","layout":"col-center","x":850,"y":495,"wires":},{"id":"41dcc056.2f92","type":"ui_template","z":"350d6959.0572c6","group":"f4159884.bd6df8","name":"","order":0,"width":"23","height":"2","format":"<img src="/title.jpg"/> ","storeOutMessages":false,"fwdInMessages":false,"x":205,"y":116,"wires":[]},{"id":"b91de5f.d4f6018","type":"ui_group","z":"","name":"Device: WISE-2410","tab":"6d05fd53.a2d884","order":2,"disp":true,"width":"9"},{"id":"bdb9800e.62a88","type":"mqtt-broker","z":"","broker":"192.168.1.2","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""},{"id":"ee55d72.8bcad28","type":"ui_group","z":"","name":"Accelerometer","tab":"6d05fd53.a2d884","order":3,"disp":true,"width":"10"},{"id":"c9d732f5.4d951","type":"ui_group","z":"","name":"Temperature of the target","tab":"6d05fd53.a2d884","order":4,"disp":true,"width":"10"},{"id":"1eec8fb4.9e1aa","type":"ui_group","z":"","name":"History Charts","tab":"6d05fd53.a2d884","order":9,"disp":true,"width":"23"},{"id":"b305b0.10f3da5","type":"ui_group","z":"","name":"X-Axis Alarm","tab":"6d05fd53.a2d884","order":5,"disp":true,"width":"4"},{"id":"c284b9b9.f3f458","type":"ui_group","z":"","name":"Y-Axis Alarm","tab":"6d05fd53.a2d884","order":6,"disp":true,"width":"4"},{"id":"86daea8a.539478","type":"ui_group","z":"","name":"Z-Axis Alarm","tab":"6d05fd53.a2d884","order":7,"disp":true,"width":"4"},{"id":"3097e8ea.629bb8","type":"ui_group","z":"","name":"Temperature Alarm","tab":"6d05fd53.a2d884","order":8,"disp":true,"width":"4"},{"id":"f4159884.bd6df8","type":"ui_group","z":"","name":"Title","tab":"6d05fd53.a2d884","order":1,"disp":false,"width":"23"},{"id":"6d05fd53.a2d884","type":"ui_tab","z":"","name":"Advantech LoRaWAN Vibration/Temp sensor Solution ","icon":"dashboard","order":1}]