Blog
OpenEnergyMonitor

Remote Control of LightWave RF plugs via MQTT using emonPi with OOK Tx

Using a Raspberry Pi as an emonPi / emonBase web-connected base station for energy monitoring has many advantages (maintainability, remote access, debugging, updated etc.) but it does seem rather wasteful to have a 900Mhz 1GB RAM machine being used to post a couple of integers to a web-server! The always-on nature of a web-connected base station and plenty of spare processing power makes it ideal to use the emonPi for more than just energy monitoring; home automation and heating control optimisation are obvious candidates.


Hardware

Many home automation products such as RF plugs, relays and heating remotes use a simple OOK (On-Off-Keying) wireless protocol. UK company LightWaveRF produce a variety of RF plugs and relays which can be controlled via OOK RF. The protocol is also compatible with some cheaper OOK learning receiver relays.  While maybe not strictly open-source the protocol and been reverse engineered allowing plugs to be easily controlled from Arduino / Raspberry Pi. There is an active LightWaveRF online community. Using off-the shelf hardware like this is a 'safe' way to control lights, heaters and appliances  around a home without getting our hands dirty dealing with with high voltages. These plugs and relays can be used to control anything from lights to immersion heaters, most LightWaveRF plugs/relays will switch up to 13A / 3kW.

Note: OOK protocol by it's simplistic nature is not particularly secure, I would not recommend controlling anything you don't mind getting accidently switched.

An OOK transmitter can easily be added to the emonPi.  We have started stocking OOK transmitter modules in the OpenEnergyMonitor store as well as adding an option to have OOK module factory installed on new emonPi's.

See emonPi Technical Hardware Wiki for details how to retrofit OOK TX module to existing emonPi's.

Software

We have been working with Lawrie Griffiths from Geek Grandad blog to develop a LightWaveRF MQTT service to run on a Raspberry Pi to allow LightWaveRF plugs to be controlled via MQTT.


Once running a plug can be controlled by publishing to the 'lwrf' MQTT topic:

E.g "1 1" switches on plug 1 while "1 0" switches off plug 1. Plugs can be paired in the usual LightWaveRF plug.

See emonPi technical Wiki for how to install & setup.

Existing LightWaveRF remotes can be emulated allowing plugs to be controlled from either emonPi MQTT or via the remote.

Now our plugs can be controlled via MQTT there are a many of options open as to how to control either via interface openHAB (blog post coming soon..), nodeRED, android Tasker etc.

I have been using nodeRED with input from android OwnTracks running on my phone to detect when I'm home and turn on a couple of lights:

Demo:

Using NodeRED and OwnTracks to turn on LightWave RF sockets when I arrive home: 




Using android Tasker with  AutoVoice and MQTT plugins to control LightWaveRF sockets:



Next Steps

Now we can control appliances remotely via MQTT the next logical step is to add a mobile user interface. In my next blog post I plan to explore setting up openHab to control appliances. Here's a early preview: 




We plan to include out-of-the-box support for OOK LightWave RF, nodeRED and openHab pre-configured on our next emonPi pre-built SD card. Due for release in December 2015.

To engage in discussion regarding this post, please post on our Community Forum.