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):
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(0) switch_off(0) # 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!