A while ago I bought me a Raspberry Pi ('RPI' from now on). It lies behind the televisionset in the living room, connected using an HDMI cable.
On it, I installed a light version of SysopView (not yet released). I needed to create a special light version of SysopView as the RPI does not have the full OpenGL implementation and is somewhat slow when it comes to decoding (m)jpeg webcam streams (I could get to do 4 frames per second for a Jpeg-"stream" from a Dericom m205w).
Here it shows a couple of RSS feeds, the total power usage of my home (retrieved from a Flukso), the last seen bluetooth device in the street in front of my house and some other interesting statistics.
Last week I got a nice little gadget from my collegue Remco: a small white box looking like an envelope. It is connected via USB and has 3 LED lights in it. You can then using a simple Python script (which can be found here) switch on and off its lights. Of course the package included a CD with ready made software, but there's no fun in using that.
This device can be bought at dealextreme.
Here's the device installed in my livingroom, underneath the television:
This picture was taken mid-day. In the evening when it is somewhat darker, it looks better.
Picture taken at night
And now what? Deciding what to do with required a long hard brainstorm session. I decided to create something on the RPI, something lightweight, that would capture network-messages and then change the color of the device. No blinking, just change the color or it might distract me from seeing what's on television.
As the script to toggle the colors was in Python, I decided to continue that path. And I'm glad I did: Python is so much easier to quickly "hack" a fully working program than Perl with its tons of weird variable addressing modes!
The following couple lines of code are to create a network-listener which receives UDP messages on port 5000. There's no protection against any hacks or so because I don't think that's required as this RPI is on a LAN not reachable from the internet.
The mini-script below is stored in /usr/local/bin so that everything in the system can execute it. For example: /usr/local/bin/send_udp_message 1. This will send number '1' to the UDP receiver shown above. When the UDP receiver receives a message, it takes the value from the message and switches the mailbox to show the color with that number. The device has 7 colors, for example 1 is green, 2 is red upto 7 which is white.
This script sends a UDP message to the RPI:
With a few lines of code all these messages are stored in an sqlite3 database:
No RPI project is complete without a build-in webserver! And again: only a few lines of code!
Now that the infrastructure is in place: let's trigger the lights!
All kinds of events can be used to trigger the lights. My (rather busy) webserver has a global php-include file which sends a UDP message to the RPI:
Using procmail each incoming mail triggers a light:
Also my IRC-bot triggers the light when someone says something or says something to me, people walking/driving down the street where I live when devices on them with bluetooth enabled trigger a flash, jobs inserted in trustedtimestamping.com trigger a flash: as you can imagine it is a cacophony of light!