Home Automation Controller

Mike Thariath

DesignDevelopmentNetworkingDev OpsProject Management

stack

Javascript
ReactJS
Redux
Socket.io
NodeJS
Z-Wave
Raspberry Pi
Linux
RTI

Project Overview

I made a web app to control and monitor various parts of our home. I started with the entertainment system by making a "universal remote controller" web app to help my roommates control the media center without worrying about different remotes, inputs, etc.

I then expanded the system by adding lighting automation, climate control, and security sensors on our doors. The app also provides real time feedback (powered by Socket,io) when events happen outside the app (e.g. when a door opens, or a light is controlled elsewhere.)

Over the years, I collected a hodgepodge of professional grade home automation equipment, including motion sensors, door sensors, smart lights, and more. Everything was configured to work together at my last apartment, but since moving into a house with roommates, I put off setting everything up. Until now. I recently found some extra time and started reassembling the system, starting with the entertainment system.

The web app itself, which will be discussed later, along with the Express REST API middle layer, is hosted on a Raspberry Pi on my local network, served up using the Serve NPM package.

Entertainment System

The interface for controlling the Roku, a media streaming device.

The entertainment system consists of the following hardware, with its controlling interface listed in parentheses:

  1. TV (IR)
  2. A/V Receiver (IR)
  3. DVD Player (IR)
  4. Roku (REST API)

To control the IR devices, I'm using an RTI XP6 processor, a professional grade home automation controller. In reality, I'm only using a fraction of its capabilities. It is NOT designed to be controlled via HTTP commands, but I found a third-party plug-in that exposes a completely unsecured REST interface for basic command execution. Using this, I was able to control all of my IR devices through my web app.

The state of the entertainment system—i.e. whether the Roku, DVD player, Chromecast, or other remote controller should be shown by default in the "entertainment" tab—is synced across sessions and devices using Socket.io. I added this because I thought it would be "kinda neat", but it turns out to be incredibly useful and intuitive!

Lighting Control

The lighting control interface

To control our lighting, I used a HomeSeer home automation controller, which exposes a JSON (not RESTful) API to control devices and get device state. To provide real time feedback, I used a plugin that automatically shoots Webhooks when events happen, pointed to an Express server hosted on a local Raspberry Pi. Unfortunately, the Webhooks were unreliable, and I set up a TCP server in the same Node server, and configured HomeSeer to send custom strings for various events. In the Express server, I emit a Socket.io event to all connected clients, with fresh data whenever a change is detected. On the client side, I send out a Redux action with the data as the payload whenever events are received. As a bonus, HomeSeer also integrates out of the box with Google Home, which means all of the lights are voice controllable.

Next I plan to add more lights throughout the house, along with automation based on motion detectors, time of day, sunrise/sunset, and based on who is home.

Climate Control

The climate control interface.

Since we have two zones of climate control, our HVAC utilities run high. The interface makes it easy to check up on its current status, and automations save energy by ramping down HVAC usage throughout the night, or while nobody is home.

I will also add additional temperature and humidity sensors, along with humidifiers and possibly space heaters for certain parts of the home.

Security

The "security system" interface

The security system (like the rest of the app, really) is in its infancy. It shows the status of four doors, and sounds an alarm if doors are left open for too long.

Along with the door sensors, I will also add door locks and Z-Wave doorbells (since our regular doorbells don't work anyway.) I will also add motion sensors throughout the house, along with sensors on windows, and leak detectors and a valve controller to check for water leaks.

Frontend Stack

I initially built the frontend using Gatsby + React. The out-of-the-box routing and other cushy conveniences were nice while it lasted, but as the system expanded to include Redux and Socket.io, I switched over to CRA.

To speed up deployment, I wrote a small npm script that SSH's into the hosting Raspberry Pi over the LAN, wipes the existing files, and replaces it with newly built files from the project, in a matter of less than a minute.

Backend Stack

I created a RESTful (ish) middle layer with Express to interact with HomeSeer and give realtime feedback to clients using Socket.io. Interacting with HomeSeer over the API is different for different device types (motion sensors, dimmer, thermostat, etc.) and the middle layer gives a nice consistent interface for the frontend to interface with.

HomeSeer can send outgoing messages in realtime as a TCP client, so I also set up a TCP server to receive events the moment they happen to trigger a Socket.io event.

Future Plans

Now that the system is up and running, I will slowly start expanding its capabilities. The next items on my to-do list include:

  1. Use environment variables so I can show off the Github repo without security concerns (IP addresses, names, etc.)
  2. Adding more lighting control devices
  3. Adding motion sensors both for security and automation.
  4. Adding authentication for users, to show different devices for different users (like lighting in each of our rooms.)
  5. Add remote access functionality after authentication.
  6. Make the interface prettier and add animations.

Keep checking in to see the progress!