What is Home Automation?

Whether you think about it or not, there is a lot going around in our homes, even when we are not there. If your home is anything like mine, you have a furnace to keep it warm, a water heater to provide hot water, a telephone answering machine, smoke detectors, and maybe even a burgler alarm system. No matter what you think of these systems, they run on auto pilot most of the time.

When we are home, the number of things which perform tasks for us around the house increases. You check on the weather, you read the news and/or the funnies, you listen to music and/or watch TV, etcetera, etcetera. So the question becomes, what can we do to automate some of these tasks, if we are interested.

Incase you have not guessed, I am a classic DIY (Do It Yourself) person. But I have learned to take some of these things further by bringing automation into the picture. Now before you start thinging of the Jetsons, those of you old enough to remember that program. What we are going to discusss today is Far below that level of sophistication. Although it is tempting to imagine.

One area where automation can be a big plus is in conserving energy. This is where I would love to see more work done. As an example, imagine if you house was smart enough to close blinds, or open windows based on the weather inside and outside your house. Imagine how much oil you could save, if your house only heated rooms when there was someone there instead of all the time. Or if you have kids, like I do, and you could turn off the lights when everyone left the house in the morning.

X-10 Control

Lets start by talking about one type of automation control which I am familiar with. This is the X10 system. Here is an explaination from Smarthome.com on what X10 is all about.

X10 is a communications “language” that allows compatible products to talk to each other using the existing electrical wiring in the home. Most X10 compatible products are very affordable and the fact that they talk over existing wires in your home means that no costly rewiring is necessary. Installation is simple, a transmitter plugs (or wires) in at one location in the home and sends its control signal (on, off, dim, bright, etc.) to a receiver which plugs (or wires) into another location in the home.

X10 is Simple, Press a Button on the Transmitter and the Signal is Sent over the Home’s Wiring to a Receiver

Using simple dials or buttons you assign each product with one of up to 256 addresses. If you wish two products to go on and off together you can set them to the same address or use scene addresses on many advanced products. All X10 compatible products can be freely mixed and matched - so use Smarthome products together with X10, Leviton, Stanley, IBM, JDS, ACT, Homepro, etc.

explaination of X10

So How do you use this type of automation in a home? Well I use it initially to turn on and off lights. I have 3 lights on controllers. One next to the front door, one at the end of the driverway, and one in my living room. Two of these use the simple X10 boxes I have here. The front porch light has an X10 light switch. It just looks like a push button switch to turn the lights on and off.

I bet some of you are thinking why not just use a simple plug in clock timer. Well I could, but where this automation starts to really work is when I start adding things for comfort around the house. For example, my middle son was having trouble falling asleep at night. Well he had this lava lamp that he liked to watch which helped him fall asleep. So I added code to my system to turn on his lava light at night before bed during the week. It would then turn off the light about midnight when he is normally. You notice I said during the week, on the weekends he likes to stay up later so I don’t run it during the weekend.

Another time light control comes in handy is when we go away. I have a few boxes, I set up on light around the house. I then plug them into lights and one into a simple radio. This allows me to randomly turn lights on and of during the evening as though people were home. I even run the radio remotely just to give the place a lived in look.

Where to start with X-10

Pictured above is the type of X10 kit I purchased from Smart Home which allowed me to try this out. The kit is basically has a computer interface module, and a hand held remote to control the lamp module. This gives you the ability to use the remote to turn on or off a light. Additionally you can use the computer software to turn the light on or off.

This simple system will let you see how X10 can be used around your house. Yes I know controlling one light seems a bit simple, but we are only talking about an initial trial system. Of course you probably noticed that there is a computer interface so, guess where Linux comes into the picture?

Before we move on though, I should point out that there are many more things X10 can do than just turn on and off lights. There are modules which are motion detectors, thermostats, and video camera, to name a few. The X10 system is interesting because it uses the Electrical wiring in your home. This means that it does not need separate wiring and is not wireless so it can not be tapped into by someone with a wireless laptop.

MisterHouse provides Control

Since we have already talked about using X10 to control lights and applicances in the house, it is time to discuss the software which I use. The program I found is called MisterHouse.

This is a automation control program written in Perl. It is interesting in that it can be used on windows as well as Linux. Here is it’s description of itself.

MisterHouse is an open source home automation program. It’s fun, it’s free, and it’s entirely geeky. Written in Perl, it fires events based on time, web, socket, voice, and serial data. It currently runs on Windows 95/98/NT/2k/XP and on most Unix based platforms, including Linux and Mac OSX.


Before we discuss the application, lets have a look at what the web interface for Misterhouse looks like on my server.

This application comes with it’s own web interface so this is not one I built. Now there is a LOT more on this web page than I take advantage of, but I will discuss the parts I have been using.

My primary use for this software is control of X10 equipment and monitoring of my Alarm system. Lets see how to configure a system to talk to some X10 modules.

    # Configure this module for X10 commands

    use lib "$Pgm_Root/lib/" ;

    use X10_Items;

    # First establish the relationship of names to X-10 ID's
    $tree = new X10_Appliance( 'K9' );

    # Turn the tree on and off 
    print_log "$Date_Now at $Time_Now - turning on Christmas Tree." if time_now "06:20 AM" ;
    set $tree ON if time_now "06:20 AM" ;
    print_log "$Date_Now at $Time_Now - turning off Christmas Tree." if time_now "10:30 PM" ;
    set $tree OFF  if time_now "10:30 PM" ;

Lets examine this code module to see how it works. First of all, the entire program is written in Perl, so this is perl code basically. Anything after a # is a comment, anything after a $ is a variable. In perl the use specifies something to be included.

In this code I start by assigning the variable $tree to an X10_Appliance with the address of K9. Next I specify what the log file will say using the routine print_log. Then I perform the operation with the set command followed by the variable, the state, and the parameters which cause it to happen.

    $myalarm = new DSC_Alarm;
    my $warning_sent = 0;

    if (my $log = said $DSC_Alarm) {
       print_log "DSC_Alarm.pl $Loop_Count said = $log\n";

Again the code for the alarm system is mostly used to log messages about what is happening with the system. Basically, I set a variable to represent the alarm input. Next I write to the log any information if I get some input which is an alarm. Not terribly sophisticated, but it allows me to use the computer to keep a record of what is happening when an alarm is triggered. Yes there is a further part which sends an SMS message to my cell phone but I did not include that part.

Music around the Home

Some of you might remember a discussion we had a while ago about how to use your Linux server and a remote music player. This was discussed in the lesson: Linux the music server for your home

I am not going to repeat what was said there, but only give a couple of updates on the information in that lesson.

In the last year or so I have found another interesting web site for listening and downloading music. They work slightly differently that emusic did. You can listen to their whole collection online via streaming music. Then if you like the music you can buy it from them for you permanent collection. Here is how they describe themselves.

We’re a record label. But we’re not evil.

We call it “try before you buy.” It’s the shareware model applied to music. Listen to 326 complete MP3 albums we’ve picked (not 30 second snippets).

We let the music sell itself, because we think that’s the best way to get you excited by it.

Our selection is intentionally small: we never waste your time with mediocre music.

If you like what you hear, download an album for as little as $5 (you pick the price), or buy a real CD, or license our music for commercial use.

Artists keep half of every purchase. And unlike most record labels, our artists keep all the rights to their music.

No major label connections and no venture capital.

We are not evil.


If you have XMMS or Zinf you can download a playlist from them and then the music will be streamed to your computer as it is played. This is an interesting way to try the different types of music they have available. I recommend you give them a try, I find I listen to them quite a bit at work.

Another Music Player

This is an interesting addition to your music system. It works much line the Barix box did before, but it is cheaper, has more flexability, and still works on Linux. Here is how they describe themselves.

Squeezebox is revolutionary. It streams your music from your computer to your digital stereo over your wireless or ethernet network?without any loss of sound quality. You now have lightning-fast access to any song in your digital music collection, anywhere in your home.

The Squeezebox player is incredibly easy to set up and use. It takes just a few minutes to install: simply load SlimServer, our powerful and free Open Source software, onto your computer and connect the player to your network. Squeezebox automatically configures itself and is ready to use.

Squeezebox is a complete and elegant solution that takes advantage of the power and capacity of your existing computer. As a result, Squeezebox places no limit to the size of your music library.

Squeezebox’s user-friendly interface allows you to browse quickly through your whole music collection via remote control or web browser. Its large, built-in fluorescent display is bright and easy to read. Thanks to its small form factor, you can place Squeezebox in your stereo cabinet, on a shelf or on your bedside table.

Digital and analog RCA outputs connect Squeezebox to your home theater, stereo receiver, or amplified speakers. And when you install multiple players, they can play independently or in sync for whole-house audio.

Read more about the Squeezebox hardware, the SlimServer software, read the reviews, and order Squeezebox from our secure server.

Squeezebox overview.

To give you an idea how this device works, here is a diagram which shows how to hook it up.

Now to be honest, I have not tried one of these, but I have read some good reviews of them. There are two points I thought I would make about them. One is that the software they use is Open Source. So the neither the firmware in the player, nor the software in the server will every vanish since the source code is available. Secondly, the company is active in promoting other people to discuss and help modify the software. This means that they provide resources for outside developers to work with their code. There is getting to be a growing list of companies who are learning not only to live with Open Source software, they are actively participating in it. This strengthens both the company and the open source community.

Portable Music Player

For those of you who want to have your music on the go, I would suggest you have a look at the Neuros. This player has interchangable backs for different storage capacities. This means that you can have one back for running, or walking which is light and virtually shock proof. And a larger backpack to take with you in the car or vacation.

I know there are a lot of mp3 players on the market but a few issues drew me to the neuros. First, as with the squeezebox, the code was released to open source. This means again that it can not go away. Another reason I like the neuros is that it plays many differnet formats of music.

I suppose the best reason for using the Neuros is the support it has under Linux. If you are familiar with portable music players, you are aware that the key piece of any player is the software that interfaces it to your computer. With Neuros they supply a .NET sync manager, which initially turned me off to them. Then I found out that they had released the specs so an outside group had created a sync manager in Java. This sync manager is able to work in Windows, Linux, Mac or other operating systems for which java has been compiled. So with that in mind I went ahead with the Neuros.

How to convert CD’s to MP3 files.

If you have a collection of music CD’s around your house and you want to move to something like Squeezebox above, what do you do?

The answer is simply, you rip them. The process of ripping a music CD and converting it to an mp3 file is easily done under Linux. The most common way I do it is to use the program grip. Here are some instructions from a web site to show you how to do it.

​1. If you want to preview any tracks before deciding to rip them, you can listen to the CD from grip.

​2. Next, select the tracks you want to rip by right clicking next to the tracks (a check mark will appear).

​3. Next, go to the Rip tab and click Rip+Encode.

​4. Watch the progress with the status bars at the bottom. Since grip is multitasking, it can rip one tune while encoding another.

​5. Grip stores your tunes by default under ~/mp3/artist/title/ Of course, you can change where it stores ripped files.

CD Ripping

I don’t know if you can get much simplier for running a program. As a rule of thumb, the mp3 files run about 1 megabyte per minute of play time. So a 20 minute song will be about 20 megs in size.

Now there are other formats that can be used to save the music files in. One of the most common after mp3 is called ogg.

Ogg Vorbis

Ogg Vorbis is a new audio compression format. It is roughly comparable to other formats used to store and play digital music, such as MP3, VQF, AAC, and other digital audio formats. It is different from these other formats because it is completely free, open, and unpatented.

Ogg Vorbis General FAQ

I mention this format for a couple of reasons. First it is an open source encoding scheme. This means that you can not get sued for using it. Secondly, they are the authors of the program cdparanoia which is the tool that captures the music off a CD and saves it on your hard drive. And thirdly they support both icecast a streaming music server, and shoutcast a web site for finding online music.

Now some of you are going to ask, or I guess I would hope you would ask, why use ogg instead of mp3? The answer is that mp3 is a patented encoding technology, and should it become popular enough, they might decide to start charging for it. The other side of the coin is that the makers of the mp3 encoding technique have not incentive to improve it. But the makers of ogg do, since it is another Open Source project. By the way Grip supports ogg encoding as well as mp3.

The question is how well is ogg supported by the hardware. Well the answer is that it is getting better and better support. Squeezebox supports it, as does the Neuros portable player. It works under Zinf and Xmms so there are players available for it.

RSS News.

Let’s start off by seeing how many of you know what RSS is?

Really Simple Syndication (RSS) is a lightweight XML format designed for sharing headlines and other Web content. Think of it as a distributable “What’s New” for your site. Originated by UserLand in 1997 and subsequently used by Netscape to fill channels for Netcenter, RSS has evolved into a popular means of sharing content between sites (including the BBC, CNET, CNN, Disney, Forbes, Motley Fool, Wired, Red Herring, Salon, Slashdot, ZDNet, and more). RSS solves myriad problems webmasters commonly face, such as increasing traffic, and gathering and distributing news. RSS can also be the basis for additional content distribution services.

WebRef Intro to RSS

RSS is a method for web sites to publish a summary of their headlines in a format that is easy to scan. This means that you can download just the summaries, select what sounds interesting to you, and if you are interested, click on a link which takes you to the story.

So if you were familiar with RSS, you could always download an RSS viewer, and use it to view your news. But we are here tonight to talk about automation. So what I have in mind is:

  • Explore how an RSS feed looks at the source level.

  • Create a simple program to display the information

  • Use the simple program as input to a news scanner.

  • Automate the process to keep you informed of breaking news.

The point in doing it this way is two fold. First I want you to see how you can use the computer to take information you often see on a web browser and understand something about it’s XML structure. Secondly I want you to see how you can use the computer to create a service that a few years ago businesses were selling to customers.

The big deal with automation is giving the computer a repetative task, and letting it work for you. One of the interesting aspects of computers to me is how they can do a number of mundane tasks well. If we look around the computer is showing up in more and more places. Dishwashers, Microwave ovens, music players, just to name a few. Why is this? Quite simply it stems from the fact that computers are cheap, flexable, and much more reliable than their clockwork predicestors.

Any way, before I get too far afield, lets have a look at a Raw RSS feed.

RSS Source Code

Here is a small RSS feed, lets go over it’s parts so you understand how it works. This is from RSS version 0.90

<?xml version="1.0" encoding="iso-8859-1" ?>
   <rss version="2.0">
      <title>NYT > Science</title>
        <description>Find breaking news, science news & multimedia on biology, space, the environment, health, NASA, weather, drugs, heart disease, cancer, AIDS, mental health and animals.</description>
        <copyright>Copyright 2005 The New York Times Company</copyright>
        <lastBuildDate>Mon, 14 Feb 2005 03:00:01 EST</lastBuildDate>
            <title>NYT > Science</title>
            <title>State Dept. Relaxes Visa Rules for Some Scientists and Students</title>
            <description>The State Department has extended the amount of time many students and scientists can remain in the country before renewing their security clearances.</description>
            <author>By KRISTEN A. LEE</author>
            <pubDate>Mon, 14 Feb 2005 00:00:00 EDT</pubDate>
            <guid isPermaLink="false">http://www.nytimes.com/2005/02/14/politics/14visa.html</guid>
            <title>In Computer Years, Apollo Replica's an Antique</title>
            <description>Late last year, John Pultorak, of Highlands Ranch, Colo., completed a four-year project, a reconstruction of the Apollo lunar mission's computer system.</description>
            <author>By CYRUS FARIVAR</author>
            <pubDate>Thu, 10 Feb 2005 00:00:00 EDT</pubDate>
            <guid isPermaLink="false">http://www.nytimes.com/2005/02/10/technology/circuits/10apol.html</guid>

The first part of this is the header between <?xml> and the tag <item> . In particular I want you to look at the information between <item> and </item>

Within these item tags there are three tags we are interested in: <title>, <link>, and <description> These are the tags we will be using later.

How to Parse RSS in Perl

Lets have a look at a program written in Perl to capture input from an RSS feed and display the results on the command line.

First I want you to see a VERY simple program I came across for parsing a slashdot.org RSS feed.



    curl --silent "$url" | grep -E '(title>|description>)' | \
      sed -n '4,$p' | \
      sed -e 's/<title>//' -e 's/<\/title>//' -e 's/<description>/   /' \
          -e 's/<\/description>//' | \
      head -20 | fmt

For those of you who would like to read more about the above script, you can find the article at: Can I track an RSS feed with a shell script?

The script goes to the URL, downloads the feed, captures only the lines title and description, Strips off the XML tags, and spits out the text.

Here is what the output looks like. At least when I ran it, remember this feed is constantly changing.

    ChoicePoint Data Stolen By Imposters
       swight1701 writes "Criminals posing as legitimate businesses have
       accessed critical personal data stored by ChoicePoint Inc., a firm
       that maintains databases of background information on virtually every
       U.S. citizen. The incident involves a wide swath of consumer data,
       including names, addresses, Social Security numbers, credit reports
       and other information. ChoicePoint notified between 30,000 and 35,000
       consumers in California that their personal data may have been accessed
       by "unauthorized third parties." No obvious notice appears to be on
       their website."
    Vonage Says VoIP Traffic Blocked By Providers
       Anonymouse writes "Advanced IP Pipeline reports that Vonage has filed
       numerous complaints with the FCC over their VoIP traffic being blocked
       by major providers, something providers have long worried about but
       had not yet been seen 'in the wild.' Analysts expect the issue of
       network neutrality (or network discrimination) is only going to get
       larger as the bell and cable companies expand their VoIP efforts and
       bump heads with smaller providers."

When I first came across the article with this code in it I was fascinated. The solution is so simple and elegent. We could use this script as is, but I thought I would show you what I consider a better one written in Perl.

    #!/usr/bin/perl -w

    use LWP::Simple;

    # Channels of RSS available at: http://www.syndic8.com/
    # Get the feed
    my $feed = get "http://slashdot.org/index.rss";

    # Parse the content:
    use XML::RSS;
    my $rss = new XML::RSS;
    foreach my $item (@{$rss->{'items'}}) {
       print "title: $item->{'title'}\n";
       print "link: $item->{'link'}\n";
       print "description: $item->{'description'}\n\n";

This program is rather short because much of the work is being done by two Perl modules. These are the library modules, LWP::Simple and XML::RSS. The program first downloads the XML into the variable $feed. It then calls the function parse to convert the input into it’s individual items. Finally it prints the information for title, link and description with a header.

Lets take a look at the same information from Slashdot as it would come out of this second program.

    title: ChoicePoint Data Stolen By Imposters
    link: http://yro.slashdot.org/article.pl?sid=05/02/15/0128211&from=rss
    description: swight1701 writes "Criminals posing as legitimate businesses have accessed critical personal data stored by ChoicePoint Inc., a firm that maintains databases of background information on virtually every U.S. citizen. The incident involves a wide swath of consumer data, including names, addresses, Social Security numbers, credit reports and other information. ChoicePoint notified between 30,000 and 35,000 consumers in California that their personal data may have been accessed by "unauthorized third parties." No obvious notice appears to be on their website."

    title: Vonage Says VoIP Traffic Blocked By Providers
    link: http://yro.slashdot.org/article.pl?sid=05/02/14/2352254&from=rss
    description: Anonymouse writes "Advanced IP Pipeline reports that Vonage has filed numerous complaints with the FCC over their VoIP traffic being blocked by major providers, something providers have long worried about but had not yet been seen 'in the wild.' Analysts expect the issue of network neutrality (or network discrimination) is only going to get larger as the bell and cable companies expand their VoIP efforts and bump heads with smaller providers."

We now have the data in a format we can easily work with. One thing to notice is that each line of data is on a single line. Makes a little strange in an HTML page, but from a script processing point of view it simplifies things.

Let suppose you are interested in being alerted when there is more news about the SCO vs IBM law suit. We could simply take the output of the program and pass it through a search tool like this: rss-perl.pl | grep -i “IBM” | grep -i “SCO”. This would not display anything unless one line contained both the character strings IBM and SCO.

So lets see if we could accomplish the same thing with the perl script above. We will search for the words only in the description. If we find it we will output the whole listing.

    #!/usr/bin/perl -w

    use LWP::Simple;

    # Channels of RSS available at: http://www.syndic8.com/
    # Get the feed
    my $feed = get "http://slashdot.org/index.rss";

    # Parse the content:
    use XML::RSS;
    my $rss = new XML::RSS;
    foreach my $item (@{$rss->{'items'}}) {
           if ( $item->{'description'} =~ /IBM.*SCO|SCO.*IBM/i ) {
            print "title: $item->{'title'}\n";
            print "link: $item->{'link'}\n";
            print "description: $item->{'description'}\n\n";

Now we have given the RSS parser the added ability to check for a specific string. OK, that is nice. Now lets really see if we can make this into something useful.

Lets suppose you have a verizon cell phone. I will assume your cell phone number is (914) 555-1212. Lets see if we can make this script send an SMS message to your cell phone if it detects a string in Slashdot’s RSS feed containing the words IBM and SCO in the same description. One key concept here is that verizon cell phones have an email address. For the above phone it’s email address is 9145551212@vtext.com. So we could use this information to modify our perl script above.

    #!/usr/bin/perl -w

    use LWP::Simple;
    use XML::RSS;
        use Mail::Mailer;

    # Channels of RSS available at: http://www.syndic8.com/
    # Get the feed
    my $feed = get "http://slashdot.org/index.rss";

    # Parse the content:
    my $rss = new XML::RSS;
    foreach my $item (@{$rss->{'items'}}) {
           if ( $item->{'description'} =~ /IBM.*SCO|SCO.*IBM/i ) {
                $mailer = Mail::Mailer->new("sendmail");
                $mailer->open( 'From'    => '<gnat@frii.com>',
                               'To'      => '<9145551212@vtext.com>',
                               'Subject' => 'IBM vs SCO' );
                print $mailer "Article titled \"$item->{'title'}\"
                         available at http://slashdot.org";

You now have a personal news parsing program. Lets call this script find-sco-news.pl. If you wanted this to run every 30 minutes between 9:00 AM and 5:00 PM weekdays, you could enter the following line in your crontab file: 0,30 9-17 * * 1-5 $HOME/find-sco-news.pl >/dev/null

Finally I will provide a couple of references for how to parse RSS feeds using perl.

  • An introduction to RSS news feeds RDF Site Summary (RSS) is catching on as one of the most widely used XML formats on the Web. Find out how to create and use RSS files and learn what they can do for you. See why companies like Netscape, Userland, and Moreover use RSS to distribute and syndicate article summaries and headlines. This article includes sample code that demonstrates elements of an RSS file, plus a Perl example using the module XML::RSS.

  • RSS and You RSS is Born

Written by John F. Moore

Last Revised: Wed Nov 2 15:16:32 EDT 2016

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
HTML5 Powered with CSS3 / Styling, and Semantics