Rolling my own Home Automation

I have been quite keen on the whole home automation trend for quite a while. I had a Ninja Block, and signed up for the Ninja Sphere too! Unfortunatly things didn’t really pan out with the Ninja platforms in the end, I am not sure what happened in the end, those of us who signed up for the Ninja Sphere, got our boxes with the system in, but the platform just didn’t seem to be ready and phizzled out 🙁

However things have moved on and home automation is picking up more mainstream interest now. There are several off the shelf solutions to choose from, however I still have bits and pieces from the Ninja Block system and don’t feel like splashing the cash to buy a whole new system. So I have been slowly getting things back to the state where I have my own system!

Step 1 Controlling the Light

My lights are some of the cheapest available, http://www.limitlessled.com/ as well as being pretty darn cheap, the wifi hub is accessible to developes and you can find information about the API online, which is handy as it means there are plenty of libraries available for working with them. My version (https://github.com/buxtonpaul/myha) is heavily based on a few others, but with some changes/additions to make it work the way I want. Namely

  1. Allow use of a messaging system, I wanted to be able to control the lights potentialy through a number of different routes. To do this I have a a service running on my home server which receives rabbitmq messages and turns them into events to control the lights.
  2. Configurable. The decision of what triggers are connected to what lights should be done through simple config file, which can potentially be used later for other things. e.g. display of state of lights/bridges?

With the server up and running I can then control lights quite easily with a bash script (which simply calls a python script that sends the rabbitmq message to the server).

Once I had control of the lights here it was pretty easy to add control of these to HA-Bridge

https://github.com/bwssytems/ha-bridge

This is a service that also runs on my home server that pretends to be a Hue bridge. This allows things like the Amazon Echo to see my lights and be able to control them.

Step 2 Sensing stuff

One of the side effects of having been a user of the Ninja Blocks platform, was that I ended up with a couple of sensors that worked with the platform, these used a 433MHz RF signal. As it happens I also have the receivers for this from the original ninja block (for some reason I decided to canabalise this). Hooking this up to a Raspberry Pi was pretty straightforward, using these instructions

Decode 433 MHz signals w/ Raspberry Pi & 433 MHz Receiver

The only thing I really had to do to get things working how I wanted was to change the way the RFSniffer program output the codes so that it flushes stdout after every line rather than buffering it up (it took me a while to realise that was the problem). I then simply piped the output of rfsniffer into my lightsender.py and it now automatically triggers lights.

Future things for me to look at involve perhaps adjusting the lights based on time of day, and linking it up with the alarm clock I am developing (more of this later!).