rber-perine ALiAs
Building your own Home Automation Server

You need to start by finding a computer to use. If you're like me, you probably have an old computer laying around the house. The requirements are pretty minimal:

If you don't have a suitable computer stashed in a closet, collecting dust, you can probably find a cheap one that will work on craigslist!

Installing Ubuntu

The first thing you need to do is use another computer to go to the Ubuntu website and download the installation material. I would suggest using Ubuntu 10.04 (Lucid Lynx) since it's the most stable. Once you've downloaded the installation material, you'll have to burn it to a CD. Perhaps you already have a program to allow you do to this? If not, you can download Active ISO Burner.

Once you have created your installation disk, it's time to power up your "soon to be" home automation server. Immediately eject the CD-ROM drive, insert your installation disk and slide the tray back in. If the computer started it's boot sequence before you were able to insert the installation disk, you may have to restart the computer.

Now you'll have to step through the Ubuntu installation sequence. Don't worry, it's very straight forward! But, be prepared... There are a few key pieces of information that you'll need to remember. If it helps, you may want to write some of it down.

The first thing you'll see after the computer boots from your installation CD is a screen asking you to select your language and then press the button that says "Install Ubuntu". There are four screens that you'll have to step through and provide the following information:

  1. Time Zone: You can either click on the map for select from dropdown menus.
  2. Keyboard Layout: Self explanatory.
  3. Perpare Disk: Choose the option to erase and use the entire disk.
  4. Who Are You: Here you have to enter a few key pieces of information. First, enter your name where is says "What is your name?". This is just how the computer will refer to you. It's not the really important stuff. Next, enter your log-in name (username). This is important since it's how you will log in to the system. Next enter and re-enter your password. This is also very important and will be used several more times while installing the remaining software. Now enter the computer name. I used "homeautomation". This is how you will refer to this computer on your local network. And finally... If you intend to disconnect the monitor and keyboard from this computer and log in remotely, you should check the "Log in automatically" checkbox. Otherwise, you can leave that alone.

Now the installation process will begin. You will be shown a progress bar as the computer performs the actual installation. When it's complete, you will see a dialog box with a button that says "Restart Now". Click it. When the computer shuts down, it will eject the CD-ROM. Remove the installation disk before the computer reboots. Allow the computer to boot up.

If you chose the option to log in automatically, you won't see the log in screen. However, if you didn't, you'll have to select yourself (there should be only one option), and then enter your password to log in.

Before going any further, you should run the Update Manager to download all the latest software patches. To do this, click on the System menu at the top of the screen, go down to the Administration option, and then down to the Update Manager and click. Once the Update Manager loads, you will probably see a large list of updates. Click on the button that says "Install Updates". You will probably be prompted for your password at this point. This is the one you provided earlier during the installation. Once you type in the password, press enter and the computer will automatically download all the updates and install them. You will probably have to restart the computer again after the updates have all been installed. You can do this by clicking the power button in the upper right-hand corner and selecting the Restart option.

Installing Apache, PHP and MySQL

Since these three often get installed as a unit, they've made it easy to install them all in a single step. Once you're logged into your server, click on the Applications menu at the top of the screen. Go down to Accessories and then down to Terminal and click. This will open a command line interface called a terminal. In the terminal, type in the following and hit enter:

sudo tasksel install lamp-server

You may or may not be asked to enter YOUR password (the one you provided during the installation process). You WILL be asked to enter a password for the MySQL root user. To keep this as simple as possible, I recommend using the same password you provided during the installation process.

LAMP is an acronym for Linux-Apache-MySQL-PHP. You can find more detailed information about this installation procedure on the Ubuntu website. Another tool you'll need is called curl. In the terminal window, type the following and hit enter:

sudo apt-get install php5-curl

After the installation process is complete, you should restart your server. You can do this by clicking on the power button in the upper right-hand corner and selecting Restart from the dropdown menu.

Once the server has restarted, log back in using your username and password. Open a terminal window (Applications -> Accessories -> Terminal) and enter the following command:

sudo addgroup <your-username> www-data

Make sure you replace <your-username> with your actual username. This will add you to the www-data group and make it easier to add the necessary files later.

Installing bottlerocket

This is a simple command line utility used to send commands to the X10 Firecracker which should be plugged into your DB9 serial port on your computer. It's very simple to install! Once again, we start by opening a terminal window. See the section above for directions on how to do this. In the terminal window, type the following and press enter:

sudo apt-get install bottlerocket

You may or may not be asked to enter your password. If so, type it in and press enter. The package will automatically be downloaded and installed. When finished, you should be able to simply type 'br'. You should see something similiar to this:

you@yourserver:~$ br
BottleRocket version 0.05b3

Usage: br [][() ...]

Options:
-v, --verbose add v's to increase verbosity
-x, --port=PORT set port to use
-c, --house=[A-P] use alternate house code (default "A")
-n, --on=LIST turn on devices in LIST
-f, --off=LIST turn off devices in LIST
-N, --ON turn on all devices in housecode
-F, --OFF turn off all devices in housecode
-d, --dim=LEVEL[,LIST] dim devices in housecode to relative LEVEL
-B, --lamps_on turn all lamps in housecode on
-D, --lamps_off turn all lamps in housecode off
-r, --repeat=NUM repeat commands NUM times (0 = ~ forever)
-h, --help this help

is a comma separated list of devices (no spaces),
each ranging from 1 to 16
is an integer from -12 to 12 (0 means no change)
is a letter between A and P
is one of ON, OFF, DIM, BRIGHT, ALL_ON, ALL_OFF,
LAMPS_ON or LAMPS_OFF

For native commands, should only be specified for ON or OFF.

One last trick to using bottlerocket... We'll be invoking the br command via the webserver, so we have to give the proper permissions to the webserver group. To do this, type in the following in your terminal window and press enter:

sudo addgroup www-data dialout

Again, you may have to enter your password...

Most of us use an internet provider which gives us a dynamic IP address. This just means that our internet address may be different from day to day. This can make it a challenge if your address happens to change while you're away from home. Normally you'd have no way of knowing what the new address is and therefore you would be unable to connect to your home automation server.

This is where DynDNS comes in... It provides a way for you to choose a static host name and then, using an update client, dynamically link the host name you've chosen to your actual IP address. If your IP address changes, for some reason, the update client will take care of all the work for you. All you have to remember is the host name you've chosen! Pretty simple, huh? And, best of all, it's free!

So, the first thing you need to do is head on over to DynDNS and register the host name you want to use. This link will take you directly to the correct page. First you have to enter the hostname you want to use. Then, using the dropdown menu next to the hostname, you can pick a domain. There are several to choose from -- pick whatever you like. Don't check the wildcard checkbox since we don't need anything that elaborate. The service type you want is "Host with IP address".

Next, you'll have to enter your IP address. If you're doing this from home, they've provided a nifty link under the text box that will automatically populate the field with your current IP address. This will only work if you're registering from the home where your home automation server will be running. Hopefully you'll be performing this while at home, so go ahead and just click on the link. Your IP address should appear in the field. Don't worry about the IPv6 field or the mail routing checkbox. Just click on the button below that says "Add To Cart".

You'll have to enter some details on the following page to create an account. Make sure you use a username and password that you can remember. These details will be required when you install the update client! Once you've created your account, proceed with the checkout process. If you've done everything correctly, this will all be free. If it asks you a credit card, you've more than likely done something wrong!

Installing ddclient

To install ddclient, enter the following command in a terminal window:

sudo apt-get install ddclient

You will be prompted by the installation script for the hostname that you registered with DynDNS. You will also be prompted for the username/password you registered with DynDNS. Lastly, you will be asked which ethernet port you primarily use to connect to the Internet (eth0 for wired or wlan0 for wireless, usually). Most of the time this is all you will need to do for the utility to function correctly.

Configuring your router firewall

Technically, the IP address assigned to you by your internet service provider belongs to your router -- for most of us anyway. So now that you have DynDNS set up (and ddclient installed and running), when you attempt to point a browser to your new DynDNS hostname/domain, you will be hitting your router. Now we need to set up your router to perform what is called port forwarding. This is going to be a little tricky because this is done a little differently on all routers. The best resource I can give you is PortForward.com. They have instructions on how to set up port forwarding for a wide variety of routers. They even have a free application which will supposedly do the work for you. I haven't used this application -- do so at your own risk.

For AT&T U-verse, you want to log into your router by typing the following URL into a browser on your computer: http://192.168.1.254/ You should see a screen that looks something like this:

Click on the Firewall icon. The next screen will look something like this:

Click on the link that says "Applications, Pinholes and DMZ". On the next screen you will be asked to do 2 things:

  1. Select a computer: There should be a link that says "Choose your-server-name", where your-server-name is the computer name you chose during the installation process above. Click on it!
  2. Edit firewall settings for this computer: Click on the radio button next to the "Allow individual application(s)" option. Scroll the Application List to the bottom and select the "Web Server" option. Now click the "Add" button and the Web Server option should show up in the Hosted Applications list. Finally click the Save button at the bottom of the screen.

You'll be asked for the password next. Assuming you haven't changed it, the password for your router is on a sticker on the side of your router. It says something like: "System Password: ...". Enter that password and that's all there is to it!

Since the ALiAs configuration utility is web-based, it's nothing more than a set of files that have to be downloaded and installed in the correct directory on your home automation server. The steps to do this are as follows:

  1. If you're not already logged in, log into your home automation server using your username and password.
  2. Launch firefox. There should be an icon at the top of the screen, in the top menubar.
  3. Type in the following URL (or click on it): http://www.barber-perine.com/ALIAS/alias_1.1.1.tar.gz
    When asked, choose to save the file.
  4. Open a Terminal window (Applications -> Accessories -> Terminal)
  5. Enter the following commands in the terminal window:
  6. cp ~/Downloads/alias_1.0.0.tar.gz /var/www
    cd /var/www
    gunzip alias_1.1.1.tar.gz
    tar -xvf alias_1.1.1.tar
  7. Let's do a quick check... From any browser, on any computer, enter the name and domain you registered with DynDNS. You should see a screen asking for a password.
  8. Ok, back to your home automation server... Let's open a file browser. Click on the Places menu at the top of the screen. Now select Computer. A file browser window should open.
  9. Double click on "File System".
  10. Double click on the "var" folder.
  11. Double click on the "www" folder.
  12. Right click on the file named "globals.php". This file contains global configuration data that you need to change.
  13. Select the "Open with gedit" option.
  14. A text editor window should open with the configuration file. The file has comments to explain what each item is. There are two items that you MUST change:
    1. $appPassword: This is the password that you will enter into your Android app. It's also the password required by the configuration utility. Please use a strong password!
    2. $dbPassword: This is the password you specified when installing MySQL above.
  15. Finally, if your home automation server has more than one serial port, you might have to change the $br option as well. If the default value of /dev/ttyS0 doesn't work, try /dev/ttyS1 and so on until you find the right one.
  16. Click on the "Save" button at the top of the text editor window.
  17. Close the text editor.
  18. Let's try to log in to the configuration utility... From any browser, on any computer, enter the' name and domain you registered with DynDNS.
  19. When prompted for the password, enter the password you provided for $appPassword.
  20. You should now be logged in! Please click here for more info on how to use the configuration utility.