Software apps and online services
This home automation project write-up is part 1 of 4 parts. We chose to break things up into chunks that are more easily digestible and to make it easier for people to focus on the aspects of our project that are applicable to them without having to wade through a bunch of stuff that has no value to them. Here's what you have to look forward to:
Part 1 - Overview. We lay out the main components of our home automation system and install the core software component, OpenHABWe install a MySQL database server and tools to manage it. We then integrate it with OpenHAB for the purposes of storing our home automation data indefinitely. We install a lightweight messaging system (MQTT broker), Mosquitto, and integrate it with OpenHAB to exchange information with custom, home-grown IoT sensors and controls. We install and configure an Apache web server and briefly discuss integrating custom web pages with OpenHAB. This will provide a platform for building custom user interfaces for our home automation system.Introduction
A perfect storm:
We needed to incorporate our newly minted indoor weather nodes into a more user-friendly platform.
So we went looking for a home automation platform that would run on a Raspberry Pi, could integrate custom IoT devices as well as common off-the-shelf devices, and could be accessed and operated from a variety of clients (web browser, smart phone app, etc.)
We didn't have to search long before discovering that OpenHAB checked all of our boxes and would be the heart and soul of our new home automation system.Overview
Our home automation system, lovingly called Home Automation Laboratory, or "HAL" for short, is composed of several open-source components. This write-up will not cover the details of installing and configuring each of these components. That information has been documented many times already and far better than anything we could add here. We will be providing references to the documentation that we utilized. We will also be providing details on how we integrated each of these components with each other and with our home automation devices.
This 4-part project write-up will cover the install and integration of the main software components that comprise our home automation system. Future project write-ups will document how we integrated various home automation devices and custom UI's with HAL as well as adding voice control. Here's a sneak-peek at what's to come:
The groundbreaking, ubiquitous all-in-one single board computer. It doesn't have earth-shattering power, but it is very capable and an ideal platform for our HA system. We're using 4 Raspberry Pi 3's in our home automation system.
What we like about the Pi:
Inexpensive ($30 at our local Microcenter)
As we stated above, OpenHAB was practically a no-brainer to be the brains of HAL. Google "home automation raspberry pi" and OpenHAB is front and center in the results.
OpenHAB is essentially a platform, or framework into which you can add "bindings" and/or services that allow OpenHAB to interact with a wide-variety of home automation devices. There are approximately 200 different bindings available. Everything from Amazon Dash buttons, to Insteon, to Phillips Hue, Z-Wave, and more. Just about any current home automation protocol, technology or standard can be integrated with OpenHAB.
Here's what we found particularly attractive about OpenHAB:
OpenHAB offers a variety of ways to persist, or store, device data. Database, JSON, MQTT, and a couple other options are available. We wanted to be able to store historical weather information for analysis. I'm fairly familiar with relational database as a side-effect of my day job, so it was a comfortable choice to save our data in a database. MySQL is Open Source, very common, and thus has a ton of support available. For us, this was another easy decision.
Attractive characteristics for us:
Although you can manage MySQL through a command-line interface, it's much easier and efficient to have a GUI tool to manage users, databases, tables, etc. Fortunately, MySQL provides an excellent, Open Source option, My SQL Workbench
Why MySQL Workbench:
Although OpenHAB offers several very useful user interfaces, we also wanted to roll our own. Fortunately, OpenHAB provides a REST API that easily facilitates custom front-ends. We chose to use fairly basic HTML5 web pages as our presentation layer. So we needed a web server to "talk" to HAL and serve up our custom web pages. We chose Apache.
Mosquitto is a very popular MQTT broker. MQTT is a light-weight protocol for exchanging messages between 2 or more systems. Mosquitto brokers, or routes, messages between HAL and some of our home-grown devices.
What we like about Mosquitto:
As mentioned, we utilized 4 Pi's in our HA system. This may be overkill and might be causing more problems than it's solving. Time will tell. Each of the major software components is installed and running on it's own Pi. OpenHAB runs on a Pi named "HAL", Apache runs on "Spidey", MySQL runs on "Dolly", and Mosquitto runs on "Zapper".
The method behind this madness is to spread the computing load. While all of these components can certainly be installed on a single Pi, we chose to divide the labor so as not to overtax the Pi. This should give us ample room for growth.
Each of our 4 Pi's starts with a basic, standard install of Raspbian. We found that the instructions on the official Raspberry Pi web site were more than adequate. Hit the "instructions" link for step-by-step details. Here's the high-level run-down:
We followed this same process for all 4 of our Pi's. The only difference between our Pi's is the size of the SD card we used. The database server got a larger card (64mb), the MQTT server a smallish card (8mb), the other 2 got a medium sized cards (16 MB).
At this point, the Pi is ready for it's specialized software install.
Out installation of OpenHAB used the "apt-get" software/repository management tool. When we first installed OpenHAB, version 2 was still in a pre-release phase. They have since formally released OpenHAB 2. So, there might be slight differences in the install procedure we went through vs. what it is now. I apologize in advance for any discrepancies.
Here's a link to Raspberry Pi install. It includes prerequisites.
This page has more specifics/step-by-step instructions
Here are the highlights of the install process:
You can then point a browser to your Pi's IP address, port 8080. This will connect to your OpenHAB server. The first time you connect, it'll walk you through a set-up wizard. The wizard wasn't in place when we did our OpenHAB install, so I can't directly comment on it, but it seems fairly straightforward.
The links above include instructions for doing a manual install for the more adventurous. There's also an install image called "Openhabian" that takes care of installing the OS (Raspbian) and OpenHAB install all in one shot, for the less adventurous :)
We now have the heart and soul of our home automation system up and running. As mentioned earlier, OpenHAB is really just a framework for integrating various sensors and controls, so it's not very functional at this point apart from the demo. However, subsequent write-ups will add more and more functionality.
Head on over tofor more fun!