Stories about Software


Build Your Own Home Automation Server for Cheap

Most of the text for this post is lifted from the script of my Pluralsight course about home automation. If you’d like a free pass to Pluralsight to check it out, please email me at erik at daedtech. But whether you check out the course or not, I’m going to describe exactly what I bought to get going with a home automation setup for, all in, less than $100. In the rest of the course, I describe how I also created a compact, RESTful home automation server that you can send commands to from the language/platform of your choice.


I personally have been doing projects with home automation for some time now, and have experimented with a variety of different home automation technologies. I’ve settled on the following setup as an introduction to home automation. I’m going to be using a Raspberry Pi to make a REST endpoint for home automation commands, and the programming will be done in Python. By way of hardware, I’m going to show you how control a lamp using X10 brand devices.

I chose the Pi because its small form factor and affordable price make it an ideal candidate for your home automation controller that won’t break the bank or take up a lot of space. I chose the X10 brand for the hardware because it’s been around the longest and tends to be the least expensive, making it a good choice for new home automation enthusiasts. And finally, I chose Python because it is the lingua franca of the Pi, the language of the X10 driver I’ll be using, and a perfectly good language for building a REST server. I am historically a C#, Java and C++ programmer, but I’ve picked up enough Python for this course to make a working endpoint and to show you how to do the same. You’re going to need hardware specifics, so I’m going to list the hardware here that you’ll need as well as some potentially helpful peripherals.

The first category of hardware that you’re going to need is the Raspberry Pi and all of its accessories. The Pi itself is easy to order, but you may not realize that you’ll need some other stuff to get going. The most important thing is a mini SD card that will function as the Pi’s hard drive. It doesn’t come with one on board. Also important is a power supply for the Pi, but you can use any Android phone charger interchangeably. I’ve bought an extra one for each Pi I have because it’s rather annoying to have to cannibalize one of my phone chargers. You might also want to get a HDMI or DVI adapter if you plan to plug the Pi into a monitor while you work with it, assuming your monitor doesn’t have an HDMI port. The Pi’s only video output is HDMI. Also, bear in mind that the Pi is going to need to be on your local network. I’m assuming for the purposes here that you’ll be using a network cable and do not plan to cover getting wireless networking up and running on the Pi. The course was not specifically about the Pi, per se. For a deeper dive into its capabilities, you should check out Jon Flanders course, “Raspberry Pi for Developers.

Now for the X10 equipment. The first thing that you’re going to order is a part that is a wireless transceiver as well as an interface to a computer. To do this, it makes use of a USB cord. The reason I’ve chosen this particular unit is because there is a readily available driver for it and also because the Pi only has a USB connection and not the serial connection that other X10 computer interfaces use. I should note here that we will not, for the purposes of the course, be going the historical X10 route and sending signals over the home electrical. Here, everything will be wireless RF. And this particular part is going to receive signals that you send it from the Pi and transmit them to the other part that I’m about to cover.

The other X10 component that you’re going to need is a regular transceiver module, which, strangely, is around the same price as the computer interface transceiver. You are going to plug a lamp into this transceiver and it is going to receive the signals from the CM19A and turn its lamp on and off accordingly.

If you have none of these parts, the entire setup should cost you around $100. If that seems a bit steep to automate turning a single lamp on and off, take some comfort in the fact that most of this is a one time entry fee, so to speak, for home automation. From here forward, you can simply buy a single module for $20 or even less to automate additional lights or appliances.

Over the coming months, I will have additional posts going through more of the script from the course and talking about home automation. But if you want to get started quickly and have a Pluralsight subscription, the course will be a much faster route to go. And, again, if you don’t have a subscription but want to check out the course, then email me and I’ll send you a 7 day trial so that you can check out my course and any others you want. Happy automating!


Introduction to Home Automation Course Now Live

I have received a comment or two here and there over the last year, asking whatever happened to the home automation posts I used to do. These were admittedly sporadic, largely because I work all day, then I moonlight at night with freelance gigs and Pluralsight, and then I blog regularly, and only then do I split my time between many hobbies. Only one of those hobbies is home automation. But, enough excuses, I decided a few months back. I’d merge two of these interests and optimize my life.

The result has been a few fun months in the making. I have created a Pluralsight course, now live, that is a detailed introduction to home automation that’s far more comprehensive than anything I’d have been able to convey on the blog easily. I think that this course probably makes up for a whole lot of posts that I otherwise may or may not have done. If you have a Pluralsight subscription and are interested, please go check it out and give it a good review if you like it. If you do not have a subscription, but are interested, email me at erik at daedtech and I’ll send you a free 7 day trial so that you can watch it and any other courses that interest you.

For this course, I used X10 and a Raspberry Pi. Some might ask why I’d do this when things like Google’s Nest are all the rage. The reason I chose this for a “fundamentals” course was for the same reason that programmers might start out with C if they’re serious about programming — it’s the original tech, and it’s an excellent platform from which to grow and really understand the various principles involved. Depending on how this course is received, I may opt to do others where I get even more advanced with X10, where I bring in other, similar technologies, or where I start expanding out to use more polished, turn-key products as part of a broader solution. We shall see.

If you’re not sure whether home automation will interest you or what, exactly, home automation is, this course will cover you. It goes into the back-story and it assumes you know absolutely nothing about the topic. Within a few hours of course time (and probably a week of real time since you’ll need to order some equipment), you can go from knowing nothing about home automation to making REST calls that turn on a light in your house, using your favorite HTTP client. And the cost of all of the infrastructure that you’ll need for this will have an upper bound of $100. But heck, watch if you’re just curious — you can always decide whether to order the stuff and follow along later.

I’ll leave you with the introductory section of my script to give you a feeling for the course.

What is Home Automation?

Let’s talk a bit about what home automation actually is.  You’re an intelligent person, and I have little doubt that the words “home” and “automation” used in succession probably conjure up an image in your mind, even if you aren’t already familiar with the term.  And whatever it is you’re imagining is quite likely accurate to some degree and at least a subset of what home automation is.

We all do a lot of manual things around the house.  When the sun goes down, we walk over to a wall switch and turn on a light.  If we suddenly feel cold, we go downstairs and adjust the thermostat.  If it hasn’t rained in a week and the garden plants are wilted and unhappy, we go out to water them.  If it’s too dark and depressing during the day, we open the blinds.  We dust, we vacuum, we scrub, and we clean.

Home automation is the process whereby we stop doing all of that manually.  We automate tasks around the house to varying degrees, either through mechanisms like remote control or through a centralized computer programmed with triggers and actions or even machine learning algorithms.  When the sun goes down, the house senses growing darkness and turns on the lights.  If we suddenly feel cold, we say into our phones “turn the heat up 2 degrees” and go back to whatever we were doing.  If it hasn’t rained in a week, the sprinkler system is smart enough to know the garden plants need water.  We needn’t bother opening the blinds because the house knows we prefer them open on sunny days and does this automatically.  We don’t dust, vacuum, scrub or clean because we have devices that do these things for us.


There are various terms for the concept of home automation.  It’s been called “Domotics” when it involves some form of domestic robotics, or having a “Smart Home.”    Lately, the idea of an “Internet of Things” has had some overlap with the concept of home automation, though there is nothing that requires any of the automation be exposed to a broader network.  Here are some of the many concepts that fall under the broad heading of home automation:

  • Controlling the lighting inside and outside of the home
  • Temperature and HVAC, or heating, ventilation, and air condition, control
  • Media management, such as music and movie playing
  • Shading, which includes the drawing and opening of curtains, blinds, etc
  • Home security, including, but not limited to door locking, intrusion detection, and monitoring systems
  • Communications systems such as intercoms
  • Cleaning devices, of which the Roomba is probably the most iconic example
  • Appliance triggering and status monitoring

Needless to say, the subject covers a lot of ground, but it can be loosely summarized as the idea of automating previously manual household tasks.

A Quick History of Home Automation

If you are somewhat familiar with the concept of Home Automation, what probably comes to your mind is recent commercials such as one for an iPhone app that lets you turn your house’s lights off when you’re not at home or else perhaps Google’s recent foray into the market with the purchase of the Nest learning thermostat.  But it goes back a lot further than that.

The absolute precursor to any concept whatsoever of home automation was the introduction of electricity into the home, which happened on a widespread scale in the early 20th century.  In the same timeframe, RF remote control technology was first introduced by Tesla and would lay groundwork for later home automation in earnest.  The first half of the 20th century was accompanied by a couple of other important advances on the front of media: radio, and later television.  Still, by the 1950’s the most significant advances were largely in the imaginations of people who uses phrases like “home of tomorrow” to describe what they thought would be possible, though some remote operation of various devices was possible, and concepts like mechanical timers for lights and thermostats did exist.

In the 1970’s, a landmark first step toward the modern concept of home automation was taken with the introduction of the X10 protocol.  The concept was simple but groundbreaking and elegant – existing AC wiring in homes could be used to transmit signals between electronic devices.  In the late 1970’s, this idea had been realized with the introduction of a command module, an appliance module, and a lamp module that allowed lights and appliances to be controlled from a centralized point in the home.  It wasn’t long before these became available for retail sale.

Since that promising development, however, progress has not been nearly as rapid as a 70’s home automation enthusiast might have hoped.  Various niche commercial devices such as The Clapper have struck the public largely as curiosities rather than game-changing developments.  More elaborate home automation systems have remained largely the province of tech-savvy hobbyists and millionaires with consultants that setup boutique, custom arrangements.  Retail brands emerged, such as X10, which was named after the protocol, but also Z-Wave, Insteon, Zigbee, and others, but none of these has been able to last in retail stores, and the X10 corporation actually wound up going bankrupt in the early 2000’s.

In spite of its disappointing lack of movement over the last 30 years or so, the home automation market is showing some signs that it may truly be about to take off.  Of course, enthusiasts have been saying that for the last 30 years, and companies like IBM and Honeywell have tried without success to capitalize on this line of products, but these days, Google, Apple, Comcast, and ADT are all pushing products that are gaining more widespread adoption.


I personally think that this is a very exciting time to get into home automation as a hobby.  As a society we’ve enjoyed such stunning technological advancement that phones we carry in our pockets have made maps, calculators and separate cameras virtually obsolete in one fell swoop, but we still turn our lights on and off in largely the same way that people in the late 1800s did.  I’d like to get a lot smarter about that and see it change, and I think that being a home automation enthusiast right now is probably comparable to being a personal computing enthusiast in the late 70’s and early 80’s.

So, Check it Out!

I’ll return to this subject matter here and there, the way I do with my other Pluralsight courses, so if you prefer the blog medium, you’ll still get to see some of the static content.  But what I won’t be doing is posting any of the video demos that are property of Pluralsight, so if you want the full experience, I definitely suggest checking out the course.  I take you through literally every nitty gritty detail of ordering parts, Linux command line setup, implementing REST with Python, and configuring Apache on the Raspberry Pi.  End product code is also up on github and downloadable through Pluralsight.



Create a Windows Share on Your Raspberry Pi

If I had to guess at this blog’s readership demographic, I’d imagine that the majority of readers work mainly in the .NET space and within the Microsoft technology ecosystem in general. My background is a bit more eclectic, and, before starting with C# and WPF full time in 2010, I spent a lot of years working with C++ and Java in Linux. As such, working with a Raspberry Pi is sort of like coming home in a way, and I thought I’d offer up some Linux goodness for any of you who are mainly .NET but interested in the Pi.

One thing that you’ve probably noticed is that working with files on the Pi is a bit of a hassle. Perhaps you use FTP and something like Filezilla to send files back and forth, or maybe you’ve gotten comfortable enough with the git command line in Linux to do things that way. But wouldn’t it be handy if you could simply navigate to the Pi’s files the way you would a shared drive in the Windows world? Well, good news — that’s what Samba is for. It allows your Linux machines to “speak Windows” when it comes to file shares.

Here’s how to get it going on your Pi. This assumes that you’ve setup SSH already.

  1. SSH into your Raspberry Pi and type “sudo apt-get install samba” which will install samba.
  2. Type “y” and hit enter when the “are you sure” prompt comes up telling you how much disk space this will take.
  3. Next do a “sudo apt-get install samba-common-bin” to install a series of utilities and add-ons to the basic Samba offering that are going to make working with it way easier as you use it.
  4. Now, type “sudo nano /etc/samba/smb.conf” to edit, with elevated permissions, the newly installed samba configuration file.
  5. If you go navigate to your pi’s IP address (start, run, “\\piip”), you’ll see that it comes up but contains no folders. That’s because samba is running but you haven’t yet configured a share.
  6. Navigate to the line in the samba configuration file with the heading “[homes]” (line 244 at the time of this writing), and then find the setting underneath that says “browseable = no”. This configuration says that the home directories on the pi are not accessible. Change it to yes, save the config file, and observe that refreshing your file explorer window now shows a folder: “homes.” Cool! But don’t click on it because that won’t work yet.
  7. Now, go back and change that setting back under homes because we’re going to set up a share a different way for the Pi. I just wanted to show you how this worked. Instead of tweaking one that they provide by default, we’re going to create our own.
  8. Add the following to your smb.conf file, somewhere near the [homes] share.PiSamba
  9. Here’s what this sets up. The name of the share is going to be “pi” and we’re specifying that it can be read, written, browsed. We’re also saying that guest is okay (anyone on the network can access it) and that anyone on the network can create files and directories. Just so you know, this is an extremely permissive share that would probably give your IT/security guy a coronary.
  10. Now, go refresh your explorer window on your Windows machine, and viola!
  11. If some of the changes you make to samba don’t seem to go through, you can always do “sudo service samba restart” to stop and restart samba to make sure your configuration changes take effect. That shouldn’t have been strictly necessary for this tutorial, but it’s handy to know and always a good first troubleshooting step if changes don’t seem to go through.

And that’s it. You can now edit files on your Pi to your heart’s content from within Windows as well as drag-and-drop files to/from your Pi, just as you would with any Windows network share. Happy Pi-ing!


RESTful Home Automation

Here are the general steps to get a REST service going on your Raspberry Pi, using Python. One thing that I’ve learned from blogging over the last several years is that extremely detailed, granular how-tos tend to be the most yawned-at posts. So this is just a quick overview of how you can accomplish the goal without going into a lot of detail. If you want that detail, you can drill into the links I’m providing or else feel free to ask questions in comments or via email/twitter.

  1. Go out and buy these things: USB transceiver, plugin transceiver, lamp module (optional)
  2. On your Pi, install apache with sudo apt-get install apache2.  This is the web server.
  3. Also on your Pi, install web2py with sudo apt-get install python-webpy.  This is the module that makes setting up a REST service a snap.
  4. Install some driver dependencies (I will probably later roll these into what I’m doing) with “sudo apt-get install libusb-1.0 python-usb”.  Here are more detailed instructions from the page of the home automation python driver that I’m using.
  5. Follow the instructions on that page for disabling interfering kernel drivers.
  6. Give your user space account permissions to hit the USB device from the referenced instruction page, but note a typo where he says “sudo nano /etc/udevrules.d/cm19a.rules” and you really want
    “sudo nano /etc/udev/rules.d/cm19a.rules”.
  7. Now go get my stuff from github and run a web server using python rest.py <port>

That’s all there is to it.  Right now, at the time of writing, you would go to http://<your pi’s ip>:<port>/office/on to basically turn everything from A on.  A and office are both hard-coded, but that’s going to change in the next few days as I grow this service to support adding rooms and lights via PUT, and storing them as JSON documents on the server.  You’ll be able to add a light with PUT, supplying the room, light, and X10 code, and then you’ll subsequently be able to toggle it with http://pi:port/room/light/{on/off}

You can also just install Andrew’s driver and use it as-is.  It even has a web mode that supports query parameters.  The reason I didn’t do things that way is because (1) I wanted a REST service and (2) I wanted to be able to customize everything as I went while learning a new language.


Getting Started with Raspberry Pi

What and Why?

(If you’re here because you googled for a RPi tutorial, I’d suggest skipping to the next section)

I’ve recently throttled back on being all .NET all the time, mainly because I’m trying to spend more time working on my home automation. Toward that end, I recently picked up a Raspberry Pi. Since the organization’s home page neglects to include an elevator pitch as to what it actually is, I’ll summarize by saying that the Raspberry Pi (or RPi, for short) is a fully functional computer that’s about the size of a credit card and contains a good cross section of the device I/O that you might want, including audio, HDMI, USB, and ethernet. Oh, and they’re $35.

I’d imagine that most of you reading have either heard of this or, if you haven’t, you’re thinking of half a dozen uses now that you’ve read my description. But if you aren’t, here are a few uses you might find attractive: tiny media PC, small robot controller, car OBD troubleshooter device, Roomba brainwasher (I totally want to do this and use it to chase my cats around). One could also use it, as I plan to, for home automation.

My purpose here with my first RPi is going to be relatively simple — I’m going to offload the home automation controlling functionality of my home’s server onto it. The server I’m currently using is a repurposed dinosaur that I took with me to college (P2, 400 MHz processor, and tricked out to the max in slots with a whopping 3 128 MB sticks of RAM). It chugs along with an old Fedora installation, running a web server, SVN, a few databases, samba, and a few other goodies, as well as being hooked up to my big external drive where media is stored and eventually whisked into the cloud via Crash Plan. Add to this the fact that there’s a firecracker module plugged into its serial port to make the jump from my software to the electrical, and this is a pretty busy old machine that may not be long for this world. So I’d like gradually to parcel out its functionality to a handful of other machines to minimize my exposure to an extremely annoying failure, and the RPi is perfect, spec-wise and form-factor-wise, for the home automation web server.

Before Getting Started

So your Pi arrived in the mail, it has no installed OS, no instructions, and you’re not really sure what to do. No worries. I was like you, and I fumbled through it cobbling together a variety of guides and tutorials, and here, centralized in one place, is how I did it. This is the dead simple, option-free way to get something going with your RPi. All you’re going to get from this tutorial is an OS and web server on the device, but you’re not going to have to pick

RaspberryPiFirst off, prerequisites. To get started, here’s what you need:

  1. The RPi, obviously (pictured)
  2. A formatted Mini SD card that will act as the hard drive (pictured), or optionally a MicroSD card with a mini adapter. Either way, it needs at least 2 GB of space
  3. A micro-USB electronic device charger (i.e. an “anything but Apple” cell phone charger) to power the Pi.
  4. A desktop, Windows computer with either an onboard or connected SD card reader/writer
  5. An internet connection
  6. (Optional) HDMI to DVI adapter if you plan to spend a significant amount of time with your RPi plugged into a monitor.

You can probably make it happen without most of these things, but this is what I was working with when I did it, so if you have a Mac or want a different Linux distro on your RPi, this isn’t the tutorial for you.

Linux on the Pi

Here are the steps that I followed:

  1. First, download the zipped OS, “Raspbian Wheezy” for the RPi at this link, which will actually trigger the download. If that becomes defunct or you want to find it on your own, you can go to the RPi download site.
  2. Now that you have the OS, you need a means of putting it on the SD card. For that, you’ll need the Win32 Image writer (link triggers actual download of zip) or find the download yourself at their site.
  3. Plug your SD card into your SD reader/writer.
  4. Extract the contents of both of the zip files that you downloaded and launch the disk manager utility with administrator rights. If it takes a long time to load, there’s probably a driver issue with your SD card — that happened to me, but the fix was very specific to my hardware and is thus beyond the scope of this tutorial.
  5. Choose the Wheezy-Raspbian img file and the drive in which your SD card is mounted on your computer (below). For me the only option was the drive with the SD card, but make sure you double check that it’s the right one — I don’t want to be responsible for your frying some drive you need with a Linux install.WinDiskManager
  6. When you’re sure you’re not blowing anything you need away, click “Write,” and then click “OK” when warned.
  7. The write process will take a while, with specifics depending on your hardware. For me it took about 10 minutes. At the end, a “Write Successful” dialog will appear.
  8. Pop the SD card out of the computer and put it into the RPi.
  9. Plug your RPi’s HDMI into a TV (or monitor with the adapter) and plug a USB keyboard and mouse into the RPi.
  10. Now plug the RPi into power and let it boot up. It should look like a normal Linux boot sequence:
  11. Once it boots up, you’ll be shown some initial configuration options. I enabled SSH and expanded the root partition to use my entire 8 Gig SD card. Your mileage may vary here, but I bought the SD card just for the Pi and I have no interest in leaving the Pi plugged into my bedroom TV on a permanent basis, preferring to remote in.
  12. I also enabled booting into desktop, though I may later get rid of that option since the Pi will be headless. From there I selected “Finish” and rebooted. This took a while since it resized the root partition on reboot.
  13. Once it booted, it booted to a cute little desktop with the RPi logo in the background and you can configure it like any other Linux distro.
  14. One early thing to note is that the default user/pass is pi/raspberry — this will help if you drop into a console tty. (i.e. you hit ctrl-alt-f4)
  15. On the desktop, I noted that wheezy ships with WPA-supplicant for wifi config, which is handy if you have a wifi USB dongle, though I did not go this route — I have known much pain from using wpa_supplicant 5-6 years ago with AES before the utility was mature.
  16. After playing with the RPi desktop a bit, I powered down and disconnected from the TV, setting it up headless in my office, to be accessed via SSH.
  17. At this point, I tunneled in via SSH and ran an update. I had seen that things weren’t working on the desktop because it needed updating, so, first things first. “sudo apt-get update” did the trick (after about 4 or 5 minutes).
  18. To put apache on there, I did “sudo apt-get install apache2″. Ah, apt-get, the original app store.
  19. Finally, if you’re going to have a web server, it makes sense to give it a static IP. There’s nothing specific to Wheezy about this — it’s just standard Linux networking involving modifications to the network/interfaces file.

And, viola! The transformation from RPi in the box it shipped in to little web server is complete.


Home Automation: The Socket Rocket

Introducing the Socket Rocket

In the last post of this series, I covered adding a wall switch to a home automation network. Today, I’m going to talk about adding the “socket rocket”, or LM15A. It is commonly known as “Socket Rocket” presumably due to it fitting in a light bulb socket and I guess vaguely looking like a rocket or something. As you can probably deduce from its image, the socket rocket works by having a light bulb screwed into it and then being screwed into a normal light socket itself.

The socket rocket confers a few benefits on users. First, unlike the lamp module we covered in the first post and like the switch we covered in the most recent post, the socket rocket does not announce its working with a loud clicking sound. It turns its bulb on and off silently. Secondly, the socket rocket will work regardless of whether a lamp is controlled by the lamp’s switch, a wall switch, or both. This makes it quite versatile and extremely easy to install, requiring neither replacement of a wall switch, nor even location of the outlet into which a light is plugged. A third advantage is that a series of socket rockets on multi-light lamps allows more granular control over the lights than is possible without home automation. For example, if you had an overhead bedroom lamp with three light-bulbs, you could use socket rockets to have a setting where two of the bulbs were off and one was on. And, finally, the socket rocket can allow control over lights that are generally hard or annoying to reach. This may seem obvious, but an interesting possibility opened up here is the ability to place a lamp in some hard to reach location (up high or on a porch, for example) and control it remotely.

On the flip side, the socket rocket also has a few downsides as compared to the switch and the lamp module. Unlike these modules, it does not work in conjunction with manual operation. If you unplug or manually turn off a lamp into which a socket rocket is plugged, the socket rocket will forget what on/off state it was in and revert to off. So, socket rocket should only be used in lamps that will exclusively be controlled by the home automation network. Secondly, the socket rocket does not allow dimming nor does it respond to dimming commands (though this does allow for the not-officially-approved but interesting ability to use socket rocket with CFL bulbs). And, third, the socket rocket is not programmable with the manual dials that I’ve discussed before — I will cover how to program them below.

Setting up the Socket Rocket

So, assuming that you’ve read through the pros and cons and decided that you have use for a socket rocket, let’s buy one and set it up. For this and other home automation needs, I usually search ebay for sales home automation stores. At the time of writing, socket rockets typically run around $20, though I have seen them for as little as $10 at times. Personally, I tend to buy them from ebay stores — people who sell X10 equipment as part of a commercial business. This generally ensures smooth, easy transactions and properly working devices. However, you can probably get them cheapest if you buy them used from other non-store ebay users. My preference may not be the same as yours.

When the socket rocket arrives, it is time for you to program it. The first thing that you want to do is set the house and unit code of the socket rocket. As I mentioned earlier, this won’t be accomplished the way you did it with the lamp module and wall switch because the socket rocket has no dials. Instead, you’re going to use your keychain remote. To complete the programming task, you’re going to need your keychain remote, your lamp transceiver module, a spare lamp (with bulb), and your socket rocket.

Plug the socket rocket into your lamp and the bulb into the socket rocket. Make sure your lamp is turned OFF, and plug it into the same wall outlet as your transceiver module. You can plug it in wherever you have the transceiver module set up already, or you can move them both to some spare outlet pair. This is all just temporary for the setting of the house and unit code. Now, decide which house code (letter) or unit code (1 or 9) you want the socket rocket lamp on. It defaults to A1, so let’s choose A9 to make sure we’re programming it correctly. Once the lamp and transceiver are both plugged in, turn the lamp on (the bulb will not light) and, within thirty seconds, click the right “on” on the remote three times. The socket rocket bulb should light up, which tells you that it has been properly programmed.

The theory behind the scenes is that whenever the socket rocket first receives power, it goes into “programming mode” and sets itself to any house and unit code combination it receives an on signal for three times. So, plugging it in and hitting “on” from the remote corresponding to A9 three times tells the socket rocket that you want to program it for A9. From here forward, the socket rocket will respond to A9 when you click it on or off.


As I mentioned briefly earlier, the socket rocket should only be controlled from your keychain. If you unplug the lamp or turn it off manually with the switch, when you turn it back on, the socket rocket will not remember that it was on last time, and you’ll have to turn it on again. So, let’s say that you plug the socket rocket into a light in your closet operated by a pull cord and turn it on with your keychain. If you turn it off by pulling the pull cord instead of with the remote, you will not be able to turn the lamp back on with your remote. And, when you go to turn it back on by pulling the cord, it will not illuminate because the socket rocket has forgotten that you wanted it on (it will briefly illuminate to show you it has power and then turn off). You will have to pull the cord and then turn it on with the key chain. Because of how confusing this is, I strongly recommend using the socket rocket only on a light that you never turn on or off any other way.

When bulbs burn out, you can replace them by screwing them into and out of the socket rocket while leaving it in place. There is no need to do anything with it at that time. If you want to reprogram it, simply repeat the original programming process but with a different house and/or unit code.


Adding a Switch to Your Home Automation

Last time in this series, I covered turning a lamp on and off with a keychain. Today, I’m going to up the ante and describe how to control an overhead light with your same keychain. This will be accomplished by replacing the switch for the light that you want to control with a new switch that you’re going order.

The benefits include not only the ability to remotely control the light itself, but also adding dimming capabilities to previously non-dimmable lights. In addition, their “soft” on and off behavior dramatically increases the lifespan of incandescent bulbs.


A few things to check off your list before getting started:

  1. The light to be controlled must be an incandescent light with wattage of at least 40. Do not use on fluorescents, halogens, etc!.
  2. You must have the transceiver from the last post or this will not work.
  3. Needle nose pliers, screw driver(s), wire nuts, wire strippers/cutters, voltage tester.

Also, and perhaps most importantly, you’ll need some degree of comfort changing out a wall socket. I assume absolutely no responsibility for what you do here. Working with home electricity can be very dangerous, and if you are the least bit uncomfortable doing this, I recommend hiring an electrician to wire up the outlet.

Making the purchase

The first thing that you’re going to need to do is order your part. You’re going to want to order the X10 Wall Switch Module (WS467). The price on this varies, but you can probably get it for anywhere from $12 to $20. It is pictured here:

I recommend this one because it will fit into the same space as most existing standard toggle switches. If you are looking to replace a rocker switch, you can order WS12A, which tends to be a bit more pricey, but such is the cost of elegance.


The unit itself will come with instructions, but here is my description from experience:

  1. First, remove the wall plate from the box just to peer in and make sure there isn’t some kind of crazy wiring scenario going on that may make you want to abort mission and/or call in an electrician. This might include lots of different wires using this switch as a stop along the way to other boxes or outlets in the house, for instance. Careful while you do this as your electricity is still live.
  2. Once you’re satisfied that the mission looks feasible, head to your circuit breaker and kill the power. Make sure power is off by using your voltage tester with one lead on the hot wire and the other on ground somewhere (if you didn’t figure out which was hot and which was ground, try both leads on the switch).
  3. Once you’re doubly sure power is no longer flowing, pop the screws on the switch itself that are holding it to the junction box and remove the switch.
  4. Your old switch should have two connected leads, and each of these should have one or more wires connected to each lead. At this point, you can basically just swap the old wireup for the new module’s wireup — the colors don’t matter (though I’ve adopted a convention with these guys of wiring black to hot). You’re going to need your needle nose pliers and wire nuts because unlike most existing outlets, the X10 have wires instead of terminal receptacles.
  5. Once you’ve twisted up the wires and made sure no bare wires are showing anywhere, settle the switch into the junction box and screw it back in. You’re now going to restore power at the breaker box.
  6. When power is back on, verify that pushing the button on the switch turns lights on and pushing it again turns them off. This switch will always be manually operable. Also, don’t be surprised that the lights come on more gradually than you’re used to (it may seem weird at first, but I love this, personally).
  7. Once everything is working properly, you can replace the wall plate. However, in continuation from our first post, what you’re going to want to do now is match the dials on the switch to one of the remote settings, in terms of house code and unit code, before you replace the wall plate. You can always change this later, but you might as well do it now while it’s already off


Now, you’ve got it installed, and it should work manually or from your keychain remote. Generally speaking, wall switches are always operational both manually and remotely. These are not rocker/toggle switches but pushbutton switches, so they have no concept of state. Each time you press the button either on the switch or from the remote, the command boils down to “do the opposite of what you’re currently doing.” That is, there’s no concept of manual or remote push overriding the other — it’s just flipping the light from whatever state it was last in.

In addition to this functionality, you also get dimming functionality. If you hold the button in instead of simply pushing it, the light’s brightness will change. Holding it in when the light is off causes it to ramp up from dim to bright, and the opposite is true when the light is on – it will ramp down. On top of this, the light will ‘remember’ its last brightness setting. So, if I turn the light on by gradually bringing it up from dark and then turn it off, the next time I turn it on, it will ‘remember’ its previous brightness.

One final note is that there is a manual slide below the main switch. This is, in effect, a kill switch. If you push that, you will completely break the circuit and no amount of remote presses or X10 signals can activate it in this state. This is the equivalent of unplugging your transceiver module from the last post. If power is cut, the signals you send don’t matter.


So, now you’ve got a remote control capable of controlling two lights in the house. One is a lamp and the other an overhead light that can now be dimmed and brightened manually, as well as turned on and off remotely. (Next time I install a switch, I will take some pictures of what I’m doing and add them to the instructions above).


Getting Started with Home Automation

I’m going to be doing a series of posts on home automation, starting out targeting beginner concepts and getting more in depth from there. My hope is that when these are complete, someone with some technical and home improvement acumen can read back through the series as an instruction manual of sorts.

What Is Home Automation?

Home automation is somewhat hard to define. Out of curiosity, I poked around and found as many different definitions as places offering definitions. The definition I most liked came from ehow:

Home automation [allows] individuals to automatically control appliances and security systems within their home through the use [of] technology.

Other sites talked specifically about the use of computers and various products, but this one is nice and general. To my way of thinking, home automation is the use of any technology that helps automate tasks in the home. This may include turning on lights, starting appliances, opening blinds, etc. So, anything from the “home of the future” to The Clapper can be considered home automation.

A Brief History

The concept of home automation has been around for a long time. In the early 1900s, the “house of the future” was the stuff of speculation at world fairs and in the studios of inventors. No doubt many interesting concepts came out of that, but nothing particularly interesting for our purposes here (though one might pedantically argue that appliances such as dishwashers or devices like thermostats are a form of home automation). As the 1900’s wore on, the concept of remotely controllable devices, such as televisions emerged, providing a relatively early snapshot.

In 1975, a Scottish company called Pico Electronics developed the X10 protocol. This was a way to use existing electricity wiring within a house for communication between a sender and a receiver. This protocol was used to transmit simple messages across the wire. A controller could send an “On” message and a device elsewhere in the house would receive this message and execute some appropriate action. For exmaple, a “lamp module” plugged into a wall and with a lamp plugged into it could turn on the lamp at the request of a signal sent from another room.

Over the course of time, the uses of X10 technology expanded from simple on and off to signals allowing control over home security, heating, air condition and ventilation (HVAC) and other home technologies. X10 is reliable and established, but it does have some limits, and those limits have become more obvious lately as the number of devices using house power have skyrocketed. Devices, especially modern ones tend to produce “noise” on the electrical lines, and the more devices we plug in the more noise is generated.

A number of other protocols and technologies have emerged as a result of this, including Insteon, Z-Wave, Lutron and more. And, there is still X10 itself, which is a little confusing as it is both the name of a protocol and the name of an organization that sells devices that implement the protocol. The newcomers tend either to use a different protocol over the electrical system (some being “backward” compatible with X10 and others not) or else to use wifi communication. Often these are more effective than the original X10, but also pricier.

For a time in the 80’s and 90’s, big box stores like Radio Shack and Home Depot carried X10 products, but that seems not to be the case anymore. Some of them now carry the higher end competitors such as Lutron and Insteon. But, if one is interested in purchasing any of these devices, you can find them in many places for ordering online, including ebay.

The fact that you don’t find these items for sale in big box stores does not mean that the home automation trend has cooled off, per se. As society expects more and more things to be automated, the home is no exception. The reason that these items are not carried so much anymore, in my opinion, is that the average consumer is not a combination of electrical engineer and carpenter. People want devices that they can plug in and have “just work” with a minimum of configuration. So, people hire contractors to wire these sorts of things up for them, rather than simply buying them at the local hardware store.

Our first crack at home automation..

So for anyone still reading, sold, and ready to jump in, I will introduce a first home automation project that you can execute as an absolute beginner. You’re going to buy two items, and it’s going to cost roughly $25 to $30, depending on where you order. One item is a keychain, and the other is an X10 “lamp module” with a wireless transceiver. They are pictured together here:

(You can buy this setup on Amazon for $30 at the time of writing, though a quick google search showed prices as low as $16, though that may be omitting a shipping charge).

When you get the devices in the mail, take out the lamp module and observe that it has a red dial on it. The red dial corresponds to the “house” code, one of 16 letters. All X10 devices have a house code and a unit code, and these together form the “address” of the device. The house code, as mentioned, is one of 16 letters, and the unit code is one of 16 numbers. This means that X10 addresses are A1, D12, J4, etc. Your lamp module has all available house codes, but only has unit codes “1” and “9”. These are the unit codes that it will respond to if you were sending commands over the electricity, but it will respond to any unit code sent wirelessly, which is how your remote will work.

If you now take out your remote and its instruction manual, you will see that you can set it to send signals to any house code and unit code. The unit code is essentially irrelevant here for your purposes. You just want to make sure the house code matches the lamp module’s. At this point in your home automation ventures, these are the only devices you have, so just leave them both at house code A.

Now, plug a lamp into the lamp module and the module into the wall. You should now be able to turn your light on and off using the keychain. The range on this should be comparable to that of your home wifi, so you could turn the lights on in your house from your car in the driveway or garage, which is handy.

So, to recap, you can basically just unwrap the devices and set them up without messing with the unit or house codes at all, since your lack of other home automation stuff means you don’t need to worry about compatibility. You now have home automation going for $25 or $30. If you’re interested in doing more, no worries – I’ll have plenty more segments on this.

More Info

For now, I’ll leave off with a series of links that I’ve found over the course of time that will hopefully be helpful, but not too overwhelming.

And, no worries if I haven’t covered all bases – I’ll have plenty more posts.



Android: Let There Be Internet!

I’ve been a little lax in documenting my experience as a neophyte Android developer, and for that I apologize. Tonight, I have a quick entry that will hopefully save you some time.

I’m working on an open source home automation server. I’ve had a prototype functional for a couple of years now that runs as a web server in apache, Java-based, and controls the lights through a web interface front end and a low level backend that interfaces with the house’s electrical system. I control this through any computer/phone/ipod/wii/etc that’s hooked to my home wifi, using the browser.

Recently, I’ve wet my beak a little with Android development, out of curiosity, and so my mission tonight was to take the layout I’d been working on and get it to, you know, actually do something. So, the simplest thing for me to do was have the app reproduce the POST request sent by the browsers to get the desired result. Here is the code I slapped together for this:

final Button myButton = (Button) findViewById(R.id.breakfastNookButton);
        myButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	HttpClient myClient = new DefaultHttpClient();
                HttpPost myPost = new HttpPost("you-get-the-idea");

                try {

                } catch (ClientProtocolException e) {
                } catch (IOException e) {

Not the prettiest thing I’ve ever written, but this is a throw-away prototype to prove the concept (though I’m going to refactor tomorrow – I can’t help myself, prototype or not).

So, I fired it up and nothing happened. I checked out the stack trace and was getting an UnknownHostExeption, which didn’t make sense to me, since I was using the home automation server’s IP address. I used the browser on my phone, and I could turn the light off. I googled around a bit and found a bunch of information about things that can go wrong with the emulator, but I’m debugging right on my phone since the Emulator is painfully slow.

Finally, I stumbled across a suggestion and got it right through some experimentation. I needed to give the app permission to use the internet! So, I updated my manifest to the following:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
     <uses-permission android:name="android.permission.INTERNET" />
    <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">

Important line is the “uses-permissions” node, and, viola, let there be dark! My light turned off. Hope that helps someone out there struggling to understand the UnknownHostException for a known host.

(Note, the node level in the XML file is important — it must be a child of manifest, NOT application).


Home Automation

Mea Culpa

As is alluded to once or twice on my sight, my main area of interest is in home automation. I’ve been somewhat mum about this interest in the blog, as my time over the last year has been spent refining this site, working on some open source tools, completing my MS degree, and, oh yeah, working 50+ hours per week programming to pay the mortgage. However, now that the site is somewhat established, business is good, and my MS degree complete, I’m planning to give this the focus that I’ve intended. So, I’ll be doing some posts about home automation in the hopes of drumming up some interest in the public at large in what I believe is a (too slowly) emerging trend.

What is Home Automation


Many people, and probably most techies, have heard of and are at least vaguely aware of the concept of home automation. The idea that most would throw out there is that one can control lights and perhaps some other goodies in the home without actually, manually getting up to toggle a rocker switch. A very simple example of this is The Clapper, a device that allows someone seated on a couch or bed to clap and turn lights on and off. A subtler example with which most are probably familiar is lighting in offices (or homes, as it were) that turns itself off after some amount of time or when nobody is detected in the room.

Generally speaking, the aim of home automation is to provide enhanced convenience, comfort, and perhaps security, with a sometimes ancillary goal of efficiency. It is nominally time saving to have lights turn on instead of walking around to turn them on, and it certainly appeals to anyone having a lazy day. From a security perspective, the ability to control lights remotely or have them turn on automatically is handy for creating the illusion that someone is at home when the house is unoccupied. And, having lights turn off in rooms not in use is certainly energy efficient, both in terms of cost and green concerns.

In reality, however, home automation promises to be and can be a whole lot more than this. I believe, personally, that the capabilities of home automation are limited only by our imaginations. But, I’ll get to see some of these later.

A Dream Deferred

In our society, we made some relative peace with the automation of all manner of processes. Computers, software and robots have obsoleted countless jobs while creating countless others. Having a land-line is starting to be considered passe, and sending “snail mail” is positively ancient. People don’t calculate square roots and cosines by hands, and the calculators that children use in school are really small computers that plot graphs and resolve equations. Why then, do we still turn lights on and off roughly the same way we did 100 years ago? And why then, does the notion of home automation evoke Rube-Goldbergian imagery in most people’s minds? Why is it that, like the flying car, the “home of the future” dried up in our collective consciousness like a raisin in the sun?

Home automation has long been one of those sci-fi things that never really materialized. I’ve read many accounts suggesting that it is over-engineering at its finest. Why spend a bunch of money on something that saves you the five seconds it takes to get up off the couch and toggle a switch? I’ve even brought up the subject and had it suggested to me that I was encouraging laziness – that the valuable exercise of toggling that rocker was the last line of defense between a tenuous grasp on health and a society where morbidly obese is the new thin.

Why It Has Yet to Really Catch On

I think there are a number of reasons that home automation has been slow in developing and capturing the world’s imagination. First off, unlike a killer app or the Sham-Wow, it requires multi-faceted expertise. Someone has to know enough EE to build the components, enough about home electricity to wire them up, enough about home improvement to complete any necessary carpentry tasks, and enough about programming to design and deploy the logic. Oh, and they probably have to be good with people as well, since these things aren’t going to install themselves. So, find me a person with all of these skills and an interest in putting them into what has historically been a non-starter, and you’ve got a major head start on the industry.

Another preventative factor is the current state of product offerings. Some years back, X10 emerged as a concept, allowing signals to be sent over home electricity, effectively allowing one appliance to send a message to another. Full of promise, this new technology took off to some degree, and stores eventually picked up (and, in most cases, later dropped) this line of products. As they proved too expensive and cumbersome for prime time, the outfits from which home automation hardware could be purchased took to the world of catalogs and infomercials (e.g. the aforementioned Clapper). This vibe still persists. A classy home automation site looks like a QVC catalog or Skymall, and a less classy one looks like some kind of MySpace nightmare potentially not safe for work (it is, don’t worry). This image is not lost on consumers that happen onto it – the whole industry feels like the “wave of the future” in the same way that the Chia Pet revolutionized gardening.

But, putting aside those respectively logistical and marketing concerns, there are some very bland business concerns such as price points and public interest/demand. In terms of the former, getting “classy”, non-DIY home automation has historically required hiring a contractor to wire everything up for very “classy”, non middle class prices. Basketball players and rock stars can have lights that dim when they say “computer, dim lights”, but you can’t. And, in terms of public interest, most people wonder if it really matters if they can turn off their lights from the couch, and they think of office bathroom auto-lights that turn out if you don’t wave your arms around every 30 seconds.

Getting Off On the Wrong Foot

Let’s forget all that. I don’t mean for the purposes of this article, but in general. The home automation movement is, I believe (and if I have anything to say about it) going to take off in earnest. Belkin and other non-catalog vendors are starting to take an interest. Green concerns are taking notice. The general public is slowly coming around. Pretty soon, things are going to perk up.

And, here’s why. It isn’t about turning your lights on from the couch. It’s about your home being intelligent and anticipating your needs the way your phone and computer do. It’s about pulling up into your driveway and having your home notice that you’ve arrived, unlocking the door, and turning on some lights for you. It’s about windows and doors that are smart enough to sound an alarm when they’re opened or broken. It’s about scheduling non-essential appliances to run at times of day when things are cheaper. It’s about heating and cooling your home not on a manual schedule, but on one that minimizes your monthly bill. It’s about a refridgerator that notices when you’re running low on eggs. It’s about getting an email or an alert on your phone when you’re due to change your furnace filter. It’s about walking from room to room listening to a Led Zeppelin song and having the music follow you wherever you go. It’s about keeping your pets off the counter even when you’re not home. It’s about putting an exciting new face on the thing that provides the most comfort and the most hours spent in life.

This deffered dream is going to exploded. But… in a good way. So, buckle up and get ready for a fun ride.

Acknowledgements | Contact | About | Social Media