In my Last Post I talked about doing a physical installation of some Z-Wave thermostats. In this post, I’m going to talk about what I had to go through to get an Aeotec Z-Stick Gen5 working with Home Assistant running on Lubuntu. I was actually surprised how easy everything was; I had no idea that Home Assistant’s Z-Wave integration was so well done.

Troubles with Hyper-V
NOTE: If you are running your Home Assistant on physical hardware such as am RPi, then you can skip this part. The main people that might be interested in this are the handful of us that are running it in Hyper-V.

The hardest part for me was because I am running the Lubuntu/Home Assistant install on a virtual machine running on a Windows 10 computer running Hyper-V. Hyper-V, unfortunately doesn’t support USB pass-through like VirtualBox or VMWare Workstation. What this meant for me is that I wouldn’t be able to ‘plug’ the USB stick into the Home Assistant computer. Lucky for me, there was a ‘free’ workaround in a software called VirtualHere which lets you share your USB devices from one computer to another over the network. So I was able to plug it into my Windows host, and access it from the Lubuntu guest. This wasn’t ideal, but it worked. I do plan on moving this to a dedicated computer eventually, but this will have to do for now.

The first thing I did was install the server on Windows 10. I installed it by running it with the -b  flag: vhusbdwin64.exe -b . That’s really all that you need to do on the server. You can check their website for more documentation if you want to secure communications or restrict some devices.

Next, I ran the client on Lubuntu using sudo. The main requirement is that you need a fairly recent kernel that has the USBIP drivers compile in. Most recent distros have this. After running the client, the USB stick showed up, and all I had to do was right-click and click ‘Auto-Use this device’. That means the device will be connected every-time you start the VirtualHere client. You should now see it if you run an ls /dev/ . You may want to run that command before using the device to see which device it showed up as. In my case it was /dev/ttyACM0.

Now, the main problem at this point is that the client can’t be installed as a service unless you have the paid version. And it also needs to run as sudo, which makes it difficult to have it autostart. So I was only able to find a crappy workaround to have it startup automatically when the computer is rebooted. I set the following command to run at startup: echo password | sudo -S vhuit32 . This works, but it’s not a very good idea to have that password in plain text, which is why this is a crappy workaround. I’m not at all a Linux expert, so there might be better ways to do this. If you know of any, please let me know.

Setting Up Z-wave in Home Assistant
After I was able to get the USB stick communicated with my system, the rest of it was very easy. The first thing I had to do, was install some prerequisites using the following command: sudo apt-get install libudev-dev libpython3.6-dev python3.6-dev . On the RPi, you have to enable the serial interface in raspi-config. 

Next, plug in the USB stick and run ls /dev . You should see the device there. Mine was named /dev/ttyACM0. You can try using the command  ls -ltr /dev/tty*|tail -n 1 which should also show you the time the device was added so you can confirm it is indeed the Z-wave stick. Worst case, just run the ls /dev before and after plugging it in and see what device shows up.

Once you know the device name, just add the following to your Home Assistant config, replacing the device name with yours:

The network_key is optional, but I would recommend it to help increase security. DON’T use this network key. Make up your own. Just be sure to save it some where safe. If you have to reconfigure your Home Assistant, and you don’t have the key, you will need to factory reset all your Z-wave devices. Restart Home Assistant.

I read on Home Assistant’s site that after you start Home Assistant, it will take up to half an hour for the Z-Wave binaries to compile. I probably tried to pair my thermostats about 5 minutes after setting this up, and I didn’t have any issues. But you may want to wait just in case.

Pairing Your Devices
Pairing the devices was very easy. In Home Assistant, go to Configuration -> Z-Wave -> Add Secure Node. Now go to your device, and follow the instructions for that device to pair it. I only have my thermostats hooked up, and I just had to go into the menu, and tap on the little radio icon. A few seconds later, it showed up in Home Assistant, which promptly identified it as a thermostat, and had all the controls for it on the home screen. I was amazed at how well that worked. I thought I would have to do a ton of configuration just to get started, but I had full control of the thermostats right off the bat. It is a little annoying that it shows up as 2 devices, one for heat and one for cooling, but I think there might be ways to consolidate that. If I do it, I’ll make another post.

That’s all there is to it. If you are thinking about Z-Wave with Home Assistant, I would highly recommend it. It’s a very mature product, and as most Home Assistant users know, it will probably just keep getting better. And Z-Wave devices are widely available as well, from locks to sensors to switches.

Leave a Reply

Your email address will not be published. Required fields are marked *