HomeCtrl

Introduction

HomeCtrl was a long term home automation project and a huge learning project for me during my university years and even a some time after. I used it productively in two appartments before I moved into the one that I have now. That said, there were actually three versions of it, from some basic connecting of things to the computer and pressing buttons, to a fully autonomous system.

Version 1

The first version of HomeCtrl was really just trying to connect some buttons and LEDs via parallel and serial ports to my computer. I already used Java and the RxTx library to react to user input and send some output. Seeing where it is today, that really wasn't much but it got me hooked and inspired me to go to the next level.

Version 2

Eventually I scrapped version 1, because I wanted to actually control things in my room (and later appartment) using a nice interface. With nice I mean a Star Trek LCARS interface, because I already liked Star Trek TNG. In that time I was learning about Java based webservers in some university course so I gave that a try.

I built a Java web app using Spring that ran in a Tomcat web server instance. I loved this idea, because I could built a web interface, which would be available on every device at home ... no installation. At first, the web server ran on my PC. Later, I put it on an extra computer for productive use. The web server did not control the devices directly. Instead, the server interacted with Atmel microcontrollers that I programmed in C, which controlled the devices and also provided status data using sensors.

HomeCtrl V2 heating control interface
HomeCtrl V2 heating control interface

What kinds of devices did it control? I startet with lighting and expanded to heating control and temperature sensors. I wanted to expand to blinds and even got the hardware, but I never got that far, even with version 3 (maybe, if my wife and I have our own house one day I'll revive the project and finish it). BUT, the project also got a sound system, meaning I had a headless VLC player that I could control via the interface to stream tuner channels or MP3 music.

Version 2.1

Version 2 eventually got a feature and design update in terms of configurability.

HomeCtrl V2.1 homepage
HomeCtrl V2.1 homepage
HomeCtrl V2.1 room control
HomeCtrl V2.1 room control
HomeCtrl V2.1 administration
HomeCtrl V2.1 administration

Oh, I almost forgot. Version 2.1 had one really awesome feature: software agents. I used the Rhino JS library to send JavaScript programs here and there that could execute controls on the servers and/or gather data, take the status data with them and continue to run on another server. Wait, multiple servers? Yes! During that time I was considering scenarios like a hotel complex, where each house has its own server and you could send an agent script around to handle actions remotely in the whole complex.

I liked using this system. The downside was that you had to press buttons for everything. After a few years I wanted a better system, one that would simply do what it was supposed to do without me constantly interacting with it. And so I moved on toward Version 3.

Version 3

Version 2.x was still very much try and error. That was shown mostly in the code, which became a big ball of mud. I wanted to move on to something more modular, in two ways. Firstly, I wanted the whole system to be highly configurable. Not the tiniest bit of how sensors and actors would be connected to each other should be predefined. Secondly, the system should be fully autonomous. I should be able to get information and take some influence if I wanted to but that should be the exception. As a result, the user inferface should not be glued to the control as it was with the Java web server.

So this time, before I started, I did some architectural work. I decided to still go with a centralized control server and the distributed microcontroller setup to connect to sensors and actors. I also kept Java and Spring on the Server but instead of a web application, I wrote a simple application. The whole distributed system used HTTP communication, which I kept too. That way I could also offer an interface of the same kind on the server to remotely connect any kind of UI.

Microcontroller during development
Microcontroller during development
Microcontroller in housing
Microcontroller in housing

The server application uses a self written event system. The whole control system, its configuration and interaction can be configured using a JSON configuration file. The parts of the control system are small code modules that resemble different kinds of actors and sensors as well as pieces to connect them through converting, comparing or combining data. The sound system didn't make it into version 3. Neither did any UI, because it worked so well after I quickly got the configuration file right. It did what it was supposed to, work fully autonomously.

Well, as I said in the introduction, the system is not in use right now. But version 3 is also available on GitHub, so you can always check it out. You can find HomeCtrl here.