Graph your Z-Wave mesh (Python, auto-update)

There are two different pieces that have URLs. The one you define above is used by HA to route the iframe request to the HTML that serves the graph. The base_url setting in the http: section is used by the Python script to know how to connect to the API, so it can write the json that is graphed by the html piece in the iframe.

Yeah, I guess I should have realized that… :frowning:
My base url is : base_url: my.domain.com

I just pushed a version that uses 1 / averageRequestRTT for the width of the edges. Faster nodes will show as thicker lines, while slow nodes can go as thin as a single pixel. In general this looks reasonable for my mesh network. My 1st layer devices are significantly faster than my 2nd, and my battery powered devices are pretty slow. I was torn between averageRequestRTT and averageResponseRTT. I couldn’t find any documentation on the differences, but I suspect Response includes the time waiting for a battery powered device to wake up.

As you mouse-over the edges, keep in mind that the numbers are for the entire traversal of the network, not just the individual paths. This means every edge from a node in layer 3 to every node it connects to in layer 2 has the same value.

That’s pretty sweet.

The differences below 100 are reasonably obvious, but above that… not so much:

If you look at the top row, two have RTTs under 200, two under 1000, and one over that.The red line on the left (Bear <> Table) is for an RTT of 140. The orange one coming down from Table is 311.

Oh, and the really thin ones, those are for an RTT of zero (I’m guessing no data).

Given that the RTT is milliseconds, anything over 500 is “not good” (half a second), and anything over 1000 is bad news (over a second). Even zoomed in the difference between 160 and 1400 is, well, there is none.

I pretty much have to agree. It just doesn’t add anything. I tried a version with the edge width based on the tiers of time as you mentioned, but I don’t really think that adds anything either. It just gets too messy.

One thing I’ve tested locally is to put the RTT in () under the node name, which seems decent. I’ve also sorted the nodes by name so the list is alphabetically…

Hmm, I wonder how it would look sorted by most-to-least number of connections? The left would be really messy and the right would be mostly empty, so maybe not an improvement.

Still tinkering locally, but I don’t have any major changes in mind.

OK, so for the docker folks, this by default does not work…
BUT, i have finally gotten to the solution by adding:

sys.path.append('/usr/src/app')

The header now looks like this:

#! /usr/bin/env python3

import argparse
import datetime
import json
import os.path
import sys
sys.path.append('/usr/src/app')

This is the link to the discussion:

Additionally, you will need to change the link in the script to point to the correct dir for python3

z_wave_graph: /usr/local/bin/python3 /config/<YOUR-PATH>/z-wave-graph.py <--ssl --port 443 (if https)>

ENJOY!

Awesome detective work, thank you! I’ve pushed a new version that has the sys.path.append() part and mentions the shell_command change in the README.

1 Like

Finally got around to giving this a shot. Awesome! Installation was a little hairy, but I got it worked out.

The RTT stats are quite interesting to see, especially the difference between 1-hop and 2-hop devices.

I’m getting an error if I run the script from shell, any ideas?

"PermissionError: [Errno 13] Permission denied: ‘/home/homeassistant/.homeassistant/www/z-wave-graph.json’
"
image

www/ or at least that www/z-wave-graph.json needs to be writable by the user that runs the script. You can create the file and set permissions appropriately if you don’t want to change the permissions on the directory.

:+1:Needed write permission to the www directory.

It runs from within the shell manually, but not from the automation, any ideas?

Any error messages? Is HA running in Docker? If so, see the README for an updated from yesterday.

No error’s in log, running Hassbian.

Are you running HA as root?

I asume so, not sure

How do you start it?

HA auto starts on boot or, “sudo systemctl start [email protected]

What does /etc/systemd/system/[email protected] say?

Does it contain the line

user=%i

If so, you are running HA as user homeassistant, but /home/homeassistant/.homeassistant/www is owned by root.

You probably want to do:

sudo chown -R homeassistant /home/homeassistant/.homeassistant
sudo chgrp -R homeassistant /home/homeassistant/.homeassistant

to get everything under your config directory changed to ownership (and group, but not as critical) by the user that runs HA.

Hi Bigrob8181,

I’ve the hass.io installation.
And I added the line sys.path.append('/usr/src/app') and unfortunately I got the same error :

core-ssh:/usr/bin# python3 z-wave-graph.py --debug
Traceback (most recent call last):
  File "z-wave-graph.py", line 31, in <module>
    import homeassistant.config
ModuleNotFoundError: No module named 'homeassistant'

I take a look at the path and I didn’t have a path “/usr/src” in my hass.io installation :frowning: