Controlling electrical sockets with Energenie Pi-mote

Last Christmas I decided I had spent enough time bending over the various chairs to reach the switch to turn on and off the Christmas tree lights. So I bought a set of Energenie remote-controlled mains switches.

I decided that this would be a great device to wire up to the Raspberry Pi, because I could then program the Pi to control my Christmas lights during the day. Unfortunately, the small remote control supplied with the distribution board does not have any mechanism of external control.  So I got in contact with Energenie, the manufacturers of these great devices, to invite them over to Pi Towers and show them what a great thing Raspberry Pi is and why they should create a Raspberry Pi add-on to be able to control the devices…

A couple of months later I get a visit from their team, who showed me the results of quite a bit of engineering (and a little fun I think):

pimote

A little bit of information from the guys at Energenie:

The Pi-mote control is an add on board that permits control of 433mHz radio controlled electrical sockets. Easy to install and command, the product provides a simple and safe way to add control of mains powered devices and appliances to your Raspberry Pi.

Energenie make a range of compatible sockets which can be operated by Pi-mote control. If you already own Energenie sockets, these are backwards compatible with Pi-mote Control.

A starter kit is available which includes the Pi-mote Control and 2 13Amp electrical sockets for use in standard UK 3-pin mains sockets. Some Python code to enable simple on-off control of these sockets will get you going out of the box.

While Amy Mather was in the office earlier in the year to do some work experience, I asked her to think of something she could do with the system and to write some code to prettify the existing Python code. She started by writing a basic function to control power sockets using some binary logic, and proceeded to hack one of the built-in Python games in Raspbian to make it play a song and turn on some disco lights when the player wins the game. Cue the music:

…finally Rick-Rolled the Raspberry Pi blog!

See Amy’s example code and the modified memory puzzle game on her GitHub.

The basic usage for Amy’s energenie module looks like this:

from energenie import switch_on, switch_off
from time import sleep

# turn a plug socket on and off by number
switch_on(1)
switch_off(1)

switch_on(3)
switch_off(3)

# turn all plug sockets on and off
switch_on()
switch_off()

# turn some plug sockets on, then turn them off after 10 seconds
switch_on(1)
switch_on(4)
sleep(10)
switch_off(1)
switch_off(4)

Want to control something simple from your Pi? Washing machine, Vacuum cleaner, liquidiser (create your own cat scarer):

Buy yours at energenie4u.co.uk!

Update: The energenie module is now available in pip.

For Python 3:

sudo apt-get install python3-pip

sudo pip-3.2 install energenie

or for Python 2:

sudo apt-get install python-pip

sudo pip install energenie

See the documentation at pythonhosted.org/energenie

39 comments

Alex Eames (RasPi.TV) avatar

Love it. Apart from the music, that is! :)

Max Klingert avatar

Would you rather have heard cat-in-the-blender?

Gordon Hollingworth avatar

I did suggest to Amy that it would be the ‘right choice’

Michael Horne avatar

Looks like a nice, easy system to get home automation going without a lot of tedious re-wiring. Not bad at all for £20!

Mike Redrobe avatar

The Pi-board is only £9.99, for £20 you get 2 remote mains sockets as well.

Bram avatar

Yes! I want this! Are they selling EU-style plugs too?

Gordon avatar

They do do EU style ones, I think you’d have to buy a Pi-mote and the EU style ones separately

Gordon

Stewart Watkiss avatar

I had done some home automation by ‘hacking’ a remote control and using a reed relay to short out the pins on the switch. This looks like a much better solution.

AndrewS avatar

I’d been planning to do that too for ages, but never quite got round to it. Don’t need to now :-)

Looking at the sample code and instructions though it seems you can only control a maximum of 4 different sockets, which is a shame. The transmitter for the remote-controlled sockets I already have, has a 4-way switch on the back, and 4 sets of on/off buttons on the front, allowing up to 16 sockets to be controlled (in theory! I currently just have 4). No idea what kind of interference might come into play if you tried controlling that many sockets though.

AndrewS avatar

Just done a quick bit of maths, and if you actually want to buy 4 sockets to go with this, it’s slightly cheaper to buy the standalone Pi-mote board and the 4-pack of sockets (a total of £37) than it is to buy the Pi-mote bundle and a 2-pack of sockets (a total of £40).

John-Paul avatar

I have some 433MHz outlets I was planning to control with a Pi by hacking the remote, this is such a nicer implementation they created.

One question though, is it strictly tied to their hardware, or can you use different coding schemes for the 433MHz signals?

Gordon avatar

OK, I believe that their implementation currently is fixed to their system, but the 433 MHz modulator could be bypassed (by removing a resistor as I remember) and driving it from a GPIO…

Gordon

Nev Young avatar

Are you sure of the frequency?

I believe 433.000MHz is allocated to amateur radio repeater outputs in the UK.
From the RSGB website:
432.994 – 433.381MHz Repeater Output Channels (FM/DV)

There are many in the UK with an output on 433.000 MHz including my local 70cm repeater GB3NR.

Some people may find their lights going on and off at random when the hams start to chat. :-)

Nev Young avatar

Ok relax. I finally found that it actually uses 433.92Mhz.
Thoese extra 920KHz make all the difference.

RaspberryPaul avatar

I’ve also hacked a set of remote control plugs via relays and an io expender and this would have been nearly a good replacement. Shame it’s not an i2c device though as it takes up valuable gpio’s.

AndrewS avatar

I guess you could always wire up an i2c port expander to the GPIO pins used by this, and then hook up the port expander to the i2c pins on the Pi, as long as you’re comfortable with re-writing the control software. Using WiringPi should make it easier http://raspi.tv/2013/using-the-mcp23017-port-expander-with-wiringpi2-to-give-you-16-new-gpio-ports-part-3

will avatar

*sighs* looks like I can’t use it… They don’t sell the sockets with the option of US ones.

HBE avatar

Nice!
If you have already bought a set of sockets with remote control and you are willing to hack the remote, you actually don’t need an extra module in most cases, tho. You can use output from a GPIO pin to drive the transmitter of the remote, using this software:

https://github.com/r10r/rcswitch-pi

which works for the most popular chipset for those sockets.

The remotes (at least those sold in Germany) usually use 12 V batteries so in order to use the transmitter of the remote control at the reduced voltage supplied by the Pi, you will also typically have to change/add a resistor in the remote as well, a description of the wiring can be found here for example:

http://www.jotschi.de/Technik/2012/12/05/raspberry-pi-433mhz-remote-controlled-power-plugs.html

HBE avatar

one more thing: the blog entry from http://www.jotschi.de/ that I cited doesn’t mention it explicitly, but you really, really should remove the 12 V battery from the remote (and keep it like this) before wiring the Raspi GPIO pins to it :-)

u8nc avatar

the due diligence paid by Energenie will reward them handsomely, i would think, with Apple releasing HomeKit with the upcoming iOS8. Currently home automation is the preserve of the technorati, but each step like this makes it more mainstream

Rick avatar

Quick tip – The energenie site is on Quidco and offers 6% cashback on all purchases, so you can get them slightly cheaper :) Just ordered the kit myself.

Ken MacIver avatar

Minor Friday Fun,
I had a no-name set of radio switched sockets for my crimbo lights a couple of years ago.. Only one slight problem.
When my neighbour got home parked up and ‘blipped’ his car my tree lights went out…

Nick avatar

Had a similar issue once. Was going out to my car parked in the street at around 4:30am, blipped my car and my neighbours doorbell starting chiming!

Harry Lassen avatar

I was looking to buy one of these, but they don’t ship to Denmark… and then i read that some of you thinks i does not work with other low cost remote controlled outlets on 433mhz.. is there any truth to this?..

Geoff Johnson avatar

Looks neater and much easier to get up and running than my solution in MagPi issue 8.

Anders Jackson avatar

Well, looks really nice.
I’m using a Tellstick device myself. It can transmit signals in this frequency band to control stuff like this, but many more brands. It can also recive signals from switches and temperature transmitted thermometers. I bought my from a Clas Ohlson shop.
So that might be a solution. It is based on USB interfaces though, and a bit more expensive.
Check them on their web page. http://telldus.com/

Nigel avatar

I use an RFXCOM device, which is more expensive but has the advantage of talking to and listening to a huuuggge range of equipment from different manufacturers (just about every RF controlled socket, weather station, power meter etc etc).

It also ties in nicely to the openHAB home control software

So “well done Energenie guys”, but really hope you could make yours more generic so those of us with a variety of 433MHz kit can control it too, I know you’d love me to replace it all with your stuff, but that’s not going to work!

Tobias avatar

I recently bought the USB version of a EnerGenie/Gembird (which doesn’t seem to be the same company as this EnerGenie) 6-socket extension cord – which already has working Linux tools: sispmctl (http://sispmctl.sourceforge.net/).

Any benefit in using the wireless stuff except that I can’t assess the security of the wireless protocol (From experience, most 433MHz devices use pretty simple/similar protocols, so the garage door opener might switch your lights on and off)?

AndrewS avatar

There’s now a discussion about these over on the forums:
http://www.raspberrypi.org/forums/viewtopic.php?f=37&t=80755

Chase avatar

HELP! Can you get US style plugs that are compatible with this board?

jordan avatar

I second this comment. Is there a US option (from this or any other retailer) available?

Nat avatar

On reading your article I immediately ordered the starter kit.

I just published a little web app over on github I wrote to control my appliances from my phone :)

Robert Hewitt avatar

Hi,
Love the idea of your web app. When I try:
pip install bottle
I get
-bash: pip: command not found.
Any ideas?
Thx
Bob

Ben Nuttall avatar

sudo apt-get install python-pip

Amir Khan avatar

Excellent write up :) I will buy some of these. I want to connect a light sensor and a temperature sensor too possibly. These would connect via gpio ports too I am guessing (I’m a total newbie). If I use the energenie board will I still be able to connect these additional sensors?

haider avatar

i wanna make a home automation system by using pi. anyone have any idea?

Lachlan avatar

I thought this was really cool, but they don’t seem to have support for or ship to New Zealand. Wish it was available :/

Bob avatar

Hi,
trying to get going with this but I keep getting:
./ENER002.py: 2: ./ENER002.py: import: not found
./ENER002.py: 3: ./ENER002.py: import: not found
./ENER002.py: 6: ./ENER002.py: Syntax error: word unexpected (expecting “)”)
for the Energise published program. Any ideas?
I’ve installed all the python stuff and am running it as su in my home folder (pi)?
Any help gratefully received.

Robert Hewitt avatar

Sorry, all working now. Had a bad brain day.

Comments are closed