Determine if device is sleepy or listening?

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.

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

cmds << zwave.zwaveCmdClassV1.requestNodeInfo()

I also tried accessing…

device.device.rawDescription

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:

1 Like

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

E.g.:

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

Or:

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?

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

zwaveInfo.zw?.startsWith("L")
2 Likes

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)?

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?

1 Like

Fibaro Flood Sensor (v1)

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.

1 Like