Determine if device is sleepy or listening?

(codersaur) #1

I’m writing a device handler for a device that normally runs on a battery, but can be mains powered.

Its behaviour is different in each mode, which is dependant on the power state when it is joined to the network (i.e. Listening vs sleepy). I can see that if it’s joined to the network when powered, it’s raw description will contain “zw:L …” whereas if it is in battery mode it will be “zw:S …”.

What is the recommended (supported) way to determine if the device is in Listening or Sleep mode, from device handler code? (as ideally I want a single DTH to work in both modes). Is this this information contained in the device properties somewhere?

Alternatively, I believe the information should be available from a Z-wave NodeInfo command, but I’m not sure how to request one.

FAQ: How does one check if a zwave device is in active or passive mode
(codersaur) #2

Well, I tried this, but it doesn’t return anything…

cmds << zwave.zwaveCmdClassV1.requestNodeInfo()

I also tried accessing…


But it just errors:

java.lang.SecurityException: Getting properties on class physicalgraph.device.Device_$$_javassist_17 is not allowed

Any ideas? @duncan @tslagle13 ?


@duncan already responded on this topic in the FAQ thread. :sunglasses:

(codersaur) #4

SOLVED. I managed to get the info from device.rawDescription (which now seems to be working again (?))


switch (device.rawDescription.tokenize(" ")[0].tokenize(":")[1]) {
	case "L":
    	log.debug "Device is listening, not secure"
	case "Ls":
    	log.debug "Device is listening, and secure"
	case "S":
    	log.debug "Device is sleepy, not secure"
	case "Ss":
    	log.debug "Device is sleepy, and secure"
	case "F":
    	log.debug "Device is beamable, not secure"
	case "Fs":
    	log.debug "Device is beamable, and secure"
    	log.debug "Unknown"


private isListening() {
    return device.rawDescription.contains("zw:L")

However, this method only works for devices that have been joined after the new fingerprint format was introduced. :expressionless:

@duncan @tslagle13 can you explain why requestNodeInfo() doesn’t currently work (or at least the returned NIF is not passed to the device handler’s parse() method). Also, is the method above going to be reliable?

(Duncan) #5

There’s a new helper for parsing the rawDescription that hasn’t made it into the docs yet: getZwaveInfo()"L")

(codersaur) #6

Thanks, just tested it. It still only appears to work for devices that joined after the new fingerprint format was introduced. Is there any way to get the same info for older devices (without excluding/re-including them)?

(Duncan) #7

The only time I’ve had to deal with that is the Aeon Multi 6, which helpfully sends a non-standard configuration report to tell you whether it’s plugged in.

I can’t think of any way to get that info from the DTH with an old-style rawDescription. Which device are you working on?

(codersaur) #8

Fibaro Flood Sensor (v1)

(Duncan) #9

Ah, cool. I didn’t realize it joined as a listening device when it had wired power.

Node Info Frame reports are intercepted by the Z-Wave protocol. They don’t show up like normal device commands. I think it will make more sense to make it so older devices get updated to the new raw description format vs add new ways for DTH to receive device info.