X10 and Home Easy with Node-RED

Some X10 and Home Easy modules
Some X10 and Home Easy modules

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.

MQTT to Home Easy
MQTT to Home Easy

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.

Light control
Light control

Appliance control
Appliance control

Modes
Modes

Mobile
Mobile

I’ve taken some cues from the old Misterhouse interface since it is what I have been using for over 10 years but it is a complete rewrite in PHP, javascript and some websockets thrown in for good measure, no more Perl or frames at last!  The CSS allows it to reflow nicely on different sized screens so it fits well on a desktop, the three O2 Jogglers (running Xubuntu these days) I have around the house as well as tablets and phones.

X10 and Home Easy transmitters

OOK Relay, 433MHz to MQTT
433MHz OOK Relay

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.

 

5 thoughts on “X10 and Home Easy with Node-RED

  1. Hi Nathan,

    Sounds good – I’ve been working with a collegue who’s done something similar with MQTT for LightwaveRF, using a transmitter on the RPi GPIO pins….

    I’m interested in your revamp, particularly the GUI. Are you planning to discuss how you’ve done this in addition to:

    it is a complete rewrite in PHP, javascript and some websockets thrown in for good measure,

    Thanks
    James

  2. Hi Nathan,
    Interested to hear about using Node-Red and MQTT. Do you have any primers on running MQTT from a Raspberry Pi to talk to Arduino nodes?

    regards,

    Dave

  3. Interesting. I have been running some cheap plugs to switch TV off etc. But these looks interesting. Would more than likely be looking to build something on a rasPi to control. Arduino’s are generally out of the picture for me now, as too much of a pain to develop on.

  4. Hi Nathan, great blog!

    I have a question regarding Home Easy modules..
    Do you know if the new Home Easy (the one that don’t have unit or group selector) works?
    At the moment I have one HE socket but they don’t have the selectors, instead they have a learn button. As I still don’t have the radio I can’t see if will work or not.

    Best regards and keep posting!!

  5. Hi Nathan, great work

    I like your user interface design ,nice clean and mister house alike.Can u share the code of your smarthouse project or at least user interface part.I have a misterhouse setup on a old P3 and thinking that is time to change some things.I plan to change old ui with new web page written in html5 and js and move all setup on to a raspberry pi.
    If u cannot share code can i have your permission to design an ui based on on your posts i really like it and is in mh style witch am used to it

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.