Programming Z-Wave

October 21st, 2008

As a developer one of the main reasons for going with Z-Wave was to try out some software product ideas I had around controlling Z-Wave.

There is a standard C-language Z-Wave Development Kit, however it costs at least US$1,500.00, which is way beyond what most hobbyists/bootstrapping startups would be willing to pay.

The main alternative is currently the ControlThink SDK, which is a .NET based API.  It costs around US$70, which is much more affordable.

The ControlThink PC SDK comes with a USB Z-Wave controller, which works for North America.  Of course if you are based in Europe (as I am) then this USB device will be useless.

I have however managed to get the ControlThink SDK working with the ACT ZCU201 USB controller on Vista.

There is an XP driver available for download here on the ACT web site.

For Vista however, I followed the instructions in this thread in order to use the driver for the Intermatic controller, which I assume uses the same underlying chipset.

I downloaded the ha22vista2.zip file from http://board.homeseer.com/showthread.php?t=121133&referrerid=55149 then I edited the DriverSetupForVista\DriverSetupForVista32\SPC825.inf file and replaced the existing [Sunplus] section:

[Manufacturer]
%Sunplus%=Sunplus

[Sunplus]
%DeviceDesc%=ComPort, USB\VID_04FC&PID_0204

[DestinationDirs]
ComPort.NT.Copy=12

with:

[Manufacturer]
%Sunplus%=Sunplus

[Sunplus]
%DeviceDesc%=ComPort, USB\VID_04FC&PID_0204
%DeviceDesc%=ComPort, USB\VID_04FC&PID_0003
%DeviceDesc%=ComPort, USB\VID_04FC&PID_0201

[DestinationDirs]
ComPort.NT.Copy=12

I then right-clicked on the SPC825.inf file and clicked Install.  Once it installed properly I rebooted (IMPORTANT!).

After rebooting I went to the device manager and saw that the USB driver was installed as COM port 4 (it may be different in your case):

image

Having installed it, I was ready to write my first program.  I created a new Console Application project, added a reference to the ControlThink assembly (in my case under C:\Program Files\ControlThink\Z-Wave PC SDK\Bin\.NET Framework 2.0\ControlThink.ZWave.dll)

I change the main program to look like this (note the use of COM4 matching the port in the device manager above):

using System;
using ControlThink.ZWave;
using ControlThink.ZWave.Devices;

namespace ZWaveTest {
    class Program {
        static void Main(string[] args) {
            ZWaveController controller = new ZWaveController();
            controller.Connected += ControllerConnected;
            controller.Connect("COM4");

            Console.ReadLine();

            controller.Disconnect();
        }

        private static void ControllerConnected(object sender, EventArgs e) {
            ZWaveController controller = (ZWaveController)sender;
            foreach (var controllerDevice in controller.Devices) {
                ZWaveDevice zwaveDevice = (ZWaveDevice)controllerDevice;
                Console.WriteLine("Found device with ID = {0} and type {1}",
                                                     zwaveDevice.NodeID,
                                                     zwaveDevice.GetType());
            }
        }
    }
}

This is the result when I ran the program:

image

Frankly I’d much rather have access to the lower-level API — there are things that I can’t do with the ControlThink API that I can’t help but wonder if I might be able to do with the proper Zensys C SDK, but at over $1.5K I guess I’ll have to make do!