This is the eighth in a series of blog posts about researching and rewiring Christmas lights to work with Arduino devices.

In the last post on the Home Collection lights, I created a Ruby gem to run on a Raspberry Pi that can control the lights via the command line. The next step was to create a small web server that allows control from a web browser. Here is a draft of what the control page could look like:

Web Interface Sketch on Paper

This doesn’t need to be fancy with AJAX and tons of client-side libraries, even plain HTML forms should do the job. To that end, I created web-pi-lights-control: A Ruby Sinatra server that provides a bare-bones interface to pi-lights-control.

Web Interface on iOS

It’s hideous, and mildly charming. It has huge touch targets. It works. Here is a preview of the page, if you’re curious.

The repo is up on GitHub, with instructions on setting it up. It is meant to run on a Raspberry Pi, although you can preview the site on other platforms as the GPIO controls have been mocked out on those platforms.

There is one other thing to do: automatically start and stop the lights so I don’t forget to turn them off. To do so I created a new cron.d file: /etc/cron.d/xmas-lights with the following contents:

01 17 * * * root /bin/bash -l -c "/usr/local/bin/pi-lights-control -p 12 on"
58 23 * * * root /bin/bash -l -c "/usr/local/bin/pi-lights-control -p 12 off"
59 23 * * * root /bin/bash -l -c "/usr/local/bin/pi-lights-control -p 12 off"

This turns the lights on at 1701 local time, just after sunset. Then the lights are turned off at 2358 and a second attempt is made at 2359, in case the first command didn’t work for some reason.

The only issue I have is that sometimes only one of two light strings receive the “on” or “off” commands. I need to adjust the transmitter antenna on the Raspberry Pi to compensate, although adding an actual metal antenna would be more effective. Next year, perhaps.