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

Thanks for integrating these options!

I’ve updated to the new version, and amhving the same results as Tinkerer. I am able to get the json generated (using my IP and --no-ssl, and also my domain and --port 443!). But no svg update, and no errors.

I also didn’t have luck with the updated shell_command. Still getting the same generic error. But I also don’t have a python3 in my HA user’s ~/bin folder (where the script lives).

Thanks again for the tool, and also for the quick development updates!

There should be no need for that updated command to reference python like that - it’s the whole point of the #! in the shell command after all (for @OmenWild).

The newest version doesn’t use SVG, but rather vis.js to directly draw the nodes. You may have to restart HA for the new html to work. I’ve been loading the dev tools and disabling caching, but it still takes two refreshes for changes to the html file to show up. HA seems to be really aggressive at caching. Once you get the new html loaded there is a trick that will avoid caching for the json.

Ah, you will need to tweak that to point to your Python 3 binary then. Or create a symlink from the bin/ directory of HA to the real binary.

The sha-bang line of #! /usr/bin/env python3 was suppose to let HA call it directly, but it did not work for me. If I get some time I’ll investigate.

I agree completely. I do Linux work for a living and the sha-bang line was suppose to work universally. I was getting an error which makes me think the HA config never loaded. Testing is a bit of a pain (restart HA, wait a couple minutes, remember to check, etc).

Ah! Booo :wink:

I liked that I could run it from outside of HA and have the SVG created - because restarting with Z-Wave is a 5+ minute job, assuming OZW doesn’t fall over because it corrupted its own cache…

I’ll wait for HA 0.62 then and have another look at this.

Thanks

Ah, makes sense. It’s actually my fault, I forgot to copy over the new html contents… whoops.

New version looks great. I have to admit that without the secondary paths, my tiny network looks a bit… well… tiny. But I can see this would be much more readable for larger networks. Overall, a good change, and less to install is also a bonus.

37%20PM

I’ll have to see what I can get to work for the shell_command. I imagine this could vary wildly for a lot of folks, considering all the different setups.

I liked that part too. I debugged the Python script by loading the SVG in a image viewer that would watch for changes, but I couldn’t quite get the graph I wanted with Graphviz. The vis.js graph is pretty cool.

If you are running a web server you could point it at the www/ directory and bypass HA.

Or, if you are running Firefox or Chrome, you can load the developer tools (control-shift-i (that’s an eye, not a one)). Then under the network tab enable Disable Caches, then reload a couple times. Once the new HTML is loaded you should be good to go.

Well, I don’t have to restart HA to get it to serve up the HTML. All I need is to run the program to create the JSON and then load the web page?

That’s what I’m guessing. If everyone lets me know what works for them I might be able to suss out a common theme that will work for most people.

O M F G

That is awesome!

Nit pick. There’s no point in drawing the lines “down” from the battery devices (eg Living room multi-sensor).

1 Like

Thanks! I was pretty happy when I got mine to finally graph like that too.

It’s hard to tell as things get squished together, but I don’t think there are lines down. I think you’re seeing lines from the 3rd tier to the Spare Socket and Patio Door devices. You can click on a node and it will highlight the connections.

You’re right. It’s just squished to make it look like there are links. I’ll play with the sliders a bit more.

I need to find the configuration combination that does the hierarchy, but doesn’t let nodes overlap. Possibly staggering each row up/down a little to make it cleaner.

This is getting really good. Great work.

Now if only we had statistics on the RTT to each node, and could color the lines by link health… :grinning:

Well, we do have averageRequestRTT and averageResponseRTT, but that’s end-to-end, not per hop. Hmmm.

1 Like

I just pushed a version that should show remotes on the graph, though mine has no connections.

BREAKING: I’ve switched my setup to proxy SSL through Apache, which means my HA is no longer using SSL. I’ve swapped the SSL default to false, so if your HA does SSL you will need to call with --ssl.

Thank you @OmenWild for your work on this.

Any suggestions for this error? I just updated to the latest version and was attempting to execute within my venv. I was able to run the old version using Graphviz and I now have networkx installed in my venv. Ubuntu Server 16.04.

Traceback (most recent call last):
  File "/home/homeassistant/bin/z-wave-graph.py", line 248, in <module>
    zwave = ZWave(config, args)
  File "/home/homeassistant/bin/z-wave-graph.py", line 160, in __init__
    self._build_dot()
  File "/home/homeassistant/bin/z-wave-graph.py", line 200, in _build_dot
    if not self.nodes.nodes[edge].forwarder:
KeyError: 12

I’m not having much luck with the newest version. I am getting the following error:

Error fetching states
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/remote.py", line 206, in get_states
    item in req.json()]
  File "/srv/homeassistant/lib/python3.5/site-packages/requests/models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

It also doesn’t seem to like the --ssl option, giving me an error that it is not an unrecognized argument.

This one I’m going to have to ruminate on. I’m using Python 3.6, but have 3.5 installed. I’ll give it a try and see what happens.

Inadequate testing on my part, sorry. Should be fixed in the newest push.