Welcome to installment number twenty seven of the Design Challenge Project Summary series here at Element14. For those of you who are new to my content, in this series, each week, I chose single Design Challenge project from the current challenge, or past challenges, and write a short summary of the project to date. If the challenge in which the project is part of is ongoing, I will periodically update this post until the challenge is finished. I am sure that some project summaries will get more than one update if they themselves are updated frequently. Unfortunately, projects that stall out, or get abandoned, will not receive any updates. Additionally, some project creators like to keep their own project summary going, and this series is not meant to overshadow those post, but to highlight each project from an outsider's perspective.
The subject of this installment is project Thuis, by Robin Eggenkamp (rhe123). Thuis was part of the 2016 Pi IoT Design Challenge dubbed Smarter Spaces. In this challenge, participants were tasked with creating a smart environment using a Raspberry Pi and several accessories such as the system.
Robin has been an IoT enthusiast for quite some time, and it was natural that he apply to join the Pi IoT Smarter Spaces Design Challenge, as he had some of the home automation infrastructure in place already. In his project’s introductory post he laid out the plan for what would eventually become the challenge’s second place finisher. Robin set the goal of building a system that would be able to control several aspects of his home including lighting, TV entertainment, energy monitoring, an easy to use mobile UI, and a welcome home system.
“The end product of this challenge will be an improved home automation system in my home. The core of the system will be a 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,” Robin said.
The project’s second post briefly clued us in on some of the hardware that will be used to control several features of the home including, Z-Wave lighting dimmers, iBeacons, and Move, a motorized Bluetooth controlled device that can open and close blinds and shades. Robin did mention that his home already has several Z-Wave devices, and Raspberry Pi boards in it, so he does have a bit of a head start already.
In update number three, Robin introduced us to the software architecture for the project. “At the heart of Thuis there is a Java EE application running in a WildFly container on a Raspberry Pi 3. On the same node Z-Way (a Z-Wave controller), Mosquitto (a MQTT broker) and a database (which one is to be decided later) are running. They are sharing the same node to save budget, but because of the modular set up they can be split on to multiple nodes.
Initially the core application will be built around a MQTT observer: it subscribes to all available topics and knows what to do when certain messages arrive,” he said. “All the rules live here, has knowledge of all devices, and keeps their status up-to-date. Different types of commands can be linked to each device and executed for them. Execution happens in prioritized JMS queue. This makes it possible to execute some commands in a predefined order and prioritize user initiated actions above background tasks.”
Update number four focused on using a program called Chef to build an install profile that would automatically provision Raspberry Pi nodes with identical software and settings. Unfortunately, Chef does not support the Raspberry Pi out of the box, which makes bootstrapping much harder than it is with other platforms. Robin has found a workaround for this though, and he provides a full tutorial on how to use this workaround to make Chef work correctly. This post also covers the basis of how Chef works, and helps the reader to better understand some of the nomenclature that Chef uses.
In update number five we learn more about what a Chef recipe is, and how the Thuis cookbook is created. The Thuis cookbook is made up of several different prewritten recipes found in the Chef supermarket, as well as some that were written by Robin himself. “I selected several cookbooks from the Supermarket and wrote some myself,” he said. “Using a series of recipes I defined the software and configuration of two of the nodes of Thuis in the Thuis Cookbook. In this post I’ll show you my choices and give some code samples to let you set up your own Chef config.” I have used a similar program called Puppet before to automate website development environments with a CMS called Drupal, but I have never even thought of using something like this to deploy multiple Raspberry Pi with the same configurations, but I can not wait to give this a try for myself.
The official challenger kit arrived in update number six, and Robin got started with getting the new Raspberry Pi 3 up and running. Thuis will use a distro called raspbian-ua-netinst as a basis for its install, as this gives the Pi 3 a very lean install of Raspbian. Unfortunately the project’s maintainer has not gotten around to updating the software to be compatible with the Raspberry Pi 3 yet, so Robin had to perform some manual steps to get everything up and running correctly. Luckily for us, he documented the whole process, so that we could easily follow along at home. The post concluded with bootstrapping Chef to the device, and then we got a brief tutorial on how to configure Z-Way and how to deploy an application to WildFly.
Update number seven walked us through the process to publish activity from Z-Way to MQTT. “Whenever the status of one of the selected devices changes it will be published to a topic. Based on these topics some other topics are available to change the status of the devices or request a status update,” he said. This tutorial was quite eye opening for me as I am working on a smart home project, and one of the things I have not figured out yet was how to connect Z-Way and MQTT together. As of this writing, I have yet to try this out for myself, but I am sure that the method described in this post will work perfectly for my application.
Update: September 30, 2016
In update number eight we got a brief glimpse into Thuis’ past as well as its future. If you have not yet read the post, Thuis got its start well before this challenge was announced, and the project’s namesake is actually the control software for Robin’s current smarthome setup. Thuis is written in Java, and currently runs on a , with the actual software being inside a WildFly container. This update mainly focuses on improving the Thuis core, and how to more efficiently utilize MQTT. “In a later stage some more external systems will be added to the core, for example for controlling the Home Theater. I'm also aware that, to keep this blog post from growing too much, I have simplified some code samples and didn't cover every detail,” he said.
Update number nine focused on providing readers with a sort of visual update to how the project is progressing so far. Robin made this post to update readers as to why progress on the project had stalled out for most of the past month. As everyone knows, life does get in the way sometimes, and we have to step back and focus on more important things. Thankfully, Robin returned, and progress will move forward from here. If you are confused about where all of the systems development sits as of this update, this post covers everything.
Every home automation system in the world would be mostly useless if it’s owners had to connect to a terminal, and then issue text commands to use the functionality of the system, and Robin agrees with this. In update number ten, he walked us through how he created a UI for IOS that features elements that can be linked to MQTT. To keep things simple for now, he decided to only create the three elements that would be most useful with the current system: a button, slider, and an info tile. The button will play a dual role as an indicator, as well as a trigger, meaning that it will display the state of the toggle and pressing it will change that toggle. The slider will mostly be used with the lighting dimmers that we saw in an earlier post. Finally, the Info Tile element will be used to display the current state of something such as the temperature of a room. If you are getting ready to build an UI for your home automation system, this is definitely a post you need to read.
Update number eleven continued with the Thuis UI build for IOS, and as you can see from the image above, it turned out very well. Robin even managed to get the UI working on iPad devices and not just iPhones, and he even wrote a short tutorial so that readers can enable their app to work with both devices as well. “From my holiday location at the coast of Bulgaria I finished up the implementation of the UI of Thuis. It works nicely on both the iPhones and the iPad on the wall,” Robin said. He included a demo video of the Thuis UI in action, but you will have to read the post itself to check that out.
One of my favorite aspects of home automation is the ability to manipulate any connected lighting you have in your home, and in update number twelve, Robin educated us on how to properly install a Z-Wave based dimmer unit into an existing light fixture, and then how he added a control for it into the Thuis UI. Connected lighting was one of the first things I tackled in my home, and from my experience, that statement is true for most novices to home automation. I am sure this post will help many people for years to come.
Update: October 2, 2016
Update number thirteen saw the start of the presence monitoring system for Thuis, and in doing so it also accomplished the “Welcome Home” use case. Utilizing iBeacons, small Bluetooth LE devices, Robin was able to develop a system that is capable of detecting who is home, and what room that person is in. This allows Thuis to perform a specific command, or set of commands based on which user is where in the home. An example of this functionality would be to turn on the foyer lights when the foyer’s iBeacon recognizes any of the home’s residents entering into that room. To top this system off, Robin was able to tie everything back to the main Thuis hub, and then use that data to perform other tasks. This is yet another update post that you have to read for yourself to fully grasp all of the possibilities that this system opens up.
In update number fourteen, Robin began working on integrating his home theater into the Thuis system, a series which he says will complete over three separate update post. In this first part he showed readers how to begin communicating with CEC-enabled devices from a Raspberry Pi. “Let's start with a short introduction of CEC itself. CEC stands for Consumer Electronics Control and is a feature of HDMI. CEC enables HDMI-devices to communicate with each other. In the ideal situation this means a user only needs one remote control to control all his devices: TV, AV receiver, Blu-ray player, etc,” he said. “Unfortunately many manufacturers use their own variation of CEC and therefore in a lot of cases one still needs multiple remotes.” To get around this issue, Robin made use of the libcec library, which enables the Raspberry Pi to “interact with other HDMI devices without having to worry about the communication overhead, handshaking and all the differences between manufacturers.”
Home theater integration continued in update number fifteen, with Robin focusing on device control. “Before we can use any devices in Thuis we have to define them. You might remember from [Pi IoT] Thuis #8: Core v2: A Java EE application that we have a class Devices containing static definitions,” he said. After some quick code snippets were written, Robin was able to control the power on and off functionality of his TV, Apple TV, and stereo receiver. He finished up the post by integrating a Wake On Lan (WOL) command into Thuis that would turn on his Network Attached Storage Array (NAS) when Thuis needed to connect to it.
Update number sixteen covered one of my favorite pieces of software for a home theater setup, Plex. For those of you who are not familiar with Plex, it’s “software which makes it possible to enjoy all of your media on all your devices. When on the server you create a library based on video (and music, photos, etc) files, Plex finds the corresponding metadata and gives you an easy to use interface to browse and play your movies,” Robin said. “You can interact with Plex through its API and you can keep up-to-date with what's happening on each client by subscribing to the WebSockets channel.” I won’t go into detail here on how Plex is setup, but Robin covers the more advanced aspects of his install in this post.
Update number seventeen concluded Project Thuis, and Robin clued us in on what parts of the project were made available in the open source realm on his GitHub. Overall Robin contributed five segments of the project back to the open source community, and seven unique use cases that are sure to find their way into the home automation projects of others. Watch the demo video above, and then head over to the full post to find out what the future holds for project Thuis.
That is going to wrap up my project summary coverage of project Thuis for now. Robin ultimately won the second place prize for this project, and I have to say that I personally feel that it deserved a top three finish! This project has been an absolute joy to follow, and has been educational throughout. Please visit the project’s blog page to read it in it’s entity! Tune in next week for another Design Challenge Project Summary here at Element14. Until then, Hack The World, and Make Awesome!