Using a Vera Edge as a network-attached zwave device (skipping the vera software)

I have a few Vera’s lying around and I wanted to migrate one to home assistant, and instead of going the tedious way of adding again all my zwave devices to a zwave stick, I decided to try and make a zwave-to-tcp device out of the controller, and connect home assistant to it.

Data path:

zwave chip - ser2net - tcp port - ... ethernet ... - socat - serial device - home assistant

And guess what? It works great!

And only uses 18 mb of ram out of 128 on my edge and barely uses any cpu - and i probably can go lower than that.

You need to be able to ssh to the controller (the password is on the bottom of the unit). You need a home assistant already installed somewhere where you have root / can run socat.


I used a Vera EDGE with the latest firmware version:

"firmware_version": "1.7.2931"
"zwave_version" : "4.5"

You can check this info by going to http://<vera_ip>/cgi-bin/cmh/sysinfo.sh

This should work on any Vera that has ser2net (afaik all of them have it), but if you have one that does not have it do

opkg update
opkg install ser2net

On Vera: list all proceses
ps aux


On Vera: kill all unnecesarry processes
Except the processes with [name] in command collumn above, kill everything. I only left

root         1  0.0  0.5   1360   652 ?        S    Sep28   0:13 /sbin/procd
root       443  0.0  0.2    888   280 ?        S    Sep28   0:34 /sbin/ubusd
root       444  0.0  0.1    768   212 ttyS1    Ss+  Sep28   0:00 /sbin/askfirst ttyS1 /bin/ash --login
root      1877  0.0  0.5   1560   656 ?        S    Sep28   0:15 /sbin/logd -S 256
root      2234  0.0  0.5   1532   752 ?        S    Sep28   1:31 /sbin/netifd
nobody    4334  0.0  0.4    964   508 ?        S    23:12   0:00 /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf -k
root      4637  0.0  0.3   1712   444 ?        S    23:13   0:00 /usr/sbin/ntpd -n -p 0.openwrt.pool.ntp.org 1.openwrt.pool.ntp.o
root     10059  0.0  0.3   1148   416 ?        S    20:13   0:00 /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22
root     30759  0.0  0.4   1212   536 ?        Rs   23:05   0:02 /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22
root     30935  0.0  0.4   1732   548 pts/0    Ss   23:05   0:00 -ash

everything else kill with

kill -9 id1 id2 id3 etc..

Id’s are the process id’s (2nd column on ps aux command), example usage:

kill -9 345 4689 4964 3458


On Vera: enable ser2net to allow network access to the zwave chip

ser2net -C "7676:raw:0:/dev/ttyS):115200 8DATABITS NONE 1STOPBIT"

this allows us to connect to the serial of the zwave chip on the vera and use it as a network-connected USB stick.


On Home Assistant - first ssh connection

install socat with “apt-get install socat” or whatever package manager your distribution has

start socat as root with (replace 1.2.3.4 with vera ip)

socat PTY,link=/dev/zwavevera,group=root,mode=777 TCP:1.2.3.4:7676

This will create a /dev/zwavevera serial connection. Leave the ssh connection open with socat running and start another ssh for next step.


On Home Assistant - second ssh connection

Stop home assistant in your preferred way (depending on installation method)

Edit configuration.yaml and add

zwave:
  usb_path: /dev/zwavevera

Start home assistant, wait for it to install openzwave (might take a while if zwave was not installed previously). Then, after the web interface is loaded, wait until all zwave devices are detected and identified - for me with 30-something devices it took about 5 minutes. If you have any battery-operated devices then wake them up.

After you’re content with the detection period go to hass configuration and restart it, to make it write the zwavecfg file.


If people are interested in this I can create two scripts to automate setting up vera (one for disabling vera default processes and another one for enabling them back).

Hope this at least gives you some ideas…

3 Likes

Very interesting. What would be the main benefits to this over using the Vera component?

Direct access to zwave chip… basically faster zwave, skipping another piece of software in the middle.

Can I use this without killing any processes? Create the direct connection to the zwave chip and still have the full functionality of vera?

Short answer: no.
Zwave chip only has one serial connection as far as I know. It would require additional custom software.

Hmm okay, if I put it this way then, would it be possible to just kill the process in vera that uses the zwave chip? So everything stays functional on the vera except for zwave devices

That’s the Vera engine that connects to zwave. If you kill it everything stops working.

cool. two questions.

  1. Is my veraplus filtering / transforming the json payload from my devices and if so, would this allow the full payload to come to homeassistant? I ask because my schlage lock is connected to veraplus and I don’t think I can get the user code from the message that comes to homeassistant.

  2. if I try this and decide that it is not for me, how to I get my veraplus back to the factory default state?

Oh, a third question.
3) Can I then use my viraplus as the z-wave connection I need to update the firmware on my aeotec multi sensors?

  1. By doing the above, you’re not using vera software anymore, just the hardware. There is no json, it’s like installing home assistant on Vera and replacing the whole software stack. Anything home assistant can’t handle won’t work.

  2. The instructions above will work for a test-run, they are not meant to be a permanent change. Rebooting the Vera will turn it back to its original state.
    I’m working on a couple of scripts to allow a semi-permanent switch at any time. I plan to install the scripts on 3 Veras to cover a larger installation (large as in large area; there are too few devices to have reliable mesh).

  3. If you have a tool that works with zwave serial connection, it will work with this. All this does is present to any software a remote network-connected zwave chip as a local one (you can imagine it as a fake usb zwave chip)

Have you been able to work on those scripts? I’ve done an initial test run and it seems to work well

@quasar66
I am having trouble with this, killing the processes in Vera doesnt seem to do anything. I use

kill -9 2

for example but when i ps aux the PID 2 is still there, am i missing something?

2 does not look like a correct process id, it should be something higher (at least 100, if not more, I get 400+ for process id’s.

The scripts are 90% done, maybe I should publish them as they are right now (due to some time constraints I haven’t been able to finish them).

I see, it shows up when i ps aux tho so i tried to kill it.

I’d be glad if you could post them, then i can help you test it as i cant quite get it to work myself

Created a docker image for the home assistant part:

Got time to play with this (again) so here is a more “detailed” instruction list…

connect via ssh with root / password (find it on the bottom of the unit)

run:
opkg update

run:
opkg install nano ser2net

now let’s disable auto starting stuff…

run:
crontab -e
then:

pres “i” to enter editor mode then use arrow keys to put the promopt before 1st and third line and put a # in front, then press escape (without commas)

i, #, down, down, #, esc

it should look like

#*/1 * * * * /usr/bin/Rotate_Logs.sh #Rotate_Logs

#20 02 * * * //usr/bin/mios-service-sync_ergy.sh #Sync_Ergy

^- notice the # at the start of the line

to save modifications, press (without commas)

:,w,q,[enter]

Now lets edit a bash file so it does not do anything…

cp /usr/bin/Start_LuaUPnP.sh /usr/bin/Start_LuaUPnP.sh
nano /usr/bin/Start_LuaUPnP.sh

now write the text so it looks like this at the start:

#!/bin/sh

sleep 120
exit

now press [control+o] then [control+w] to save

do the same with:
/usr/bin/Start_serproxy.sh

now let’s create a new file with

nano ~/check.sh

with contents:

COUNT=$( netstat -a | grep -i listen | grep -i "0.0.0.0:7676" | wc -l )
echo "Found $COUNT"
if [ "$COUNT" == "0" ] ; then
  echo "Killing..."
  kill -9 $( pgrep -f "Start_LuaUPnP" )
  kill -9 $( pgrep -f "Start_serproxy" )
  kill -9 $( pgrep -f "serproxy" )
  kill -9 $( pgrep -f "lighttpd -f" )
  kill -9 $( pgrep -f "LuaUPnP" )
  kill -9 $( pgrep -f "/etc/cmh-ra/keys/cmh-ra-key.priv" )
  kill -9 $( pgrep -f "cmh-ra-daemon.sh" )
  kill -9 $( pgrep -f "cmh_PnP" )
  echo "Starting..."
  ser2net -C "7676:raw:0:/dev/ttyS0:115200 8DATABITS NONE 1STOPBIT"
else
  echo "Already started"
fi

Press controll+o and controll+w to save it.
Now run
chmod +x check.sh

We can run it with
./check.sh

It will say somehting like
netstat: /proc/net/tcp6: No such file or directory
netstat: /proc/net/udp6: No such file or directory
netstat: /proc/net/raw6: No such file or directory
Found 0
Killing…
ash: you need to specify whom to kill
ash: you need to specify whom to kill
ash: you need to specify whom to kill
ash: you need to specify whom to kill
ash: you need to specify whom to kill
Starting…

If we run it again…
./check.sh

netstat: /proc/net/tcp6: No such file or directory
netstat: /proc/net/udp6: No such file or directory
netstat: /proc/net/raw6: No such file or directory
Found 0
Killing...
ash: you need to specify whom to kill
ash: you need to specify whom to kill
ash: you need to specify whom to kill
ash: you need to specify whom to kill
ash: you need to specify whom to kill
Starting...
[email protected]_45103975:~#
[email protected]_45103975:~#
[email protected]_45103975:~#
[email protected]_45103975:~# ./check.sh
netstat: /proc/net/tcp6: No such file or directory
netstat: /proc/net/udp6: No such file or directory
netstat: /proc/net/raw6: No such file or directory
Found 1
Already started

All ok!

Now let’s edit crontab to make this run every minute so our port is always exposed if vera restarts…

nano /etc/crontabs/root

and add the line

*/1 * * * * /root/check.sh

^- this means every minute, change to something else if you want…

then control+o then control+w

the reboot with

reboot

now after reboot reconnect with ssh and only run

netstat -a | grep -i listen | grep "7676"

and after 1-2 minutes you should see a line with

tcp 0 0 0.0.0.0:7676 0.0.0.0:* LISTEN

this means all is working fine!

so even if it reboots, vera will restart the tcp server for the zwave chip

Enjoy!

Wow man thanks a bunch! I’ll try this out in the coming weeks, currently abroad.

Just tried it. Thank you for sharing the scripts, it works, and it is much more interesting than configuring ZWave with Vera UI. Once you bypass Vera you have much more control over ZWave :slight_smile:

I had to add “unlink-close=0” to the socat options otherwise for me it removed the /dev/zwavevera device when the TCP connection was timing out (or closed by Vera).

If you have an idea on how to encrypt this traffic - please please share it. I wouldn’t like any device on my wifi to now be capable of sniffing ZWave traffic.

Block port 7676 with firewall from lan on vera.

From hass container / vm / server do a ssh with reverse port forward - forward remote (vera) 127.0.0.1:7676 to local (hass environment) 127.0.0.1

Modify socat to use 127.0.0.1

Encrypted zwave communications!

On second thought: start ser2net with 127.0.0.1,7676:raw: … instead of 7676:raw … no firwall changes needed!

How does home-assistant cope with /dev/zwavevera not working but still existing then working again when connection is recreated?

I went the other way - once the connection/file is missing, restart everything - see the files in this folder:

Not good. I’m not giving up yet and still experimenting. For me Vera drops the connection without any apparent reason like every hour or so, and in most of these cases all ZWave devices in HA become unresponsive. Restarting everything will work but doing it every hour does not seem acceptable.

BTW forwarding it to localhost might help. Will give it a try, too. Thank you!