Like many developer things, this isn't super-well-documented on Hubitat, but unless you do so "manually" (more on that later), Hubitat only sends Z-Wave commands for drivers when both of these are true:
- either a single formatted Z-Wave command or a list of formatted Z-Wave commands (so technically either a
String
or aList<String>
, though thedef
you have will also work if this is what you end up with) is returned from a method, and - that method is the implementation of (i.e., matches the name of) a driver command (so "command" in a different sense here, things like the
refresh()
method forcapability "Refresh"
or any custom command you declare)
So, while we're missing whatever aaDebug()
is that you mentioned (but I don't see code for), it's apparent from the refresh()
method you provided that it's not returning the formatted commands. Because of that, Hubitat isn't actually sending them for you. You could fix this by moving your log.trace "Exiting refresh"
command somewhere before the last line of that method (though I guess that wouldn't quite make sense) so that runCommandsWithInterstitialDelay refreshCumulativeDataCommands
would be your last line. If you're not familiar with Groovy, this is equivalent to return runCommandsWithInterstitialDelay(refreshCumulativeDataCommands)
(in Groovy or Java)--the return
is optional in Groovy and will be the last expression of your method (if not void
). But basically, the method needs to return the formatted command(s).
If you want to send a Z-Wave command without it being the return value of a (driver) command, then you can do so manually with the sendHubCommand()
method. Something like this, for example: sendHubCommand(new hubitat.device.HubAction(zwaveSecureEncap(zwave.meterV4.meterGet(scale: 0)), hubitat.device.Protocol.ZWAVE))
As an aside, unless there's a reason that isn't apparent from your snippets, you don't need to check whether the device is securely paired: you can just put either a command object or "formatted" string command through zwaveSecureEncap()
, and the platform will take care of security for you if needed. (And state.secure
will only tell you something if you set that somehow yourself; device.getDataValue("S2")
on a C-7 will tell you if it has either S0 or S2, with the exact data value specifying the specific grant[s], and I think .isSecurePairingComplete
would be S0 on a C-5).