Ich habs gerade ausprobiert es gehen nur 4 Temps
[
{
"id": "7b874c502a51605c",
"type": "function",
"z": "e78e73d3.53155",
"name": "generate objects",
"func": "let relays = msg.payload.relays ?? 0;\nlet wrelays = msg.payload.wrelays ?? 0;\nlet dimmer = msg.payload.dimmer ?? 0;\nlet temp = msg.payload.temp ?? 0;\nlet batt = msg.payload.batt ?? 0;\nlet level = msg.payload.level ?? 0;\n\nfunction wordToNumber(word) {\n const numberWords = {\n zero: 0,\n one: 1,\n two: 2,\n three: 3,\n four: 4,\n five: 5,\n six: 6,\n seven: 7,\n eight: 8,\n nine: 9,\n ten: 10, // Add more as needed\n };\n\n const lowerCaseWord = word.toLowerCase();\n return numberWords[lowerCaseWord] || NaN;\n}\n\n// if (relays != null && relays != undefined && relays != \"0\") {\n// let i = 0;\n// msg.payload.relays = [];\n\n// while (i < relays.length) {\n// msg.payload.relays[i] = {};\n// msg.payload.relays[i].id = \"Relay\"+wordToNumber(relays[i])\n// msg.payload.relays[i].state = global.get(relays[i]);\n// msg.payload.relays[i].name = global.get(\"N\" + relays[i]);\n// //msg.payload.relays[i].autooff = global.get(relays[i] + \"offauto\") ?? 0;\n// i++;\n// }\n// }\n\n// if (wrelays != null && wrelays != undefined && wrelays != \"0\") {\n// let i = 0;\n// msg.payload.wrelays = [];\n\n// while (i < wrelays.length) {\n// msg.payload.wrelays[i] = {};\n// msg.payload.wrelays[i].id = \"WifiRelay\"+wordToNumber(wrelays[i].substring(1))\n// msg.payload.wrelays[i].state = global.get(wrelays[i]);\n// msg.payload.wrelays[i].name = global.get(\"N\" + wrelays[i]);\n// msg.payload.wrelays[i].firmware = global.get(\"wrelay\" + wordToNumber(wrelays[i].substring(1))+\"_firmware\");\n// //msg.payload.wrelays[i].autooff = global.get(wrelays[i] + \"offauto\") ?? 0;\n// i++;\n// }\n// }\n\n// if (dimmer != null && dimmer != undefined && dimmer != \"0\") {\n// let i = 0;\n// msg.payload.dimmer = [];\n\n// while (i < dimmer.length) {\n// msg.payload.dimmer[i] = {};\n// msg.payload.dimmer[i].id = \"dimmer\"+(parseInt(dimmer[i].substring(6))+1)\n// msg.payload.dimmer[i].state = global.get(dimmer[i]);\n// msg.payload.dimmer[i].name = global.get(\"N\" + dimmer[i]);\n// //msg.payload.dimmer[i].autooff = global.get(dimmer[i] + \"offauto\") ?? 0;\n// i++;\n// }\n// }\n\nif (temp != null && temp != undefined && temp != \"0\") {\n /*let i = 0;\n msg.payload.temp = [];\n\n while (i < temp.length) {\n msg.payload.temp[i] = {};\n msg.payload.temp[i].id = \"temp\"+parseInt(temp[i].substring(4))\n msg.payload.temp[i].state = global.get(temp[i])\n msg.payload.temp[i].name = global.get(\"N\" + temp[i]);\n i++;\n }\n */\n \n msg.payload.temp = [\n {\n \"id\":\"temp1\",\n \"state\":global.get(\"temp1\").toString(),\n \"name\":global.get(\"Ntemp1\"),\n },\n {\n \"id\":\"temp2\",\n \"state\":global.get(\"temp2\").toString(),\n \"name\":global.get(\"Ntemp2\"),\n },\n {\n \"id\":\"temp3\",\n \"state\":global.get(\"temp3\").toString(),\n \"name\":global.get(\"Ntemp3\"),\n },\n {\n \"id\":\"temp4\",\n \"state\":global.get(\"temp4\").toString(),\n \"name\":global.get(\"Ntemp4\"),\n }\n\n ];\n\n}\nif (level != null && level != undefined && level != \"0\") {\n let i = 0;\n msg.payload.level = [];\n\n while (i < level.length) {\n msg.payload.level[i] = {};\n msg.payload.level[i].id = \"level\"+parseInt(level[i].substring(5))\n msg.payload.level[i].state = global.get(\"Level\"+level[i].substring(level[i].length-1));\n msg.payload.level[i].name = global.get(\"NLevel\" + level[i].substring(level[i].length - 1));\n i++;\n }\n}\nif (batt != null && batt != undefined && batt != \"0\" || batt != 0 && batt == 1) {\n msg.payload.batt = {\n \"VoltB\": global.get(\"QUCC_Volt_ges\"),\n \"Ampere\": global.get(\"QUCC_Amp_ges\"),\n \"battsoc\": global.get(\"QUCC_SOC\")\n }\n}\n\n\n\nreturn msg;\n\n\n ",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 550,
"y": 3260,
"wires": [
[
"081e13488093c513"
]
]
}
]