AutoHome – Home Automation Software Setup

I’ve had a request to hand out my home automation software so here’s preliminary setup doc. This currently works with Insteon and CentraLite light switches and stock XBee analysis pods (see my earlier posts). I’m happy to discuss enhancements.

The Zip File is here.

 When you’re done you’ll have some lightweight software that runs on the server in a session – polling and updating – and a web site that runs at a non-port-80 port to control your lighting. I have a tiny hole in my firewall so anywhere in the world I can turn lights on and off using my android phone (or anything with a browser).

This entire setup should take less than 10 minutes other than installing SQL Server express, which takes a little while. Once that’s done it’s another 5 minutes to set up the ports and define some switches.

In the next post I’ll show you how to get something other than a blank page – i.e. how to identify and use your switches and run the software.

Overview

The intent is to have all database control functions (like defining and initializing switches, understanding the protocol, and pairing) done in the server local application while activities (lights on/off) are controlled via a protocol-agnostic web application. Users just need a web browser while the administrator uses tightly-coupled local Windows software.

The AutoHome software consists of two modules.

AutoHome.exe – this C#/.net application communicates with the hardware via virtual COM ports. The program initializes the hardware and monitors changes (light switch presses, for example) as well as sending commands. All of the data is stored in real-time in an SQL database. It also polls the CommandQueue table looking for commands to execute.

WebSite – this folder contains a bunch of ASP.NET files (mainly lamps.aspx) that have a web view of the SQL database. The lamps page shows switch on/off/dim status and contains on/off buttons in a trivial-to-use format. Commands are sent by appending string records to a CommandQueue table within the database (which are then interpreted and executed by AutoHome.exe).

Supplies

You should have some spare CPU cycles on a Windows Server (2003 or 2008) along with:

Hardware [any or all]

  • Insteon PowerLinc USB – for connecting to Insteon dimmers/switches and outlets. The serial version should also work but then don’t bother installing an FTDI USB driver.
  • CentraLite USB Stick – for connecting to CentraLite Zigbee-compliant switches
  • SparkFun USB Explorer or similar with XBee – for connecting to XBee satellites.

Software

  • Windows Server with IIS installed. I’m using Windows Home Server (Vail beta) at this point.
  • ASP.Net 3.5 (available here) or ASP.NET 4.0 or… [likely already available]
  • Microsoft SQL Server Express (see here)
  • FTDI driver for Insteon (see below)
  • Telegesis driver for CentraLite (see below)
  • CentraLite control software for testing/analysis/setup
  • AutoHome software client

 

Set up the Hardware

Insteon

The USB Insteon PowerLinc internally uses an FTDI 232 chip to convert serial to USB. The driver does the reverse, simulating a virtual COM port for use by software.

Install the VCP package from FTDI (here).  You can get the driver or run their executable setup program. Based on running the executable:

  1. Run Device Manager (in the control panel) and open up the Ports section (if there is one) check to see what serial ports exist.
  2. Run the ftdi setup exe program and let it complete.
  3. Plug the Insteon PowerLinc to a usb port. The PC should say the driver was successfully loaded.
  4. Re-look at the Device Manager ports section and note what new serial port exists. This is the Insteon virtual serial port. Write it down!

Centralite

Setting up the USB stick is pretty straightforward:

  1. Download the latest Telegesis driver from here. Unzip it somewhere.
  2. If the USB stick is not yet connected:
    1. Connect the CentraLite USB stick to your computer.
    2. When asked for a driver point to the folder you just created.
  3. If the USB stick is already connected.
    1. Go to device manager (Control Panel) and find the warning’ed object.
    2. Right-click and select Update Driver… then browse to the Telegesis driver folder.
  4. As with Insteon, note which port this is using by looking at Device Manager Ports!

Set up the Software

  • Install SQL Server express on your server.
    • I use all the defaults and Windows authentication for the installation.

Copy the AutoHome software and site

  • Put the AutoHome files into appropriate folders. The AutoHome zip contains two pieces.
    • Applications – the client application and config file. I put them into C:\Program Files\AutoHome.
    • WebSite – a bunch of (maybe unecessary) files that comprise the web site. I put them into C:\Program Files\Windows Server\Bin\WebApps\AutoHome in Server2008.
  • Run the AutoHome.exe program
    • Verify that it starts and runs ok. You may need to install .net 3.5 as noted earlier.
    • The first time you run it there should be a request to create the database tables.

  •  
    • Go ahead and create the database and tables.
    • After that, click the Edit Lamp Table button and ensure you see two sample lamps.

  •  
    • Quit by closing all the windows.

Enable a new web site

  • Open the Administrator IIS tool (Internet Information Services Manager).
    • Add a new web site on port whatever (anything but 80 or 443), I usually use stuff over 8000 like 8088; and point the site to your WebSite folder contents. Here’s the property sheet.
    • Verify it by browsing there (http://localhost:8088) from the server IE browser (not a client). You should see “Cannot open database “AutoHouse” requested by the login” or a similar error (because access rights aren’t set yet).
      • If it can’t find the database at all you’ll get a different error. Ensure your SQL stuff is working and the database exists.
      • If necessary, hand-edit the .config file to change the database linkage.
      • You may need to enable asp.net 3.5 or 4 for the site.

Create a database login for your web site identity

  • Run SQL Server Management Studio
    • Connect to the local database (./Sqlexpress by default).
    • In the Security / Logins folder right-click select New Login… and add a login for IIS APPPOOL\AutoHome. You can’t list it in the GUI but you can type it longhand into the login name field. In the user mapping section turn on AutoHouse.
    • Right-click the AutoHouse database and in Properties / permissions for IIS APPPOOL\AutoHome turn on Select.
  • Browse to http://localhost:8088 to get a blank page if everything is working. You can change the database linkage by hand-editing the web.config file in the web site if you have it somewhere custom or on some other form of SQL server.
  • Browse to http://localhost:8088/lamps.aspx to see the lamps page [which should have just the two sample lamps at most].

 

Open the firewall for the web site

If you want to get at the web site from outside your private net you’ll need to poke a hole in the firewall and set up port forwarding in your router.

  • Enable outside access using the Windows Firewall — allow incoming connections to port 8088 (or whatever) by creating a new rule.
  • I validate this by using my 3G on my phone to browse to my forwarded public site – that way it doesn’t go through my local switch. I browse to http://mypublic.public.com:8088/lamps.aspx .

 

This seems like a lot of work to just get some switches working but enhancing the software is pretty easy and all of the setup on this page is a fixed cost that doesn’t need to be redone for future versions. Updating will generally just involve overwriting the web site or application.

The web site source and SQL design are open [the web site code is not great]. I haven’t decided on the client source, but that mainly updates the database.

Mark

 

2 Responses to Setting up the home automation software

  1. Rao says:

    Is it possible to see your source code. I am a c# developer and am interested in developing around Insteon but have not seen any good examples yet

  2. Rob says:

    I was wondering the same thing as Rao. Insteon’s source development is very poor and gives little to no examples. Being able to see your source would be amazing.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>