Well that was good timing – events this week have made this review suddenly topical. The recent issues with Amazon Web Services have highlighted the danger of relying on cloud services, particularly for IoT home automation. A problem in a data centre in Virginia can leave you unable to turn your lights on or control your thermostat… not good. Not good at all.
Services including Nest and IFTTT were amongst those affected, and it highlights the importance of making sure your smart devices have some kind of manual override – at the very least a smart thermostat should fall back to a pre-defined schedule and ideally you should be able to manage your smart devices from your local network. Let’s face it, it’s just as likely that you’ll have an internet outage due to problems with your ISP as it is that the cloud services go down.
So what if there was a way of controlling all of your smart home automations from your own computer – even a Raspberry Pi? Turns out there is…
Home Assistant and OpenHAB are the two main open source contenders. Today I’m looking at Home Assistant (HA for short from now on), a Python based platform for controlling your smart home that seems to be capable of integrating with just about any smart device or platform you can think of.
Let’s start with installation. If you have a spare Raspberry Pi there’s a dedicated image that you can write to an SD card and you’ll have Home Assistant up and running within minutes of booting. Installing on a Linux distribution that already has Python 3 is also easy – simply pip install homeassistant, preferably in a Python VirtualEnv, and away you go. There are also instructions for Windows and MacOS.
It’s all pretty simple and well documented on the website, as is the initial configuration, so I won’t go through that here – this is a review and not a tutorial 🙂
I will just mention that I chose the slightly more complex route of installing on CentOS 7, which only comes with Python 2, simply because that’s what my server already runs. I’ve written up some notes on how it was done and hopefully they’ll be incorporated into the installation documentation.
By default the discovery component is enabled, and this can find things like media players and Philips Hue hubs automatically. HA talks directly to the Hue hub on the local network without going out to the cloud and back, making Hue a good platform for remaining independent of the internet.
Once the discovery is complete and you’ve done some basic configuration you can control your devices through the web front end.
This is one of the strengths of Home Assistant. Good user interfaces used to be a very rare thing in the open source world but thankfully this is improving. The HA web frontend uses Material Design and is fully responsive, working just as well on a phone as on a PC. This sort of thing is often under appreciated by your average geek, who’d probably be quite happy bashing out a command line to turn the lights on, but it’s essential to making software accessible for the general user.
Unfortunately that’s where the general user friendliness ends.
Almost all of the configuration is done via files written in YAML, formerly Yet Another Markup Language and now apparently YAML Ain’t Markup Language. YAML is not particularly complicated, but most end users would be happier with a point and click GUI interface.
Here’s how you’d set up Samsung SmartThings to turn a light on when a door opens after sunset:
In Home Assistant this would be done with a snippet of YAML configuration along the lines of:
- alias: "Light on when door opens" trigger: platform: state entity_id: sensor.front_door_contact to: "open" condition: condition: state entity_id: sun.sun state: "below_horizon" action: service: light.turn_on entity_id: light.hall
Once you get the hang of it, it’s very powerful but there is a much steeper learning curve than there is for the commercial alternatives. On the other hand, there’s a lot more it can do. If the YAML method isn’t flexible enough it’s even possible to use Python to write automation routines using AppDaemon.
To be fair, HA is on version 0.39 and every release brings improvements. Since I first installed it, only a few weeks ago, new features have been released to allow some configuration directly through the front end. There isn’t yet full GUI configuration but I imagine it’s just a matter of time until only the most complex configuration has to be done via configuration files.
One downside of the rapid release schedule is that the developers aren’t afraid of making changes that break existing configuration files and force you to rewrite bits of your config. It’s the price of being an early adopter, and I don’t disagree with the approach – it feels like the developers are iteratively working towards a better structure for the internals and aren’t afraid to throw away approaches that they feel are dead ends. Just be prepared for a certain amount of frustration and make sure you read the release notes before upgrading.
The documentation is pretty comprehensive, but even so you’ll need to be prepared for a lot of trial and error to get things working. It sits somewhere between end user documentation and a technical reference, and often presupposes a fair degree of technical knowledge. I found the examples invaluable – especially the examples of YAML configuration files that other users have made available.
I know from experience it’s really hard to write documentation for things you know inside out yourself – it’s almost impossible to put yourself in the place of someone coming to it fresh and think of the questions that they’d have.
Once you get beyond the basics, the possibilities are endless but be prepared to spend plenty of time scratching your head, reading the documentation, possibly reading the code, and simply experimenting.
One of the strengths of HA is its ability to interface with other controllers. I’ve already invested in SmartThings, and there is a bridge between the two. Setting it up requires familiarity with installing custom device types and smart apps in SmartThings, but since I’ve actually written a couple myself that wasn’t a problem. Getting the bridge set up was slightly challenging, but – again – largely because of my choice of OS.
Once it was configured it gave me two way communication between HA and SmartThings. I can now control my SmartThings managed lights from within HA automations and also automate actions in HA based on the state of my SmartThings sensors.
The next step is to go beyond reliance on another platform and use HA to interface directly with sensors and other devices. I bought a USB Z-Wave controller and a door sensor to get started, and set about getting it working in HA. It’s a fairly technical exercise unless you use an installation method that has it preconfigured, but if you’re reasonably confident with Linux it shouldn’t be that much trouble.
I think the fact that I’ve jumped into getting my own Z-Wave controller and devices shows that despite minor reservations, I think HA is a great way to manage a smart home. If you’re happy to spend the time and you’re technically capable it can free you up from reliance on external services and put control of your home back in your own hands.in Home Automation