I’ve been searching for an easy-to-get-started home automation platform that can be extended and customized as my needs grow. After struggling with OpenHAB, Domoticz and Freedomotic, I’ve found Home Assistant to be a much better fit for me. My main requirements are that the system should be open-source, have good tutorials & documentation, work well on a Raspberry Pi and be extensible for my likely future needs. I will spend this and a few upcoming posts with my Home Assistant experiments.
About Home Assistant
Home Assistant is an open-source Python 3-based home automation platform. It can be used for integrating with devices and systems using several different protocols like z-wave, mqtt, rest/http, command line tools etc. The configuration is done in yaml-files and automation can be done by specifying triggers, conditions and actions. There are lots of available components from the Home Automation community:
and it is possible to write your own custom components in Python.
Why Home Assistant?
I have some actuators and sensors at home that I control and monitor via services running on a Raspberry Pi. I want to use Home Assistant for consolidation of these services and data in one place. I also want to use Home Assistant for future extensions of my smart home using z-wave.
My first goal with HA is to integrate my existing sensors and actuators:
- Read my existing MQTT messages (from sensors)
- Trigger my 433 MHz outlets (via an existing REST service)
- Inline existing web apps (like my sensor graphs)
- Connect to my USB security cam
- Connect to my RPi Cam
My upcoming goal is to integrate new devices and services like:
- Z-wave devices like a Fibaro flood sensor
- OwnTracks (to track when a family member enters or exits a zone)
Installing Home Assistant on a Raspberry Pi
I use a Raspberry Pi 2 with Raspbian OS for my Home Assistant installation. I’ve opted for using a Python virtual environment with a dedicated Home Assistant user as described in this tutorial:
I had no problems with the installation. After HA is started, I can browse the system from:
The application’s GUI scales well on a mobile phone, so accessing the system from a desktop shortcut on an iPhone works fine.
The configuration file for Home Assistant on a Raspberry Pi (based on the tutorial mentioned above) is located in:
Open this file in a text editor like nano to modify the configuration.
By default, Home Assistant runs a discovery action for finding and integrating existing devices. It finds my Sonos and SqueezeBox systems. I don’t want to integrate HA with these right now, so I have turned off discovery in the configuration.yaml file by commenting out the section:
# Discover some devices automatically #discovery:
Configuring an MQTT broker to use
My first custom configuration is to make HA listen to my existing MQTT topics. To achieve this I first have to configure HA to use my MQTT broker (Home Assistant can have its own broker but I already have mosquitto running on a separate Raspberry Pi):
mqtt: broker: 192.168.1.16 port: 1883 client_id: home-assistant-1 keepalive: 60
If you have other settings needed for the broker, you can define them according to:
Configuring MQTT sensors
For an introduction to my MQTT setup, see these posts:
A self-hosted MQTT environment for Internet of Things – Part 1
A self-hosted MQTT environment for Internet of Things – Part 2
A self-hosted MQTT environment for Internet of Things – Part 3
HA’s mqtt sensor platform allows you to add subscriptions to sensor values/messages published on specific topics:
My first sensor setup looks like this:
|– platform: mqtt|
|name: 'Ground floor temp'|
|– platform: mqtt|
|name: 'Outdoor temp'|
|– platform: mqtt|
|name: 'Outdoor humidity'|
|– platform: mqtt|
|name: 'Top floor temp'|
With these sensor configurations in place, I get four sensor widgets in my Home Assistant GUI. To view historical data (1 day), a widget can be clicked to show a graph.
Integrating an existing web app with Home Assistant
I store all sensor data locally in a MongoDB database on a Raspberry Pi (gathered via an MQTT subscriber) and I have made a chart web app for viewing these data:
With Home Assistant’s panel_iframe configuration, it is possible to integrate a command that inlines this web app in the Home Assistant’s GUI:
With this configuration, there will be a new command in the menu that shows the web app in the main view:
I’ve just started getting to know Home Assistant and I will continue integrating more of my existing devices and services while learning more about this great platform. Next up is the integration of my service for remote controlled 433 MHz power outlets.
So far, this is my verdict for Home Assistant:
- Great instructions on installation and configuration! Some components could have more examples to be easier to get started with, though.
- It works great on a Raspberry Pi.
- Very good front-end! It is responsive and works well on mobile devices with small screens.
- The default-generated GUI is not very nice, but with a few tweaks with group and customize, you can get a ok user experience.
- The Logbook and History are very clearly laid out and lets you examine events and measurements in the past in an easy way.
- Lots of built-in and community-developed components.
- Does not force you into one “hub”-system. Home Assistant lets you integrate with your existing systems and services.
- You can build your own components in Python.
- With Home Assistant’s API it is possible to make your own front-end.
- It is self-hosted – you manage your own data. Love that.