Device discovery in Z-Wave

January 7th, 2010 by Henrik Leidecker Jørgensen | Edit this entry Leave a reply »

It is possible to request a list of connected devices from the Z-Wave controller. This article will take a look at the requests and responses related to device discovery in Z-Wave.
The article is part of a series of articles with focus on the Z-Wave protocol and how to implement it in C#. Reading the previous articles will be an advantage, but it is not mandatory.

It is possible to have 232 Z-Wave devices in one network. Each device is identified by a node id. A number of common attributes are defined for the devices e.g. type. The Z-Wave protocol defines numerous device types but only the Controller, Switch and Dimmer will be addressed in this article.
It is relatively straight forward to identify the devices in the Z-Wave network handled by the Z-Wave controller.

  1. Ask the Z-Wave controller about the registered node ids
  2. Ask the Z-Wave controller about the type linked to each of the node ids

The concept of the callback id was introduced in the previous article ‘The Z-Wave protocol in C# – Part 3‘. A callback id can be added to the requests presented in this article, but the callback id will not be part of the connected responses. Zensys have for unknown reasons decided only to specify the callback id for certain request/response pairs. The callback id is therefor left out on all the requests shown.

The message required for requesting the information about registered devices can be seen below.

/*
    0x01, 0x03, 0x00, 0x02, 0xFE
*/

The devices and configuration from the article ‘The Z-Wave protocol in C# – Part 3‘ are reused and result in the following response from the Z-Wave controller.

/*
    0x01, 0x25, 0x01, 0x02, 0x04, 0x00, 0x1D, 0x21, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0xE7
*/

The interesting part here is the 29 bytes following 0×1D. They represent the nodes in the Z-Wave network as a bit mask. One bit for every node. This implies that 232 nodes can be connected to the Z-Wave network (29 byte * 8 bits / byte = 232 bit).
The first byte following 0×1D is 0×21. This byte masks node 1 to 8. The binary representation of 0×21 is 0010 0001. It becomes clear that bit 1 and 6 are set by checking the binary representation from right to left – devices are registered in the network with node id 1 and 6.
Let’s have a look at the 6th byte following 0×1D. This byte masks node 41 to 48. The value is 0×04 and in binary representation this is 0000 0100. A device is registered with node id 43.
The result is that a number of three nodes in total are registered in the network (1, 6 and 43).

The next step is to identify the type of each of the registered devices. The following message is being used for the type request.

/*
    0x01, 0x04, 0x00, 0x41, node id, checksum
*/

This is the response for node 43.

/*
    0x01, 0x09, 0x01, 0x41, 0xD1, 0x8C, 0x00, 0x04, 0x10, 0x01, 0xFE
*/

Byte 9 is the one that describes the type that we are looking for. In this article only three devices appear.

/*
    0x02:    Controller
    0x10:    Switch
    0x11:    Dimmer
*/

So the device with node id 29 is a switch.

The above protocol elements will be implemented in C# in the upcoming article.
A switch is not just a switch – some supports power metering and some not. The Z-Wave protocol supports a way to request the capabilities of a device. One of the later articles will cover this aspect.

Advertisement

2 comments

  1. Luis Silva says:

    Hi,
    i’ve been reading these post.
    I have one device, when i request all the devices of my network i get:
    01 25 01 02 05 00 1D 03 00 00 ….
    So as i only have one device, when we see 03 in binary it gets:
    0000 0011 -> 1st and 2nd bits with value one.
    This is not coherent with what you said. Maybe the first bit refers to having or not any device in the network.
    What do you think about this?
    I’m using a switch/power meter, Qees Power. If you want i can run some tests that may be useful to you and the community.

    I’m looking forward your next article, when are you publishing it?

    Best regards,
    Luis Silva

  2. Hovo says:

    Im still new to the z-wave protocol so don’t take anything I say as truth.
    I think the receiver ‘usb’ stick counts as a device,
    also I think the receiver has a memory, if the device is paired but not turned on I would assume that it would still show up in the list..

    It would be nice to see if this is the case.

    Cheers

Leave a Reply