Trivial Thoughts
Thoughts and discussion on programming projects using the Python language.


Python Sites of Note
Software Development



Recent Posts
 6/15/04
 5/16/04
 5/13/04
 5/10/04
 5/8/04
 5/5/04
 5/5/04
 4/23/04
 9/23/03
 9/22/03
 9/12/03
 9/11/03
 8/21/03
 7/21/03
 7/17/03
 7/10/03
 7/7/03
 7/1/03
 6/26/03
 6/25/03
 6/18/03
 6/15/03
 6/2/03
 5/28/03


Subscribe to "Trivial Thoughts" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.
 

 

Monday, May 10, 2004
 

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  comment []    


Click here to visit the Radio UserLand website. © Copyright 2004 Michael Kent.
Last update: 6/15/2004; 4:14:00 PM.
This theme is based on the SoundWaves (blue) Manila theme.
May 2004
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Apr   Jun

Previous/Next