Zigbee2MQTT network map

Havn’t implemented it, but looking at the code of the examples it’s pretty straight forward. I hope the webview element supports the touch as well, this might be a limitation. But we will see. I’m currently full on work, but when I have time this weekend to implement, I will then share the code :+1:

Hi,

can somebody help with correct syntax for
executeCommandLine("/usr/bin/sfdp -Nfontname=Arial -Nfontsize=9 -Ncolor=#666666 -Nstyle=filled -Nfillcolor=#eeeeee -Efontname=Arial -Efontsize=8 -Efontcolor=#cc0000 -Ecolor=#cccccc -Tsvg -o" + svgFile + " " + dotFile, 5000)

in OH3.
Getting errors in OH3 for this line because syntax for executeCommandLine changed.
With OH2 everything worked fine.

Thanks

Did you see the new network map release in v17.0 inside the new api?
You can embed this interactively with a Webview into your sitemap.

Could you please share how you did this? Thx.

First ensure that Zigbee2MQTT is running on the latest version with the new api and embed this into your sitemap by
Webview url="http://z2mserver:apiport/#/map" height=15

3 Likes

Can anybody describe what to do to get it working, like a small tutorial??
Has Graphviz to be installed? Do I need to create all the above mentioned things (files)? Or is this Webview command everything I need? (oviously not, as it is not working)
Thanks,
Ingo

I answer myself:
There has nothing else to be installed but ZigBee2MQTT, but at least in version 1.17.0.
In the configfile
data/configuration.yaml
has to be:

frontend:
  # Optional, default 8080
  port: 8080
  # Optional, default 0.0.0.0
  host: 0.0.0.0
  # Optional, enables authentication, disabled by default
  auth_token: your-secret-token

For OpenHab at least the port must be changed as OH is sitting on 8080. So, pick something like 8081
Then the map can be called by:
http://IP-Zigbee2MQTT-is-running-on:apiport/#/map
apiport would then be 8081
Within OH this can be used in the sitemap (IP is an example, change to your environment):
Webview url="http://192.168.178.23:8081/#/map" height=15

2 Likes

Hey k3067e3,

you probably fixed it by now, but here is the Code for DSL Rules in OH3 style.
Imports are not supported, so you have to use the full qualified names:

// parameters
val String dotFile = "/etc/openhab/html/zigbee.dot"
val String mapFile = "/etc/openhab/html/zigbee.map"
val String svgFile = "/etc/openhab/html/zigbee.svg" 

// once zigbee2mqtt sent graphviz network map => store it and convert it to PNG/SVG
if (zigbee_NetworkMap.state !== NULL && zigbee_NetworkMap.state != "") {
    var String dotString = zigbee_NetworkMap.state.toString
  
    // load mapping file and regex-replace network addresses with friendly names
    var java.io.FileReader fr = new java.io.FileReader(mapFile);
    var java.io.BufferedReader br = new java.io.BufferedReader(fr);
    var String line
    var String[] split
    var String regex
    var String replace
    while ((line = br.readLine()) !== null) {
	    split  = line.split("=")
	    if(split.length == 2) {
	    	regex = "(label=.*)(" + split.get(0) + ")(.*)"
	    	replace = "$1" + split.get(1) + "$3"
	    	dotString = dotString.replaceFirst(regex, replace)
        }
    }
    fr.close();

    // store result to DOT file
    var java.io.FileWriter fw = new java.io.FileWriter(dotFile, false);
    fw.write(dotString);
    fw.flush();
    fw.close();

    // render PNG/SVG
    executeCommandLine(Duration.ofSeconds(5000),"/usr/bin/sfdp","-Nfontname=Arial","-Nfontsize=9","-Ncolor=#666666","-Nstyle=filled","-Nfillcolor=#eeeeee","-Efontname=Arial","-Efontsize=8","-Efontcolor=#cc0000","-Ecolor=#cccccc","-Tsvg","-o",svgFile,dotFile)
  }
1 Like

No, had no clue to fix it.
But now it is working.

Thanks a lot!

Hello everyone, hope you can help me with troubleshooting on the ZigbeeMap.
I recently migrated from OH2.5 to OH3.0. Old OH is still running on a RPi3 and I can use to check if working as intended on the RPi4.
The problem I’m facing is that end-devices are not show linked in the network map, despite I can receive their data and log them into Influx.
The only key differenced I can think between old and new installation OH:

  • New CC251 Coordinator and Routers
  • New zigbee firmware for the coordinator (CC2531_SOURCE_ROUTING_20201128) and for the routers (CC2531_router_2020_09_29), vs.
    The new map looks like this (without end-devices link quality):
    zigbee
    While the old one looks like this (with end-devices link quality):
    zigbee
    I’ve been reading this thread and several other ones, but I’m not understanding where the problem could be.
    Additionally, in MQTTfx I observe that while an end-device is logged with full info such
{
    "battery": 100,
    "device": {
        "applicationVersion": 3,
        "friendlyName": "0x00158d0002c8ec85",
        "ieeeAddr": "0x00158d0002c8ec85",
        "manufacturerID": 4151,
        "manufacturerName": "LUMI",
        "model": "WSDCGQ11LM",
        "networkAddress": 63131,
        "powerSource": "Battery",
        "type": "EndDevice"
    },
    "humidity": 46.81,
    "linkquality": 128,
    "pressure": 1017,
    "temperature": 24.02,
    "voltage": 3195
}

the same the device returns an LQI error during networkmap:

{"level":"error","message":"Failed to execute LQI for '0x00158d0002c8ec85'"}

I’m also wondering if the problem is on the fact that launching the network map, the bridge problem returns

{"level":"info","message":"Starting network scan (includeRoutes 'false')"}

Hope you can help me getting the end-devices link quality visible on the new OH3 configuration, as it was in OH2.5
Thanks beforehand for any help you can provide.

Though I really like that z2m has not a web frontend, where we you can look up several things, the map function still needs some improvements. I still prefer the one of this thread as it is way cleaner and by using the mentioned libs a lot more mobile friendly.
What I did was instead of adding the map to a webview is to add the z2m web frontend URL to the starting screen of openhab (@ip:port)