Zwave response command usage

Hey, I’m tinkering around device-handler and zwave devices, and I have an issue to understand the difference between:

def zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {
    log.debug "${device.displayName} parameter '${cmd.parameterNumber}' with a byte size of '${cmd.size}' is set to '${cmd.configurationValue}'"
    createEvent([name: "coin", value:"coin"])

def zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {
    def level = cmd.batteryLevel > 0 ? cmd.batteryLevel.toString() : 1
    createEvent([ name: "battery", unit: "%", displayed: false, value: level ])

def configure() {

    def cmds = []

    cmds << zwave.configurationV1.configurationGet(parameterNumber: 24).format()
    // and this
    cmds << response(zwave.batteryV1.batteryGet())

    delayBetween(cmds, 500)

When zwave.configurationV1.configurationGet is triggered, the device will send (when awake) an event which will be parsed and will call zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport to deal with the reponse.

But for response( ? what is the workflow ? response will return the result of the battery event callback ? (for example in this case).

What is the use case ?

What will contain cmds ?

Maybe @duncan could help me understanding this quite easily :smile:

Thanks !

Well I may finally got it.

response is used to send back zwave commands to the device from a the parse function.

The things that I don’t understand is that in this code:

The configure function

def configure() {
	log.debug "Configuring Device For SmartThings Use"
    def cmds = []
    // send associate to group 3 to get sensor data reported only to hub
    cmds << zwave.associationV2.associationSet(groupingIdentifier:3, nodeId:[zwaveHubNodeId]).format()

	// turn on tamper sensor with active/inactive reports (use it as an acceleration sensor) default is 0, or off
	cmds << zwave.configurationV1.configurationSet(configurationValue: [4], parameterNumber: 24, size: 1).format()
    cmds << zwave.configurationV1.configurationGet(parameterNumber: 24).format()
    // temperature change report threshold (0-255 = 0.1 to 25.5C) default is 1.0 Celcius, setting to .5 Celcius
    cmds << zwave.configurationV1.configurationSet(configurationValue: [5], parameterNumber: 60, size: 1).format()
    cmds << zwave.configurationV1.configurationGet(parameterNumber: 60).format() 
    cmds << response(zwave.batteryV1.batteryGet())
    cmds << response(zwave.versionV1.versionGet().format())
    cmds << response(zwave.manufacturerSpecificV2.manufacturerSpecificGet().format())
    cmds << response(zwave.firmwareUpdateMdV2.firmwareMdGet().format())

	delayBetween(cmds, 500)

Is mixing both response and commands… So if I understand it well:

  • when called by the user, only commands are played and responses are discarded
  • when called from parser zaveEvent overload, only response are played and commands are discarded

Am I right ?

I think that is a copy/paste mistake – response is meant to only be used from parse. I think it works fine as part of a list of actions returned from a command method, but is redundant.

1 Like

Thanks for your response, I finally manage to understand and Yes I think this is a copy/paste mistake. I hope you don’t mind to be mentioned for Zwave related questions (nobody on IRC sound zwave skilled).