This is part of a series of posts I am doing describing some of the things I have been doing as part of the revamp of my home automation system.
When I started on the home automation road in 2002 I began with a kit of 3 X10 modules and a CM12U PC interface which I controlled via the command line X10 application Heyu and some DIY scripts, shortly afterwards I switched to the Perl based MisterHouse package which I heavily customised over the years and continued to use until recently.
Many more X10 modules were added over time giving me control of most lights in the house as well as several appliances. X10 has always had a few issues though, the modules are fairly costly although the clones available these days have improved that somewhat but the biggest issue has always been that it is susceptible to noise or interference on the mains line causing things to not turn on/off when asked or to turn on/off erroneously. As more and more electrical devices have been added around the house and with nearly every wall socket having a 4, 6, 8 or more gang adapter plugged into it these problems have only got worse.
With this in mind I’ve been gradually adding more and more Home Easy modules to replace the X10 modules that were causing problems and have now switched almost exclusively to Home Easy. Unlike X10 these modules work via RF so don’t have the same communication problems and they are very cheap, 3 appliance modules can be had for around £20 with a remote control, less if you pick them up second hand on eBay and being controlled via 433MHz OOK signals they can easily be controlled using an Arduino etc.
To control them I am using a budget Arduino clone with an ethernet shield and a cheap 433MHz transmitter, along with the 433MHz for Arduino library and this sketch that I wrote which subscribes to an MQTT topic and turns the Home Easy modules on or off depending on the payload, for example a payload of 4525186,0,on turns the module with unit code 0 in the group with code 4525186 on, this allows you to use as many Home Easy devices as required (maximum of 16 units per group code). One thing that will become important later is that I am not using any of the codes used by my original Home Easy remote controls which will allow me to re-purpose those.
I did try to get this working on a Nanode as I have a few spare after replacing them with other things, MQTT on the Nanodes was always problematic but the recent appearance of the ArduinoUIP library for the ENC28J60 ethernet chip makes it compatible with the standard Arduino MQTT client (pubsubclient) which seems to be much better, unfortunately the combination with the 433MHz for Arduino library seems to be causing RAM issues resulting in random crashes so I went with a cheap W5100 based ethernet shield in the end as this handles the IP stack itself resulting in much reduced memory usage and a very reliable system.
To control all this I’ve been rewriting my home automation web interface from scratch using Node-RED as the back end, there are a few screen shots below of the lighting and appliance screens and mode screen and there are some more on the home automation page.
To control the Home Easy devices it is just a case of sending the correct payload to the control/homeeasy topic and I’m also setting a global.context variable to keep track of what is on and off. For the few remaining X10 devices I’m just using the Exec node to shell out to Heyu.
X10 and Home Easy transmitters
I also have some X10 RF wall switches and PIRs as well as four Home Easy remotes that came with kits, a Home Easy RF wall switch, internal and external PIRs and a door contact. To utilise these I am using a cheap 433MHz receiver (the counterpart of the transmitter used for the Home Easy transmitter node) connected to one of my Tiny328 modules running the JeeLabs Ookrelay2 sketch, this receives the OOK signal from the X10 and Home Easy remotes and relays it over the RFM12B which is in turn received by the Tiny328 connected to my server and fed into Node-RED. The parsing function I’ve written in Node-RED sends the commands from the various remote controls to different MQTT topics from where they are passed through functions to send commands out to more MQTT topics.
This allows the buttons to be configured to turn things on and off, activate macros (eg. turn a set of lights on/off) set modes (eg. home and away) and so on. I’ve de-programmed the Home Easy remotes from their original receivers so that they no longer control the modules directly which allows me to use all 8 or 10 buttons for different functions as required.
In the Node-RED function that parses the output from the Tiny328 that is connected to the server I check if the transmitting node is the OOKRelay (node 20) and if it is the packet is sent to another function that checks the OOK code to see if it is a Home Easy or X10 remote and directs it to an MQTT topic using the remote’s code, eg. homeeasy/remote/2126
Another function node subscribing to that topic can then be coded to perform various tasks depending on the button pressed. Here is an example of a flow for an 8 button Home Easy remote being used to turn 3 devices on or off and the group on/off buttons being used for setting the system into home or away mode.
While the range on the Arduino transmitter to the Home Easy modules is very good the receiving range on all these remote controls with the cheap 433MHz receivers isn’t brilliant, maybe 6 or 7 metres for the Home Easy and slightly less for the X10 but it is easy to deploy multiple relays in strategic positions to get round this, I’ve also used a couple of Home Easy signal boosters in a couple of places.
As well as two X10 PIRs and a Home Easy PIR I’ve also got the hacked Ikea Oleby light, a hacked AirWick iMotion Freshmatic and a Tiny328 with PIR module which are used to turn lights on automatically in several areas. I’ve also been experimenting with some cheap Chinese 433MHz alarm PIRs and door/window contacts but so far the range on these with the 433MHz receiver board is so poor as to be unusable but I’ve not given up yet.