Confused Again on zwave command format

Working on a battery device driver, and ran into something I don't get. I'm quite certain it is something I'm missing/not understanding but it is eluding me...

This is how I used to do the command list building and sending. This works when said battery device is USB powered, but DOES NOT work when it is battery powered (when battery powered I'm doing it in the wake notification method):

def cmds = []
cmds << secure(zwave.configurationV2.configurationSet(scaledConfigurationValue: 1, parameterNumber: 1, size: 1).format())
cmds << secure(zwave.configurationV2.configurationGet(parameterNumber: 1))
delayBetween(cmds, 500)

This always works:

def cmds = []
cmds << sendHubCommand(new hubitat.device.HubAction(secure(zwave.configurationV2.configurationSet(scaledConfigurationValue: 1, parameterNumber: 1, size: 1)), hubitat.device.Protocol.ZWAVE))
cmds << sendHubCommand(new hubitat.device.HubAction(secure(zwave.configurationV2.configurationGet(parameterNumber: 1)), hubitat.device.Protocol.ZWAVE))
delayBetween(cmds, 500)

I really don't get why the 1st version doesn't work?

Try this out.. These are the methods I use:

void sendToDevice(List<String> cmds, Long delay = 300) {
    sendHubCommand(new hubitat.device.HubMultiAction(commands(cmds, delay), hubitat.device.Protocol.ZWAVE))
}

void sendToDevice(String cmd, Long delay = 300) {
    sendHubCommand(new hubitat.device.HubAction(zwaveSecureEncap(cmd), hubitat.device.Protocol.ZWAVE))
}

List<String> commands(List<String> cmds, Long delay = 300) {
    return delayBetween(cmds.collect { zwaveSecureEncap(it) }, delay)
}

Then you just:

sendToDevice(cmd.format())

or

sendToDevice(List<String> of cmd.format())

I use these methods for everything I send from my drivers..

Remember cmd.format() gives back a string..

So start your list as

List<String> cmds = []

then

cmds.add(cmd.format())

and finally

sendToDevice(cmds)

Thanks, as always, Bryan!

I'll try that out. I'm sure it works, as you are already using it.

Anytime

And, of course... It worked perfectly doing it your way.

:heart:

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.