Python and X10 Home Automation, Part 1.1
I wrote previously about Project WiSH, which gives you access to X10 computer interface controllers via device drivers. I also wrote about uprading my home system to Mandrake 10. Mandrake 10 has the new 2.6 kernel. Sadly, WiSH does not (yet) work with that kernel. So, I had to find an alternative.
From googling around, and comments from readers, I found the 'bottlerocket' software, for accessing the CM-17a 'Firecracker' X10 computer interface. This gives you a simple command-line program for issuing X10 commands via the CM-17a. It lacks the ability to watch for an X10 command coming in from a sensor, or querying the status of a status-capable X10 controller, so it's not a complete replacement for WiSH (but that functionality is not supported by the CM-17a anyway, so you don't get it with WiSH either), but it will do me for now.
When you are doing time-based automation under Linux, it makes sense to leverage Linux's built-in abilities. The 'cron' system lets you schedule tasks for execution based on date/time, either periodically on a period of your choosing, or at one particular data/time. The 'at' command lets you schedule a command for execution at one particular time in the furture. For example, typing the following command at the Linux command-line prompt will schedule the running of the command '/usr/local/bin/br a2 on' for 8:00pm today ('br' is the bottlerocket command): at 8:00pm today <<EOF /usr/local/bin/br a2 on EOF
To test the usability of 'at' for X10 home automation, I wrote a simple shell script that issues two 'at' commands -- one to turn on my driveway lights at dusk, and one to turn them off at 10:30pm. I then set up a 'cron' job to run this shell script ever day at 00:05 in the morning. Thus, each day the two 'at' jobs are reissued for the current day. It's necessary to reissue the commands each day because an 'at' job is a one-shot deal, while 'cron' is what you use to run commands at regular intervals.
This system of 'at', shell scripts, and 'cron' works fine, and demonstrates the simplest Linux/X10 home automation setup. For your needs, this may be all that you require. For me, this was just baby's first steps.
What I want is a more capable solution to the X10 home automation problem. I want to be able to schedule both periodic and one-time events. I want a system that understands how to deal with times like 'sunset' and 'sunrise'. I want to be able to alias the X10 house/unit code that controls my driveway lights as 'driveway lights'. I want to be able to create macros that trigger multiple commands, so that I can execute macro 'wakeup', and have the commands sent to turn on the TV, the coffee maker, and the window blinds opener(insert images of George Jetson being ejected from bed like toast from a toaster). I want to have a web interface to all of this. And, of course, I want to do it all with Python.
Sure there are several other pre-existing Linux solutions for X10 home automation. For fun and learning, stay tuned as I put together my own solution using Python.
2:03:02 PM
|
|