Once upon a time I started to automate my home using some cheap plugin switches, Arduino’s and homemade sensors. Over time the Thuis app (the name of the system, “home” in Dutch) evolved and grew, and now it’s time to bring everything to a higher level. Imagine arriving home and being welcomed by your iPhone giving you direct actionable notification, or walking around while the house adjusts to your needs. Lots of things are currently already possible using off the shelve solutions, however you’ll always lack the freedom and power compared to designing this yourself. I’m solving this using a flexible communication layer based on MQTT. By giving all parts one way of communication in common we can mix several off the shelve solutions with our own. This brings me to the two goals of this project:

  • Improve my own home with an integrated home automation solution based among others on Z-Wave, Java, iOS, iBeacon, Plex and a Raspberry Pi as core
  • Contribute to the community by making several parts available as open source libraries for others to reuse

Selected use cases

After a long day of work coming home should be a relaxing experience. With this project I intend to make this a reality as much as possible. I have chosen a few use cases to focus on, which I will describe here.

Light when and where you need it

Take for example the kitchen: depending on your activity, your need for light are very different. While cooking the lights above the worktop and stove should be on, maybe even the ceiling lights as well. But when you’re there just to brew a cup of coffee a small light will do. And what about when it’s still quite light outside? The light plan should feel natural. It can be based on data from sensors, knowledge about habits and other activities in the house.

Using several ambient light sensors, PIR movement sensors, and possibly iBeacons, the system can detect where something is happening. When combined with previous behavior actions can be triggered.

Welcome home

Getting home in the winter and finding your home at a comfortable temperature is something most home automation systems or thermostats like Nest provide. However wouldn’t it be nice to help you in your most likely activities too? Such as when getting home in the evening you get a notification which allows you to turn on the home cinema system. Or you get home when it’s late and dark lights guide you to the bathroom and bedroom and will turn off when you lie down.

The detection of coming home will be a combination of several iBeacons around the home which are sensed by an iPhone in combination with some PIRs. Based on the time and where in the house the sensors are triggered the wanted actions will happen.

Home Cinema

Home Cinema involves many parts: TV, receiver, speakers, and for playing media an Apple TV and BluRay player. Just turning them all on or off is already a hassle. Using some Z-Wave switches and a Raspberry Pi attached via HDMI most of this can be turned into a single action. In combination with Plex and some APIs we can make the selection of your favorite TV series easy as well. The Raspberry will communicate through CEC with the TV and receiver, through MQTT it will receive commands from the core of the system and report back if anything happens.
A possible addition to this will be adding a DIY Ambilight. This can be done by capturing the images from HDMI to a Raspberry Pi, which will drive an Arduino, which in turn will drive the LEDs mounted on the back of the TV.

Mobile & On-The-Wall-UI

A home automation system can do quite some things automatic, but it can’t read your mind yet. So there needs to be an interface to tell it what you want. For this an iPad will be installed in the living room for easy access to the most important actions and data, including controlling the home cinema. When walking around these actions are also available on the iPhones of me and my girlfriend. In the kitchen a Raspberry with the 7″ touchscreen will give similar controls, this time giving data useful while for example preparing breakfast, such as the weather forecast and maybe even delayed trains.

Two possibilities for further expansion are a dedicated iPhone as a home cinema remote and using an even more natural way of communication: speech. The latter will involve having a microphone connected to either a Raspberry or the wall-mounted iPad which always listens to a trigger phase (much like Apple’s “Hey Siri”) and afterwards can execute actions. This might however be a bridge too far for now.

Mockup of the iOS app
Mockup of the iOS app

Wake-up light

As alarm clock I use the Sleep Cycle app: it measures the quality of your sleep and wakes you up at the right moment in your sleep cycle. In the 30 minute window the app might sound the alarm it would be great if the bedroom adjusted gradually to daylight. In the summer slowly opening the curtains (using a MOVE) would be enough, in the winter it should also turn on the lights. By doing this waking up should be a lot easier.

Unfortunately it doesn’t have any APIs yet (they might add a web hook after I suggested it), but I want to prepare before they do or to find an alternative that does. Or maybe I can simulate a Philips Hue bridge which it already supports?

Manual override

Nothing is more annoying than lights to turn on or off when you don’t want it, so it’s essential to provide a manual override for each as well. I will use traditional wall-switches for this, which will be integrated in the system through Z-Wave.

Energy monitoring & saving

One of the promises of home automation is that you can save energy. As you will add quite some (always-on) electronics this can be overrated. However most switches can help you monitor the usage of individual appliances. I use a YouLess device to get the overall usage. Using this information you can actually save energy: knowing is half the battle. Out of the box the current power usage and totals are available, but you can only really act on it when you have usage over time and trends. That’s why I will work on aggregating the data and making it available for analysis.

Results

The end product of this challenge will be an improved home automation system in my home. The core of the system will be a Raspberry Pi 3 with a WildFly server. The Java EE application running on this will manage the logic of the house and bridge the several parts together. On this same Raspberry the Razberry/Z-Way software will be installed to be able to communicate with Z-Wave devices. Another Raspberry will be used as part of the Home Cinema setup and will be hooked up through HDMI to the AV receiver. It will control a.o. the receiver and TV via CEC. Other apps in the system include the iOS apps for both iPhone and iPad, which act as remotes.

An overview of the home with all the devices can be seen below:

Map of the home with devices. Numbers refer the hardware list below.
Map of the home with devices. Numbers refer the hardware list below.

The most important aspect of the project will be the communication between the different nodes. The nodes communicate with each other using MQTT. This is a very light weight communication protocol providing a publisher/subscriber setup. It’s very suitable for this project as it’s able to send around information quickly and it’s platform independent. To be developed and published as open source to my Github are at least:

  • MQTT integrations for a.o. Z-Way and Plex
  • A CEC Java library (with support for forwarding events to an MQTT topic)
  • MQTT based UI components for iOS
  • (optional) MQTT monitor which records events to a database for analysis

All these will help others who are working on a DIY home automation system, especially when they use MQTT for their communication.

About me

I’m a Dutch developer who likes to tinker with hardware. I’m mostly developing software in Java, Swift and some Processing (Arduino). For about 6 years I taught Computer Science at a high school, during which I also developed quite some course materials about Arduino (published by a Dutch educational publisher) and App Inventor (Dutch, available on GitHub in LaTeX). Currently I’m co-founder of the startups ZEEF and LinkPizza.