SmartThings Community

How to send z wave command inside 'runIn' handler


(Simon Wood) #1

Trying to figure out how I can send a z wave command inside a runIn handler. The return type is void so it’s not like parse.

Thanks

Simon


(Tony Fleisher) #2

I think the most common approach is to have the scheduled method call a command method.
I believe that you can also use sendHubCommand(), though I can’t find where this is documented.


(Simon Wood) #3

Thanks Tony.

Had another play, couldn’t find a syntax that allowed me to execute a device command from within the device handler (apart from a tile action). But a little searching through the other device handler templates revealed the way to get sendHubCommand working:

	def cmds = []
    cmds << new physicalgraph.device.HubAction(zwave.basicV1.basicSet(value: 0x00).format())
    cmds << new physicalgraph.device.HubAction(zwave.switchBinaryV1.switchBinaryGet().format())
    sendHubCommand(cmds)

(Todd Wackford) #4

https://docs.smartthings.com/en/latest/smartapp-developers-guide/scheduling.html#passing-data-to-the-handler-method