As convenient as it is to have my home automation hub running on my PC, it's not very stable. My PC is sometimes off, or not connected to the network, so I'd like to have a dedicated PC just for the purpose of home automation. But I don't want an entire PC running…
Enter the Raspberry Pi! A tiny credit-card sized computer that can run Linux. I bought myself a Pi 4, so now it's time to move my entire home automation setup to this thing.
Install openHAB
Luckily, they keep a special linux image for running openHAB as it's own system on small computers like the Raspberry Pi. The guide is here.
The installation process is super easy. Just download the image, flash it to an SD card with Etcher, start the Pi and wait. It's that easy!
However… My network is pretty much entirely Wi-Fi based, running a cable upstairs would be too much effort. Luckily they provide a way of setting it up over Wi-Fi. After flashing the image onto the SD card, we can open the openhabian.conf
file and put our Wi-Fi details in there.
Ok, now all we have to do is put the SD card into the Pi, and start it up! Once it's done, it's now accessible via http://openhab on the local network.
Setting it all up again
I'm not going to include this process here, it's basically the exact same as in the previous blog posts. The only difference is how to find the COM port for the Z-Wave controller.
Wow, this one turned out to be difficult. Apparently there is an electronic bug inside my specific Z-Wave USB stick that, when plugged into the Pi 4, makes the Pi think it's a USB3 device and try to communicate via that protocol. Of course, the Z-Wave stick doesn't even have USB3 pins on it, so this goes nowhere. Luckily the solution is simple: just get a super cheap USB2 hub and plug the Z-Wave stick into that instead. It specifically needs to be a USB2 hub, since USB3 is broken with this device.
Once it's plugged in, we can run dmesg | grep tty
to discover all the COM devices, and see which one we need.
Since mine is appearing as ttyACM0
, the serial port I need to give to openHAB is /dev/ttyACM0
.
Access from anywhere
Now that my openHAB is running on a Pi (which has no screen connected), I'd like to be able to access it from anywhere. It's accessible via SSH from within my network, but I'd like access to it from anywhere!
For this purpose, I've decided to use ZeroTier One, which is a great free VPN which links computers together over the internet. You can have up to 100 devices on your virtual network for free.
To install it on Linux, we can simply run this command:
Once it's been installed on both my computer and the Pi, the IP address can be found on my.zerotier.com. This IP address is fixed, so that means I can now SSH into my Pi from anywhere!
Done
And that's it. My entire home automation hub has been moved to a Raspberry Pi, which is always running and accessible from anywhere in the world. Nice!