FluentDwelling

Have you ever wanted to control your lights and appliances from a computer program? While technology like X10, and more recently Insteon, have given us the hardware we’ve needed to accomplish that, we found the programming interfaces lacking. That’s why we developed FluentDwelling.

What is FluentDwelling?

FluentDwelling is a free and open source .NET class library for controlling Insteon-compatible home automation devices using the SmartHome 2413S serial-to-Insteon or 2413U USB-to-Insteon bridges. The fluent API is designed to be particularly easy to use:

Requirements

(We’re already assuming you’re a .NET programmer.) To use FluentDwelling, you need to have a 2413U (USB) or 2413S (serial) device:

The USB model is cheaper, more easily available, and more convenient. However, the USB device is actually a serial device with a USB to serial chip built-in. In order to use the USB version with FluentDwelling, you have to install the FTDI chip virtual com port (VCP) driver. (Instructions for doing this should be included with the 2413U). When it installs, it will create a new “virtual” serial port on your computer. Make a note of what that is, because you need to connect to the device using this address in your program.

The 2413U or S device allows your PC to send and receive Insteon messages using the Insteon protocol (as well as legacy X10 messages). It’s a “dual band” device so it sends these messages both over the power-line to other devices that are connected to your electrical system, as well as wirelessly.

Device Discovery

Normally, you “link” all of your Insteon-compatible devices to a controller. In this case, the controller is the 2413. You do this by plugging both devices into their outlets, holding down the button on the side of the 2413, waiting for it to beep, then holding down the button on the side of the device you want to control. It should also beep. Once you’ve done this, they are “paired”, and the 2413 keeps a list of all the paired devices in a database, which you can access with FluentDwelling:

var database = powerlineModem.GetAllLinkDatabase();
foreach (var record in database.Records)
{
// You can attempt to connect to each device
// to figure out what it is:
DeviceBase device;
if(powerlineModem.Network
.TryConnectToDevice(record.DeviceId, out device))
{
// It responded. You can get identification info like this:
string category = device.DeviceCategory;
string subcategory = device.DeviceSubcategory;
// ...and use the concrete object type to determine capabilities:
if(device is DimmableLightingControl)
{
// command it to turn on slowly to light level 50%:
((DimmableLightingControl)device).RampOn(128);
}
}
else
{
// couldn't connect - device may have been removed?
}
}

Receiving Messages

The 2413 can also notify you of incoming events. In order for this to work, you need to call the .Receive() method at regular intervals. The best way to do this, if you’re using WPF, is with a DispatcherTimer: