fix meshctrl with individual devices

Signed-off-by: si458 <simonsmith5521@gmail.com>

si458 committed Jul 12, 2025 at 12:57 UTC 6feebaee57df68400d17984196d9d1965ec7aae9
1 file changed +4 -4
meshctrl.js
+4 -4
@@ -2401,10 +2401,10 @@ function serverConnect() {
2401 for (var j in devicesInMesh) {
2402 var n = devicesInMesh[j];
2403 nodecount++;
2404 - if (settings.xmeshes) {
2404 + if (settings.xmeshes && settings.xmeshes[i]) {
2405 console.log('\"' + settings.xmeshes[i]._id.split('/')[2] + '\",\"' + settings.xmeshes[i].name.split('\"').join('') + '\",\"' + n._id.split('/')[2] + '\",\"' + n.name.split('\"').join('') + '\",' + (n.icon ? n.icon : 0) + ',' + (n.conn ? n.conn : 0) + ',' + (n.pwr ? n.pwr : 0));
2406 } else {
2407 - console.log('\"' + n._id.split('/')[2] + '\",\"' + n.name.split('\"').join('') + '\",' + (n.icon ? n.icon : 0) + ',' + (n.conn ? n.conn : 0) + ',' + (n.pwr ? n.pwr : 0));
2407 + console.log('\"\",\"\",\"' + n._id.split('/')[2] + '\",\"' + n.name.split('\"').join('') + '\",' + (n.icon ? n.icon : 0) + ',' + (n.conn ? n.conn : 0) + ',' + (n.pwr ? n.pwr : 0));
2408 }
2409 }
2410 }
@@ -2433,7 +2433,7 @@ function serverConnect() {
2433 for (var i in data.nodes) {
2434 var devicesInMesh = data.nodes[i];
2435 if (devicesInMesh.length > 0) {
2436 - if (settings.xmeshes) { console.log('\r\nDevice group: \"' + settings.xmeshes[i].name.split('\"').join('') + '\"'); }
2436 + if (settings.xmeshes && settings.xmeshes[i] && settings.xmeshes[i].name) { console.log('\r\nDevice group: \"' + settings.xmeshes[i].name.split('\"').join('') + '\"'); }
2437 console.log('id, name, icon, conn, pwr\r\n-------------------------');
2438 for (var j in devicesInMesh) {
2439 var n = devicesInMesh[j];
@@ -2662,7 +2662,7 @@ function getDevicesThatMatchFilter(nodes, x) {
2662 for (var d in nodes) { if ((nodes[d].ip != null) && (nodes[d].ip.indexOf(ipSearch) >= 0)) { r.push(nodes[d]); } }
2663 } else if (groupSearch != null) {
2664 // Group filter
2665 - if (settings.xmeshes) { for (var d in nodes) { if (settings.xmeshes[nodes[d].meshid].name.toLowerCase().indexOf(groupSearch) >= 0) { r.push(nodes[d]); } } }
2665 + if (settings.xmeshes) { for (var d in nodes) { if (settings.xmeshes[nodes[d].meshid] && settings.xmeshes[nodes[d].meshid].name.toLowerCase().indexOf(groupSearch) >= 0) { r.push(nodes[d]); } } }
2666 } else if (tagSearch != null) {
2667 // Tag filter
2668 for (var d in nodes) {