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

Very possible. I have API Password still enabled. But I’ll sit and wait patiently. Thanks so much for creating this!

Getting this error when trying to run from the shell:

(homeassistant) homeassistant@hassbian:~/.homeassistant $ ./bin/z-wave-graph.py --debug --config ~/.homeassistant/
Traceback (most recent call last):
  File "./bin/z-wave-graph.py", line 323, in <module>
    zwave = ZWave(config, args)
  File "./bin/z-wave-graph.py", line 184, in __init__
    m = self.request('')
  File "./bin/z-wave-graph.py", line 200, in request
    response = get(url, headers=headers)
  File "/srv/homeassistant/lib/python3.5/site-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/requests/sessions.py", line 616, in send
    adapter = self.get_adapter(url=request.url)
  File "/srv/homeassistant/lib/python3.5/site-packages/requests/sessions.py", line 707, in get_adapter
    raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for 'axxxxxs.duckdns.org:8123/api'
(homeassistant) homeassistant@hassbian:~/.homeassistant $ 

Any hint?

@techwithjake and @AlbertoLpx,

I was playing with this last night and today. I finally got it running. I was having similar issues to each of you.
I can confirm it works fine on the latest version (.0.82.0). I am in fact still running an api password though. Can you:

  1. look at your base url and make sure it is exacly what you use to log into Home Assistant.
  2. check your permissions on /www/z-wave-graph.html
  3. check your permissions on /bin/z-wave-graph.py

I changed my permissions on each to the Home Assistant user and group and did a chmod 755 to z-wave-graph.py. Neither change had a positive affect. Once I set my base url to exactly what I use to log into Home Assistant it worked.

Please try setting your base url first because if it works I would like to put my files back to how they were :wink:
If setting your base url first has no affect, please try permissions on z-wave-graph.html first and then z-wave-graph.py.

@OmenWild, seems to be broken in 83.1

I have read through the entire thread. Tried tons of stuff. Think it has to do with the API password.

> (homeassistant) homeassistant@raspberrypi3:/home/pi $ /srv/homeassistant/bin/python3 ~/.homeassistant/bin/z-wave-graph.py --debug
> {'nodes': [], 'edges': []}

Any suggestions?

UPDATE: This fixed my issue:

57c57
<         except (KeyError, TypeError):
---
>         except KeyError:

The above is a patch for z-wave-graph.py that fixed this issue with my installation.

I’ve created a pull request to add long lived API token support: https://github.com/OmenWild/home-assistant-z-wave-graph/pull/12

Perhaps it can solve your issue? It works for me :slight_smile:

Thanks @mvdm, I’ve merged it. I was tempted to remove the legacy API, but I figure there must be some holdouts, so I’ve kept it for now.

I tried to do this

I end up with this error in Home Assistant:

Error while executing automation automation.generate_z_wave_graph. Service not found for call_service at pos 1: (ServiceNotFound(…), ‘Service shell_command.z_wave_graph not found’)

When I try to run the command in the CLI i get an error:

error: unrecognized arguments: --token

What am I doing wrong?

It looks like you don’t have the shell command configured and are running an older version, could you check?

How would I do that? I made the changes listed in the PR. Maybe I should just download the new file?

@OmenWild
It’s been a while since this was setup and working, well, until today that is, any idea what may be causing the following error?

2019-05-30 18:05:00 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: `/srv/homeassistant/bin/python3 /home/homeassistant/.homeassistant/python_scripts/z_wave_graph.py`, return code: 1
NoneType: None

I suspect it has something to do with some assumptions the script makes about the state of the objects it gets back from HA. Can you run it from the command line? That might give you a full traceback which would make fixing the issue pretty straight forward.

EDIT: interestingly enough, I finally got around to some upgrades (tokens ONLY) and mine fails with the same error. Debugging now.

It took me a while, but I finally tracked down my problem. I had a file that was not readable by the Home Assistant user in /usr/local/lib/python3.7/dist-packages/ so I had to chmod -R a+rX /usr/local/lib/python3.7/dist-packages/* .

To find this I put the following in my configuration.yaml:

logger:
  logs:
    homeassistant.components.shell_command: debug

Then the full traceback gets logged. If you still need help, post the full traceback.

On first run from the command line it gave me the following error:

Error unable to import the module 'networkx', please pip install it from WITHIN your virtual environment.

After Installing “networkx”, I get the following:

pi@hassbian:~ $ /srv/homeassistant/bin/python3.7 /home/homeassistant/.homeassistant/python_scripts/z_wave_graph.py
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/python_scripts/z_wave_graph.py", line 325, in <module>
    raise ValueError("Unable to automatically find configuration.yaml, you have to specify it with -c/--config")
ValueError: Unable to automatically find configuration.yaml, you have to specify it with -c/--config

I have no idea what needs to be done here.

The script walks through a list of directory paths where configuration.yaml often resides, but it looks like the script is not finding yours. You can edit the shell_commands/z-wave-graph.yaml file and add --config=/full/path/to/configuration.yaml . If you let me know what that path is I might add it to the default search list.

It’s in the default location.

/home/homeassistant/.homeassistant/

Where do I add --config=/home/homeassistant/.homeassistant/

In the shell_commands/z-wave-graph.yaml file. It probably has z_wave_graph: ~/bin/python3 ~/bin/z-wave-graph.py right now.

Oddly enough, that path is already in the default search list, so I don’t know why the script cannot find your configuration.yaml file.

@OmenWild,

Is this still a factor?

Default to no SSL for the API connection. You will need to add --ssl to your invocation if your HA uses SSL directly (i.e. not through a proxy).

If so, I don’t understand how to add --ssl to my invocation

Thanks

--ssl is deprecated and has been removed for a year and a half. Try upgrading to the newest version and trying again.

NEW RELEASE! I know, I can’t believe it either. I just pushed a new release that has a breaking change (requires a long lived token). Feel free to give it a spin, but make sure to read the next paragraph.

On a side note, I am pretty much deprecating this project. With the newest release, Home Assistant Community Z-Wave graph (without the python) has pretty much nailed it. Doing it without the Python makes integration significantly easier and is the route I should have taken from the beginning, but my JavaScript is weak and my Python is stronger.

I wish they had a proper GitHub release, but this gist seems to have the magic: https://gist.github.com/AdamNaj/cbf4d792a22f443fe9d354e4dca4de00

Thank you everyone for the support and interest, it has been an interesting ride.

3 Likes