The system has three elements:
- A regular plugstrip.
- A Fonera.
- A box with an optocoupled relay board, a 5V power source and some LEDs.
In this figure you can see a schematic representation of the elements and the connections among them (clic to make it bigger). The status LEDs and the relay optocouplers have been omitted.
The power entering the plugstrip is routed to the gray box only when the power switch is on. Then it's routed to the 5V power source (that powers the Fonera) and to the relay switches. When the relay switches are closed, power is routed to the sockets in the plugstrip, and devices plugged to these sockets are powered.
Each relay switch is independently controlled by a GPIO pin inside the Fonera. So the Fonera controls when a socket has power or not. A CGI inside the Fonera is in charge of rendering a web page that serves as a control panel for each socket in the plugstrip. The user can interact with this web page, and the CGI will power ON/OFF the sockets accordingly.
The Fonera is a closed platform, so to be able to control the GPIO pins and install software inside it, you have to hack it first. You can find instructions here. Once hacked, it's not necessary, but it's recommended to install OpenWRT, a GNU+Linux distro designed mainly for routers and other similar small systems. Info about OpenWRT and the installation process, here.
And finally we get to code something. I have created an init script that configures the GPIO pins and the default status of the sockets. I have also coded a CGI in Linux shell script that renders the control panel and controls the sockets in the plugstrip. Both of them share a configuration file (/etc/plugstrip.conf) that can be used to map GPIO pins to the sockets, to change the text labels in the web page, to set the default socket status, etc. Grab the sources and installation instructions (including how to set up basic HTTP authentication) here.
This project is almost finished, but I want to add a new feature: the ability to configure time trigged events to power ON/OFF the sockets. I'll update this entry if I get some time to code it.