Tuesday 21 May 2013

Tellstick on Raspberry Pi to control Maplin(UK) remote lights

This is a short post just to describe the setup of the Maplin (UK) lamp remote control switches so that you can control them using a Raspberry Pi.

The lamp controls come in packs of three or you can buy them individually.


They come with a remote, which from the back you can see uses 433.92 MHz.


However, to control these from the Raspberry Pi, I obtained a TellStick for about £20 on ebay. 

To get the TellStick set up on the Pi I followed this guide and I'm not going to repeat it here as it covers all the key steps.

The part that you need to know for these particular lamp controllers is when you come to the 'Configure Receivers' section. This is where you edit to configuration files for the telldusd service.

The file to edit is:

/etc/tellstick.conf

There are a number of different protocols that can be used for different brands of light switches. In this case, the configuration that worked for me was the risingsun protocol. 

user = "nobody"
group = "plugdev"
ignoreControllerConfirmation = "false"
device {
  id = 3
  name = "Living room light 3"
  protocol = "risingsun"
  model = "codeswitch"
  parameters {
    house = "4"
    unit = "3"
  }
}


The "name" can be defined by you. The "protocol" needs to be risingsun, "model" needs to be codeswitch, and the parameters for "house" and "unit" need to match what you set on the remote and the switches. In the diagram above on the remote you can see that the "house" is set to 4 ( IV ) and the buttons on the reverse of the remote provide on/off switches for each unit (1-4). In the picture below of an individual  switch, you can see house is also set to 4 ( IV ) and this particular unit is number 3. 


Once you save the configuration file, you need to remember to restart the service using:

sudo service telldusd restart

To actually control the lights you use:

tdtool --on 3
tdtool --off 3

... where the number following the on or off argument matches the "id" that you set in the configuration file. In the above example it was defined to be 3. 

You can add multiple units to the configuration file by duplicating the device section, making sure you add a new id and modify the "house" and "unit" values to match those on your switch. 

It is then fairly easy to create a simple web server to generate an interface and make calls to the tdtool in order to control the lights from a computer or smartphone.