I recently read an article in the German computer magazine c’t about controlling simple plugin switches via pilightPilight is a small piece of software with a built in web-based GUI that can control a variety of devices. This intrigued me quite a bit since I still had a cheap Brennstuhl RCS 1000 N comfort lying around here, which is exactly the switch set used in the article and is apparently supported quite well by pilight.

So, of course, I sat down and ordered a GPIO Full Kit from the pilight shop as well as a DHT22/AMS2302 temperature and humidity sensor from Amazon, plus some resistors, cables and my very first bread board.

The net result of the assembly, following the instructions for wiring up the sender/receiver and these instruction for wiring up the AMs2302, looks a bit messy, but works splendidly :)

RaspberryPi wired to breadboard

Note that I intentionally left away the wiring for firmware updates because I wanted it to be as simple as possible for this test setup.

After finishing the hardware setup I went at the software part, which is quite straight forward.

sudo su
echo "deb http://apt.pilight.org/ stable main" > /etc/apt/sources.list.d/pilight.list
wget -O - http://apt.pilight.org/pilight.key | apt-key add -
apt-get update
apt-get install pilight
service pilight start

That is it, basically. You can now reach (an empty) pilight GUI on http://<yourhost>:5001.

Figuring out the configuration you need is also fairly trivial. Simply start pilight-receive as root and push the button on your remote, if you have one (my RCS 1000 N set came with one).

sudo su
pilight-receive

You will see whatever is sent by the remote in your console. For my Brennstuhl switches I saw the following piece of code - next to some others which we do not need to care about too much now. According to the c’t article they are backwards compatibility measure.

{
 "message": {
   "systemcode": 17,
   "unitcode": 2,
   "state": "on"
 },
 "origin": "receiver",
 "protocol": "elro_800_switch",
 "uuid": "0000-74-da-38-0091fa",
 "repeats": 1
}

The interesting parts are:

  • protocol: we need this to be able to tell pilight how to talk to devices
  • systemcode: to tell pilight the system code
  • unitcode: so pilight knows which device to talk to

With that information we can now create a config.json (/etc/pilight/config.json). The pilight wiki also explains in some detail how to do this for this kind of switch.

{
    "devices" : {
        "Brennstuhl_A" : {
            "protocol" : ["elro_800_switch"],
            "id" : [{
                    "systemcode" : 17,
                    "unitcode" : 1
                }
            ],
            "state" : "off"
        },
        "temperature" : {
            "protocol" : ["dht22"],
            "id" : [{
                    "gpio" : 7
                }
            ],
            "humidity" : 5.2,
            "temperature" : 1.7,
            "poll-interval" : 5
        }
    },
    "rules" : {},
    "gui" : {
        "Brennstuhl_A" : {
            "name" : "Brennstuhl A",
            "group" : ["Test"],
            "media" : ["all"],
            "readonly" : 0
        },
        "temperature" : {
            "name" : "Temperature Sensor",
            "group" : ["Test"],
            "media" : ["all"]
        }
    },
    "settings" : {
        "log-level" : 6,
        "pid-file" : "/var/run/pilight.pid",
        "log-file" : "/var/log/pilight.log",
        "webserver-enable" : 1,
        "webserver-root" : "/usr/local/share/pilight/",
        "webserver-http-port" : 5001,
        "webserver-cache" : 1
    },
    "hardware" : {
        "433gpio" : {
            "sender" : 0,
            "receiver" : 1
        }
    },
    "registry" : {
        "pilight" : {
            "version" : {
                "current" : "7.0"
            }
        }
    }
}

Note the settings in devices and in GUI. You will also note that I already added the AM2303 sensor in the same way, using the DHT22 protocol. Also note the GPIO pin. If you follow the instructions I linked to earlier you will also have connected your AM2303 to GPIO pin 7, otherwise adjust as necessary (following the wiringpi scheme). Detailed instruction to configure that sensor are found in the pilight wiki.

And that’s that. Restart pilight and you should be good to go.

pilight

This now gives me a set of cheap switches I can play with. In a next step I am going to try and see if I can attach pilight to Home Assistant.

Leave a comment