mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46: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
|
||||
// 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);
|
||||
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
|
||||
devices.forEach((device) => {
|
||||
if (device.device_type === "Coordinator") {
|
||||
@ -342,18 +343,21 @@ export class ZHANetworkVisualizationPage extends LitElement {
|
||||
});
|
||||
} else {
|
||||
// Find the link that corresponds to this strongest connection
|
||||
let strongestLink: NetworkLink | undefined;
|
||||
links.forEach((link) => {
|
||||
if (
|
||||
(link.source === device.ieee || link.target === device.ieee) &&
|
||||
link.value! > (strongestLink?.value ?? 0)
|
||||
) {
|
||||
strongestLink = link;
|
||||
let bestLink: NetworkLink | undefined;
|
||||
const alreadyHasBestLink = links.some((link) => {
|
||||
if (link.source === device.ieee || link.target === device.ieee) {
|
||||
if (!link.ignoreForceLayout) {
|
||||
return true;
|
||||
}
|
||||
if (link.value! > (bestLink?.value ?? -1)) {
|
||||
bestLink = link;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (strongestLink) {
|
||||
strongestLink.ignoreForceLayout = false;
|
||||
if (!alreadyHasBestLink && bestLink) {
|
||||
bestLink.ignoreForceLayout = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user