mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 19:56:42 +00:00
Improve ZHA routes vizualization (#26270)
This commit is contained in:
parent
20dab92ad8
commit
d9bf605c3f
@ -290,7 +290,8 @@ export class ZHANetworkVisualizationPage extends LitElement {
|
|||||||
},
|
},
|
||||||
symbolSize: (width / 4) * 6 + 3, // range 3-9
|
symbolSize: (width / 4) * 6 + 3, // range 3-9
|
||||||
// By default, all links should be ignored for force layout
|
// By default, all links should be ignored for force layout
|
||||||
ignoreForceLayout: true,
|
// unless it's a route to the coordinator
|
||||||
|
ignoreForceLayout: route.dest_nwk !== "0x0000",
|
||||||
};
|
};
|
||||||
links.push(link);
|
links.push(link);
|
||||||
existingLinks.push(link);
|
existingLinks.push(link);
|
||||||
@ -331,7 +332,7 @@ export class ZHANetworkVisualizationPage extends LitElement {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Now set ignoreForceLayout to false for the strongest connection of each device
|
// Now set ignoreForceLayout to false for the best connection of each device
|
||||||
// Except for the coordinator which can have multiple strong connections
|
// Except for the coordinator which can have multiple strong connections
|
||||||
devices.forEach((device) => {
|
devices.forEach((device) => {
|
||||||
if (device.device_type === "Coordinator") {
|
if (device.device_type === "Coordinator") {
|
||||||
@ -342,18 +343,21 @@ export class ZHANetworkVisualizationPage extends LitElement {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Find the link that corresponds to this strongest connection
|
// Find the link that corresponds to this strongest connection
|
||||||
let strongestLink: NetworkLink | undefined;
|
let bestLink: NetworkLink | undefined;
|
||||||
links.forEach((link) => {
|
const alreadyHasBestLink = links.some((link) => {
|
||||||
if (
|
if (link.source === device.ieee || link.target === device.ieee) {
|
||||||
(link.source === device.ieee || link.target === device.ieee) &&
|
if (!link.ignoreForceLayout) {
|
||||||
link.value! > (strongestLink?.value ?? 0)
|
return true;
|
||||||
) {
|
|
||||||
strongestLink = link;
|
|
||||||
}
|
}
|
||||||
|
if (link.value! > (bestLink?.value ?? -1)) {
|
||||||
|
bestLink = link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (strongestLink) {
|
if (!alreadyHasBestLink && bestLink) {
|
||||||
strongestLink.ignoreForceLayout = false;
|
bestLink.ignoreForceLayout = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user