Hi JL...
This is how I am doing it.... (Yeh, I know my coding isnt the best, but it works for me...)
{
"id": "14161f8f.5bb748",
"type": "function",
"z": "a8cb3b26.8b8608",
"g": "35635e2d.56d582",
"name": "Extract Pylon req Bat Query Data",
"func": "if(msg.payload == \"clear\"){//clear and initialise\n context.set(\"arr\",undefined,\"file\") ;\n return null\n}\n\nvar rT = 17; // Table max #rows(1st is headings)\n cT = global.get('INVNoBattStrings','file')+1 ; // Table max #columns(was5)\n r = 0 ; // Row Counter\n c = 0 ; // Column Counter\n \nif(context.get(\"arr\",\"file\") != undefined){\n arr = context.get(\"arr\",\"file\")\n}\nelse{\n arr = [];//Doesn't exist, so create the base array\n} \n//Layout Blank Table\nfor(r = 0; r < rT; r++) { // for each of rows(1st is headings)\n if(arr [r] == undefined){//Create if it doesn't exist\n arr[r] = []\n } \n for(c = 0; c < cT; c++) { // create columns\n if(arr[r][c] == undefined){//Create if it doesn't exist\n arr[r][c] = null\n }\n } \n}\n\n//Put in Headings/Titles\narr[0][0] = \"Batt#\";//\"Power\";\narr[1][0] = \"Volt\";\narr[2][0] = \"Amps\";//\"Curr\";\narr[3][0] = \"ºC\"//\"Temp C\";//\"Tempr\";\narr[4][0] = \"SOC\";//\"Coulomb\"; \narr[5][0] = \"Tlow\";\narr[6][0] = \"Thigh\";\narr[7][0] = \"Vlow\";\narr[8][0] = \"Vhigh\";\narr[9][0] = \"Mos ºC\";//\"MosTempr\";\narr[10][0] = \"Base.St\";\narr[11][0] = \"Volt.St\";\narr[12][0] = \"Curr.St\"; \narr[13][0] = \"Temp.St\"; \narr[14][0] = \"B.V.St\";\narr[15][0] = \"B.T.St\";\narr[16][0] = \"M.T.St\";\n//arr[13][0] = \"Time\";\n\nData = msg.payload;\nBatt = \"\";\nBatt = msg.payload.substring(55,61);//Get Unique for this query\n\n//Look for trigger string\nif(Batt == \"Dischg\" || Batt == \"Charge\"||Batt == \"Idle \"){\n //Data Populate from msg.payload string\n Address = Number(msg.payload.substring(0,5));//Battery\n arr[0][Address]= Number(msg.payload.substring(0,5));//Battery\n arr[1][Address]= Number(msg.payload.substring(6,12))/1000;//Volt\n arr[2][Address]= Number(msg.payload.substring(13,19))/1000;//Curr\n arr[3][Address]= Number(msg.payload.substring(20,26))/1000;//Tempr\n arr[4][Address]= Number(msg.payload.substring(91,99).trim().replace('%', ''));//Coulomb\n arr[5][Address]= Number(msg.payload.substring(27,33))/1000;//Tlow\n arr[6][Address]= Number(msg.payload.substring(34,40))/1000;//Thigh\n arr[7][Address]= Number(msg.payload.substring(41,47))/1000;//Vlow\n arr[8][Address]= Number(msg.payload.substring(48,54))/1000;//Vhigh\n arr[9][Address]= Number(msg.payload.substring(138,146))/1000;//MosTempr\n arr[10][Address]= msg.payload.substring(55,63).trim();//Base.St\n arr[11][Address]= msg.payload.substring(64,72).trim();//Volt.St\n arr[12][Address]= msg.payload.substring(73,81).trim();//Curr.St\n arr[13][Address]= msg.payload.substring(82,90).trim();//Temp.St\n arr[14][Address]= msg.payload.substring(121,129).trim();//B.V.St\n arr[15][Address]= msg.payload.substring(130,137).trim();//B.T.St\n arr[16][Address]= msg.payload.substring(147,154).trim();//M.T.St\n //arr[][]= msg.payload.substring(100,120).trim();//Time\n context.set(\"arr\",arr,\"file\");\n for(r = 0; r < rT; r++) { // for each of rows(1st is headings)\n for(c = 0; c < cT; c++) { // for each of columns\n if(arr[r][c] == null){ // Check it's populated\n return; //Get out of here, table isnt full yet\n }\n } \n }\n //Table is populated fully - Serve it!\n msg.payload = arr;\n return msg;\n}\n\nreturn;//Not a trigger string, just leave!\n\n//Power Volt Curr Tempr Tlow Thigh Vlow Vhigh Base.St Volt.St Curr.St Temp.St Coulomb Time B.V.St B.T.St MosTempr M.T.St\n//2 49020 -4748 27500 23900 24000 3268 3268 Dischg Normal Normal Normal 36% 2021-05-20 22:32:13 Normal Normal 25600 Normal\n//1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 330,
"y": 1020,
"wires": [
[
"b9680781.24a37"
]
]
},
{
"id": "b9680781.24a37",
"type": "delay",
"z": "a8cb3b26.8b8608",
"g": "35635e2d.56d582",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "2",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"outputs": 1,
"x": 580,
"y": 1020,
"wires": [
[
"a1639b7e.8df1a8"
]
]
},
{
"id": "a1639b7e.8df1a8",
"type": "ui_table",
"z": "a8cb3b26.8b8608",
"g": "35635e2d.56d582",
"group": "78ad4256.fda3d4",
"name": "Batt Basic Info",
"order": 2,
"width": 7,
"height": 10,
"columns": [],
"outputs": 0,
"cts": false,
"x": 770,
"y": 1020,
"wires": []
},
{
"id": "2365c560.586fa2",
"type": "link in",
"z": "a8cb3b26.8b8608",
"g": "35635e2d.56d582",
"name": "",
"links": [
"a210e66a.672038",
"166e9d46.bfd18b"
],
"x": 155,
"y": 1020,
"wires": [
[
"14161f8f.5bb748"
]
]
},
{
"id": "78ad4256.fda3d4",
"type": "ui_group",
"name": "Pylon Info",
"tab": "ac8a95bb.741908",
"order": 4,
"disp": true,
"width": "7",
"collapse": true
},
{
"id": "ac8a95bb.741908",
"type": "ui_tab",
"name": "Management & Diag",
"icon": "dashboard",
"order": 11,
"disabled": false,
"hidden": false
}
]
Regds
Ed