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

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:

This is really cool. Just ordered my first z-wave based pieces (should be here in a week or two; a aeotec usb z-wave stick and some motion sensors) and this looks like something I will be using, thanks for creating this :slight_smile:

Still won’t run with the automation

@OmenWild

Changed the Shell Command to : “z_wave_graph: /home/homeassistant/.homeassistant/python_scripts/z_wave_graph.py”

And put “z_wave_graph.py” in > z_wave_graph: /home/homeassistant/.homeassistant/python_scripts/

And now get: “2018-02-05 13:10:00 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: /home/homeassistant/.homeassistant/python_scripts/z_wave_graph.py, return code: 1
NoneType: None”

Any ideas?

I wish I knew where in the code it was throwing that so I could put in proper error checking. Do you have base_url set in the http: section of your configuration.yaml?

Yes:
configuration.yaml=

  z_wave_graph:
    title: 'Z-Wave Graph'
    icon: mdi:vector-square
    url: !secret z_wave_graph_url

secrets.yaml
z_wave_graph_url: http://192.168.200.210:8123/local/z-wave-graph.html

That’s z_wave_graph_url. I asked about base_url. The script uses base_url to figure out how to login to your HA API. z_wave_graph_url is used to point HA to the HTML used to show you the results.

No I do not.

configuration.yaml:

http:
  api_password: !secret http_password

I’m stumped. It will default to http://localhost:8123 and pull the API password to connect, which seems like it should work for you.

I know, it’s weird because, if I run "/home/homeassistant/.homeassistant/python_scripts/z_wave_graph.py
" manually in shell from within my venv, it works, it just won’t run with the automation.

“2018-02-05 14:55:00 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: /home/homeassistant/.homeassistant/python_scripts/z_wave_graph.py, return code: 1
NoneType: None”

Does the above error mean it can’t find z_wave_graph.py?

The instructions were specifically for the docker build of home assistant. Are you using a docker? Just looking at your command line, you might try /usr/bin instead. What you would be looking for is the location of the homeassistant folder, where ever that is located, that path is what needs to go in between the single quotes.

Another thing to do would be to call the script from cron every hour, or even every day. You would just have to make sure the script run in the venv if you use one.

I haven’t actually animated it or anything, but I think my network is pretty static until I add more devices.

I had the same error “NoneType: None” when I put the script into the subfolder “python_scripts”. I didn’t get the error, when I but the script into another subfolder inside the configuration folder like “bin” . I think this comes from home-assistant who calls the python_scripts in another way.

I had the same error “NoneType: None” when I put the script into the subfolder “python_scripts”. I didn’t get the error, when I but the script into another subfolder inside the configuration folder like “bin” . I think this comes from home-assistant who calls the python_scripts in another way. With the location of the script inside “bin” I have no problems so far.

As I written, I use the hass.io installation which is “an operating system based on ResinOS and Docker”.

Not sure exactly what this means, can you explain?

I tried moving it to /srv/homeassistant/bin, and when i run the automation it still doesn’t update, no errors in log.

@OmenWild

So here is what I did.

I moved the python script to “/home/homeassistant/bin/z_wave_graph.py”, there was no “bin” directory, so I created it.

When I run the script from shell with “~/bin/z_wave_graph.py” it creates the “z-wave-graph.json”, but there isn’t any graph when I go to “http://localhost:8123/z_wave-graph”, and no errors in log, any ideas?

If I run the script from shell a second time, I get the following error:
“2018-02-06 11:55:01 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: /home/homeassistant/.homeassistant/python_scripts/z_wave_graph.py, return code: 1
NoneType: None”

The automation seem to be working now, if I trigger the automation I get the same error.

How big is the www/z-wave-graph.json file? Mine runs around 10KB. If yours is small, like just a couple hundred bytes, it probably means the script was unable to pull the node information from HA. You can confirm this by running ~/bin/z_wave_graph.py --debug. It should dump some debug info in the form show below. If you don’t get anything it means the script was unable to pull the data via the API.

vvvvvvvvvv 1 vvvvvvvvvv

1 => [6, 11, 12, 13, 14, 15, 16, 17, 19, 21, 22, 23, 24]
   [1]

20 => []

vvvvvvvvvv 2 vvvvvvvvvv

14 => [1, 4, 6, 7, 8, 12, 15, 16, 17, 21, 22, 23, 24]
   [14, 1]

15 => [1, 4, 6, 7, 8, 11, 12, 14, 16, 17, 21, 22, 24]
   [15, 1]

17 => [1, 6, 11, 12, 13, 14, 15, 16, 21, 22]
   [17, 1]

Hey, the .json file is 4 KB, and when I run “~/bin/z_wave_graph.py --debug” I get the following plus a bunch more info about node’s, battery, etc…:
vvvvvvvvvv 1 vvvvvvvvvv

1 => [2, 5, 7, 8]
[1]

vvvvvvvvvv 2 vvvvvvvvvv

2 => [1, 5, 7, 8, 10]
[2, 1]

7 => [1, 2, 5, 8]
[7, 1]

5 => [1, 2, 7, 8, 10]
[5, 1]

8 => [1, 2, 4, 5, 7, 10]
[8, 1]

vvvvvvvvvv 3 vvvvvvvvvv

10 => [2, 5, 7, 8]
[10, 8, 1]
[10, 2, 1]
[10, 5, 1]
[10, 7, 1]

4 => [7, 8]
[4, 8, 1]
[4, 7, 1]