Skip to content

Get more info about children #3

Description

@koying

I don't know if this is specific to my BR (HA addon beta), but I can ask for children details rather than the plain childtable, which allows me to get the extadress and thus do device naming mapping, which is extremely useful.

Dropping the rough diff here:

diff --git a/app.js b/app.js
index 861efe9..3fece70 100644
--- a/app.js
+++ b/app.js
@@ -200,8 +200,8 @@ async function processQueue() {
                 type: "getNetworkDiagnosticTask",
                 attributes: {
                     destination: currentExt || currentRloc,
-                    types: ["routerNeighbors", "childTable", "rloc16", "extAddress", "ipv6Addresses"],
-                    timeout: 5
+                    types: ["routerNeighbors", "children", "rloc16", "extAddress", "ipv6Addresses"],
+                    timeout: 10
                 }
             }]
         };
@@ -752,9 +752,9 @@ function updateGraph(data) {
     // Process Children (End Devices)
     // Note: Children are often sleepy end devices (SEDs) and we don't crawl them directly
     // because they don't have neighbors to share. We just display them attached to parent.
-    if (data.childTable) {
+    if (data.children) {
         // Pre-calculate positions for NEW children to distribute them in a separate circle
-        const newChildren = data.childTable.filter(child => {
+        const newChildren = data.children.filter(child => {
              const childId = `${rloc}_child_${child.childId}`;
              return !nodes.get(childId);
         });
@@ -762,11 +762,11 @@ function updateGraph(data) {
         const parentPos = parentPositions[rloc] || {x: 0, y: 0};
         const childRadius = 125; 
 
-        data.childTable.forEach((child, index) => {
+        data.children.forEach((child, index) => {
             // Calculate Child RLOC16: Parent RLOC + Child ID
             // Note: This is an approximation. Child ID is usually the last bits.
             // But for display, we might just use a unique ID.
-            const childId = `${rloc}_child_${child.childId}`;
+            const childId = `${child.rloc16}`;
             
             // Add Child Node
             if (!nodes.get(childId)) {
@@ -787,8 +787,11 @@ function updateGraph(data) {
                 // It does NOT give Extended Address. That is why they are missing ExtAddr.
                 
                 const isSleepy = child.mode && !child.mode.rxOnWhenIdle;
-                const label = `Child ${child.childId}\n${isSleepy ? '(Sleepy)' : ''}`;
-                
+                label = `Child ${child.rloc16}\n${isSleepy ? '(Sleepy)' : ''}`;
+                if (child.extAddress && deviceNames[child.extAddress]) {
+                    label = `${deviceNames[child.extAddress]}\n(${child.rloc16})`;
+                }
+
                 const nodeOpts = {
                     id: childId,
                     label: label,

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions