@April, is there a better place to post this? If so, please move it…
I’ve encountered an interesting error in the documentation that I’d like to report…
The code sample in this section:
http://docs.smartthings.com/en/latest/device-type-developers-guide/building-z-wave-device-types/building-z-wave-device-types.html#sending-commands-in-response-to-events
… will generate an error. The error is in this line:
result << createEvent(descriptionText: "${device.displayName} woke up", displayed: false)]
(There’s a closing square bracket at the end, but not an opening one anywhere.)
The entire “createEvent” call must be in square brackets in order for the code to “compile” (no brackets results in: groovy.lang.MissingMethodException: No signature of method: java.util.LinkedHashMap.leftShift() is applicable for argument types: (physicalgraph.device.HubAction)…)
However, even if that error is corrected by adding an opening square bracket before “createEvent”, the code is still not functional. In that case, result will end up looking something like this:
[[[descriptionText:Office Motion Sensor woke up, isStateChange:false, displayed:false, linkText:Office Motion Sensor], 8002, delay 1200, 8408]]
The commands (8002, 1200ms delay, 8408) never get sent to the device. (I’ve been playing with this code for the past 2 hours… ) I’m not fluent enough with groovy to understand the nesting of maps within maps and how things should work, but I suspect the problem is… well… the nesting of maps within maps.
Here’s some code that DOES work (but doesn’t do the same as the example):
def cmds = []
cmds << zwave.batteryV1.batteryGet().format()
cmds << "delay 1200"
cmds << zwave.wakeUpV1.wakeUpNoMoreInformation().format()
response(cmds)
It sends the commands to the hub properly, but doesn’t create an event. I’m still working on a way to create the event AND send a response to the hub… (I’ll reply when I find it. None of the examples I’ve seen floating around seem to actually work properly.)