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

That’s a good sign. I’m not sure why that isn’t getting pulled into the iframe and graphed though. The physics -> hierarchicalRepulsion part shows the JavaScript is loading, but possibly not the JSON with the nodes and edges.

At this point you may need to pull up the browser inspector and look at the network traffic for the loading of z-wave-graph.json?ts=LONG_INT. Check the console output for errors from vis.js too.

I may be wrong,but everything looks good to me:

z-wave-graph.json?ts Headers
image

z-wave-graph.json?ts Preview

z-wave-graph.json?ts Response
image

vis.js Console:

Well there’s the answer. You have two nodes with the exact same name. I just pushed a version that can work around that. Update and let me know how it goes.

1 Like

Sure thing, thank you.

All the results are the same with new script.

Are you sure you re-ran it after you downloaded it? The json needs to get regenerated. If you did, can you PM me your entire json file?

Yes, I ran it.

From the automation, it creates the following error, but no json file.

From shell, no errors, it creates the json file, and graph page is blank.

PM on the way.

Thanks.

For the thread, there was an error graphing two nodes that had the exact same name. I pushed a code fix, but we’re still unable to get the shell_command to run under Hassbian. If any Hassbian users have solved it I would appreciate a step-by-step so I can post it on the GitHub page.

Did a little more troubleshooting.

If I run the Automation, nothing happens, and no errors in log.

If I run the script from the command line in the venv, it creates or updates the graph.

If I run the script from Dev Tools / Services / python_script.z_wave_graph, I get the following error in the log:

2018-02-08 14:01:24 ERROR (Thread-8) [homeassistant.components.python_script] Error loading script z_wave_graph.py: Line 37: “init” is an invalid variable name because it starts with “", Line 62: “getattr” is an invalid variable name because it starts with "”, Line 74: “str” is an invalid variable name because it starts with “", Line 104: “iter” is an invalid variable name because it starts with "”, Line 105: Yield statements are not allowed., Line 109: “init” is an invalid variable name because it starts with “", Line 147: “iter” is an invalid variable name because it starts with "”, Line 156: Yield statements are not allowed., Line 160: “init” is an invalid variable name because it starts with “", Line 193: “get_entities" is an invalid attribute name because it starts with "”., Line 198: “build_dot" is an invalid attribute name because it starts with "”., Line 218: “get_entities" is an invalid variable name because it starts with "”, Line 225: “build_dot" is an invalid variable name because it starts with "”, Line 258: “from" is an invalid variable name because it starts with "”, Line 259: “to" is an invalid variable name because it starts with "”, Line 260: “from" is an invalid variable name because it starts with "”, Line 260: “to" is an invalid variable name because it starts with "”, Line 272: “name” is an invalid variable name because it starts with "

Correction.

If I delete the .json that was created running the script from shell and run the automation I get the same error as before.

Love the idea of this, great job,

I am using the standard docker image and so far I am unable to get this to work:

  1. Regarding the pre-req pip3 -install - do I have a venv in the docker or do I just run the command?
  2. I created a local/bin/ under my config (docker mapped volume) and put the .py script there
  3. I merged the config into my split config under /config/includes
  4. I merged the automation into my flat automations.yaml
  5. I put the .html into config/www

I restart, and can see the iframe. If I click on it I get an empty frame and an error in the log:

2018-02-11 10:24:58 ERROR (MainThread) [frontend.js.latest.201801300] :0:0 Script error.

followed by:

2018-02-11 10:25:00 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: ~/bin/python3 /config/local/bin/z-wave-graph.py, return code: 127

If I try to run the script from within the docker: python3 /config/local/bin/z-wave-graph.py --debug I can see the .json output

Suggestions?

I suspect the problem is the ~/bin/python3. From the command line run which python3 and use that path instead.

1 Like

That fixed it - Thanks!

I’m struggling to get this working correctly in a venv deployment. I have setup the various yaml files and everything is working except the automation calling the shell_command which looks like this in my log:

Error running command: `/usr/local/bin/python3 /home/homeassistant/.homeassistant/bin/z-wave-graph.py`, return code: 1
11:07 AM /srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/shell_command.py (ERROR)

Running the script from my venv works as expected, it reads the log and updates the JSON and the ipanel is updated and everything functions correctly.

administrator@hass:~$ sudo su -s /bin/bash homeassistant
homeassistant@hass:/home/administrator$ source /srv/homeassistant/bin/activate
(homeassistant) homeassistant@hass:/home/administrator$ cat /home/homeassistant/.homeassistant/shell_commands/z-wave-graph.yaml
z_wave_graph: python3 /home/homeassistant/.homeassistant/bin/z-wave-graph.py
(homeassistant) homeassistant@hass:/home/administrator$ python3 /home/homeassistant/.homeassistant/bin/z-wave-graph.py
(homeassistant) homeassistant@hass:/home/administrator$

Your single quotes look wrong to me they should be ’ not `, unless it’s the error formatting :stuck_out_tongue:

I’m not sure I follow. The only quotes I’m seeing are from the copy/paste output of the log which came from the home assistant web interface log function. The z-wave-graph.yaml has no quotes in the file.

What’s the output of which python3 from within your venv?

(homeassistant) homeassistant@hass:~$ which python3
/srv/homeassistant/bin/python3
(homeassistant) homeassistant@hass:~$ ls -la /srv/homeassistant/bin/python3
lrwxrwxrwx 1 homeassistant homeassistant 22 Nov  7 17:48 /srv/homeassistant/bin/python3 -> /usr/local/bin/python3
(homeassistant) homeassistant@hass:~$ ls -la /home/homeassistant/.homeassistant/bin/z-wave-graph.py
-rwxrwxr-x 1 homeassistant homeassistant 9945 Feb 11 10:49 /home/homeassistant/.homeassistant/bin/z-wave-graph.py
(homeassistant) homeassistant@hass:~$ date
Tue Feb 13 19:42:51 EST 2018
(homeassistant) homeassistant@hass:~$ /srv/homeassistant/bin/python3 /home/homeassistant/.homeassistant/bin/z-wave-graph.py
(homeassistant) homeassistant@hass:~$ ls -la /home/homeassistant/.homeassistant/www/z-wave*
-rw-rw-r-- 1 homeassistant homeassistant  3155 Feb 11 10:50 /home/homeassistant/.homeassistant/www/z-wave-graph.html
-rw-rw-r-- 1 homeassistant homeassistant 14185 Feb 13 19:42 /home/homeassistant/.homeassistant/www/z-wave-graph.json
(homeassistant) homeassistant@hass:~$

I thought this was going to be easy, but nope. :slight_smile:

I wonder if you change the action in the shell_command to use the /srv/homeassistant/bin/python3 path if it would work? Maybe the venv isn’t getting activated by the /usr/local/bin/python3 path?