Fix networkmap error when using Gledopto GL-C-008-2ID. #3623

This commit is contained in:
Koen Kanters
2020-05-30 18:27:25 +02:00
parent e4c3ffe38d
commit d440de8069
+14 -14
View File
@@ -57,32 +57,32 @@ class NetworkMap extends Extension {
let text = 'digraph G {\nnode[shape=record];\n';
let style = '';
topology.nodes.forEach((device) => {
topology.nodes.forEach((node) => {
const labels = [];
// Add friendly name
labels.push(`${device.friendlyName}`);
labels.push(`${node.friendlyName}`);
// Add the device short network address, ieeaddr and scan note (if any)
labels.push(
`${device.ieeeAddr} (${device.networkAddress})` +
((device.failed && device.failed.length) ? `failed: ${device.failed.join(',')}` : ''),
`${node.ieeeAddr} (${node.networkAddress})` +
((node.failed && node.failed.length) ? `failed: ${node.failed.join(',')}` : ''),
);
// Add the device model
if (device.type !== 'Coordinator') {
const definition = zigbeeHerdsmanConverters.findByDevice(device);
if (node.type !== 'Coordinator') {
const definition = this.zigbee.resolveEntity(node.ieeeAddr).definition;
if (definition) {
labels.push(`${definition.vendor} ${definition.description} (${definition.model})`);
} else {
// This model is not supported by zigbee-herdsman-converters, add zigbee model information
labels.push(`${device.manufacturerName} ${device.modelID}`);
labels.push(`${node.manufacturerName} ${node.modelID}`);
}
}
// Add the device last_seen timestamp
let lastSeen = 'unknown';
const date = device.type === 'Coordinator' ? Date.now() : device.lastSeen;
const date = node.type === 'Coordinator' ? Date.now() : node.lastSeen;
if (date) {
lastSeen = utils.formatDate(date, 'ISO_8601_local');
}
@@ -90,10 +90,10 @@ class NetworkMap extends Extension {
labels.push(lastSeen);
// Shape the record according to device type
if (device.type == 'Coordinator') {
if (node.type == 'Coordinator') {
style = `style="bold, filled", fillcolor="${colors.fill.coordinator}", ` +
`fontcolor="${colors.font.coordinator}"`;
} else if (device.type == 'Router') {
} else if (node.type == 'Router') {
style = `style="rounded, filled", fillcolor="${colors.fill.router}", ` +
`fontcolor="${colors.font.router}"`;
} else {
@@ -102,22 +102,22 @@ class NetworkMap extends Extension {
}
// Add the device with its labels to the graph as a node.
text += ` "${device.ieeeAddr}" [`+style+`, label="{${labels.join('|')}}"];\n`;
text += ` "${node.ieeeAddr}" [`+style+`, label="{${labels.join('|')}}"];\n`;
/**
* Add an edge between the device and its child to the graph
* NOTE: There are situations where a device is NOT in the topology, this can be e.g.
* due to not responded to the lqi scan. In that case we do not add an edge for this device.
*/
topology.links.filter((e) => (e.source.ieeeAddr === device.ieeeAddr)).forEach((e) => {
const lineStyle = (device.type=='EndDevice') ? 'penwidth=1, ' :
topology.links.filter((e) => (e.source.ieeeAddr === node.ieeeAddr)).forEach((e) => {
const lineStyle = (node.type=='EndDevice') ? 'penwidth=1, ' :
(!e.routes.length) ? 'penwidth=0.5, ' : 'penwidth=2, ';
const lineWeight = (!e.routes.length) ? `weight=0, color="${colors.line.inactive}", ` :
`weight=1, color="${colors.line.active}", `;
const textRoutes = e.routes.map((r) => r.destinationAddress);
const lineLabels = (!e.routes.length) ? `label="${e.linkquality}"` :
`label="${e.linkquality} (routes: ${textRoutes.join(',')})"`;
text += ` "${device.ieeeAddr}" -> "${e.target.ieeeAddr}"`;
text += ` "${node.ieeeAddr}" -> "${e.target.ieeeAddr}"`;
text += ` [${lineStyle}${lineWeight}${lineLabels}]\n`;
});
});