DEV Community


Posted on

OpenHAB Home Automation

This is part 1 in a series of posts documenting what worked and what did not while building a privacy and security focused smart home

IoT and the smart home realm of electronics is largely a joke in the security industry. Smart locks and garage door openers provide little to no physical security against a hacker or someone with one of their tools [1] [2] [3]. Smart bulbs and other "innocuous" IoT devices can be used for infection and propagation of malware, and en masse can pose a risk as botnets [4]. Cameras spy on citizens and provide intel to foreign (or sometimes domestic) governments[5]. The point is, IoT devices are either wilfully or negligently full of security flaws that punch holes in your network and let attackers in or leak your personal data out.

...So why on Earth am I building myself a smart home? Because I want this:

"Hey Mycroft, turn on my kitchen lights."
"Right away."
Four light fixtures turn on at once

How freaking cool? We're living in the future, folks.

But how do I do this without compromising my privacy, or my network security? I've done a lot of research and I think I've found a decent compromise. Leaning heavily on open source software, I'm building a home automation network with OpenHAB, Z-wave, and Mycroft. Let me explain why this is a good solution.

Z-wave is a mesh network protocol that creates a "LAN" of IoT devices that are, themselves, never connected to the internet. These mesh IoT devices connect to a Z-wave "hub" that can be connected to the internet, if you want it to (e.g. if you want to control your smart home from oot and aboot). The hub sends commands to the devices, updates the devices, and overall coordinates the smart home show. There are plenty of Z-wave hubs already out there (cough SmartThings cough), but I wanted something less opaque that would be amenable to the addition of some non-z-wave devices, such as the Wyze cam. Something more... open source.

OpenHAB is a powerful smart home automation suite that frankly has impressed the socks off of me. This thing was clearly architected by people who knew what they were doing from a design standpoint, because their concepts (bindings, things, channels, items) generalize so well that once you understand the OpenHAB ecosystem, it's a joy to add and control a new device. It just works. I love open source success stories. OpenHAB has a binding for Z-wave that allows it to act as a hub as long as there's a Z-wave serial device present on the system. It also has bindings for all sorts of other things you might want to integrate with your smart home solution, including for example Spotify. The beauty of a single-stop solution like OpenHAB is that you can gather all your state information in one place, and use it to create complex interactions between your home devices.

While OpenHAB even provides a means for creating custom UIs for controlling your devices, sometimes talking to your house is just more natural (or more awesome). But voice assistants are all cloud-based services because the hard work of lexing human speech and deriving meaning is the work of an AI, and sadly, they seem to require more horsepower than a raspberry pi. Even more sad, though, is that these cloud-based services snarf up your data and sell it to advertisers. There's no guarantee that they aren't always listening. an indeed there's some evidence that they are, and that our personal moments are being recorded and transcribed by humans in order to improve the AI's speech recognition (I read this article, but I can't find it now - guess you will have to take my word for it).

Mycroft is a cloud-based AI service, but it is open source, to the degree that it is possible. It requires an online account in order to link your Mycroft instance to its cloud service, and their privacy policy does contain language that enables them to sell your data to advertisers. They swear that they don't - being privacy conscious and respectful of their users is their biggest selling point and something that they tout on their website - but they absolutely could. It's up to the end user if they believe them. I decided they were the lesser of all the evils, and I'm excited about the potential to write my own skills for Mycroft, as its skills engine is python-based. It also integrates with OpenHAB, giving it access to all of the items exposed through OpenHAB's configuration. In theory, one can create Mycroft commands to control literally any of the smart home things.

Here's the shopping list so far:

$100 Raspberry Pi 4 Kit from CanaKit
$39 Zooz Z-wave Plus 2 USB Stick
$30 Zooz Z-wave Toggle Smart Switch
$9 PS3 Eye Microphone
$35 Raspberry Pi 3 B+
$25 x3 Raspberry Pi 3 A+
$25 Wyze Cam V2

That all runs a bit over $300. Expensive, sure, but what's life without a hobby. What all this buys me so far are three sets of networked and synchronized speakers (hooked up to Pi 3 A+'s running Max2Play), a voice assistant (the PS3 eye attached to the Pi 3 B+ running, using their picroft image), a solitary smart light switch, a camera to watch my front door, and a home automation hub (the Pi 4 with the Zooz Z-wave USB stick). So... I can turn on a single light, play some music, detect when someone's coming into the house, and ask the internet some questions. It's not bad but it's not exactly like the house is alive. All I've bought so far is proof of concept toys.

I'll continue this series with posts about each individual node in the smart home network, including any relevant configuration, wiring, networking, travails, and triumphs. For now, I wait for the pieces to come in.

Top comments (2)

n_develop profile image
Lars Richter

Hi @dizzyspi ,

thanks for the great post. I will totally check out Mycroft. That looks super interesting.
Has your home automation tech changed in the last 12 months or is basically still the same tech?

I'm still struggling to decide if I want to try HomeAssistant or OpenHAB first. But your arguments for OpenHAB sound great. Maybe I will go and play with OpenHAB first.

Btw, have you seen Ben's new Forem-based home-tech community called Hometechnica? You should check it out. I think it's a great idea to have everything home automation and home-related tech stuff in a dedicated community.

dizzyspi profile image

Hey Lars,

I had not seen that community! I'll certainly take a pop over there, thanks.

The tech I'm using is mostly the same as what I outlined here. I didn't end up integrating the cams with openHAB yet - I tried, but getting the MQTT integration working with them was... fiddly. For now, I've just got the cameras saving their feeds to a NAS with a cronjob. I'd eventually like openHAB to be able to send me photos from the cameras on different trigger conditions. Maybe I'll work on that today :)

The zooz switches have worked out great, for the money I would definitely recommend them. I ended up with a mix of different revisions of the zen 23 due to buying a second bulk batch of them months after the first, and the more recent version are better for operating in groups. In fact, had I ended up with several of the older zen 23's, I'm not actually sure how I would have turned them into a group to turn on and off together, at least with OpenHAB. I've bought a zooz dimmer switch for another room in the house, though haven't installed it yet. I expect that'll work about the same as the toggles.

I tried out a smartbulb (an aeotech one, very colorful, tons of customizations) and the openHAB integration was lackluster. I believe I probably could get the bulb to do whatever I wanted, the features are accessible, but only really through the scripting interface, and only with a lot of trial and error. Trying to use the widget that auto-populated on the dashboard for the bulb would just turn off the light whenever I changed a setting. Increase the brightness? Nope. Bulb dark. Change color? Only if that color is "black." Not exactly a flawless integration.

Mycroft was a neat toy that I played with for a while, but I decided that actual functional use of it would have to wait until I had a better mic setup. The PS3 eye that they recommend is good for getting a feel for the platform and playing around with things, but in practice I think I want something like an omnidirectional mic pi hat to help boost the sensitivity. I found that even from a few feet away, I'd be yelling at the thing to get it to do stuff. I'm a quiet person though, what I consider yelling some people may consider talking ;) On the whole though I had a positive impression of Mycroft, very customizable, and I was able to get the OpenHAB integration working no problem.

My underbaked thoughts on OpenHAB vs HomeAssistant - they both look good. HomeAssistant is probably easier to learn, and (hopefully) has a better UI. One of the less great things about OpenHAB is that it has a bunch of UIs to choose from, all slightly different and with different use cases, and none of them really intuitive. You'll end up reading the tutorial in full for OpenHAB in order to really get going with it, which will take some time. It's imperative to understand the different types of objects the system uses (thing, binding, etc.). That said, I'm quite happy with it - at the end of the day, once a device is integrated and automated the way I want, I don't look at the UI again. So the big selling points for me with OpenHAB are the sheer amount of devices it supports and the heavy customization. I have not yet run into a case where I was like, "I wonder if OpenHAB can do this," googled it, and didn't see a result matching what I wanted.

If you do play around with HomeAssistant, let me know what you think! I'd be curious to hear your thoughts, especially if you try them both and compare.