mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-10-15 02:30:05 +00:00
Implement basic graphviz networkmap. #252
This commit is contained in:
@@ -14,6 +14,7 @@ class NetworkMap {
|
||||
// Set supported formats
|
||||
this.supportedFormats = {
|
||||
'raw': this.raw,
|
||||
'graphviz': this.graphviz,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -33,6 +34,18 @@ class NetworkMap {
|
||||
raw(topology) {
|
||||
return JSON.stringify(topology);
|
||||
}
|
||||
|
||||
graphviz(topology) {
|
||||
let text = 'digraph G {\n';
|
||||
topology.forEach((item) => {
|
||||
text += ` "${item.ieeeAddr}" [label="${item.ieeeAddr} (${item.status})"];\n`;
|
||||
text += ` "${item.ieeeAddr}" -> "${item.parent}" [label="${item.lqi}"]\n`;
|
||||
});
|
||||
|
||||
text += '}';
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NetworkMap;
|
||||
|
||||
Reference in New Issue
Block a user