Documentation ERRORS (not suggestions)

@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:

… 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. :wink:

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()

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.)

Okay, so the only solution seems to be using sendEvent() (instead of createEvent). Also, “response()” needs to be called on the combined responses, not on each one. So, to “fix” the example mentioned:

def zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)
    sendEvent(descriptionText: "${device.displayName} woke up", displayed: false)
    def result = []
    result << zwave.batteryV1.batteryGet().format()
    result << "delay 1200"
    result << zwave.wakeUpV1.wakeUpNoMoreInformation().format()

    response(result) // returns the result of reponse()

Errors are bad. If they are straight-forward to fix, feel free to make a pull request in the git repo with our documentation.

I’m planning on digging deeper into this area this week, probably starting Tuesday.

Thanks for finding this, it’s really appreciated!

No problem, Jim. You can just help me nag @April for my “I broke SmartThings” t-shirt. :stuck_out_tongue:

As for the pull request, I’m not going to be able to do that in the short term. I’m in Windoze right now, and never bothered to install git on it. (I wonder if there’s a way to do it on the github website without a local git installed… I’ll have to try that.)


@garyd9 I am ALWAYS nagging @April. In fact, after putting up with me for the last 36 hours pretty much continuously, she might just reach over and knock me out now :smile:

I’ll try and review/update based on your suggestions tomorrow if I can carve out a few un-interrupted minutes.

I think you’ll get a “I broke @april’s heart” t-shirt because you keep making that joke! :stuck_out_tongue: I’ll never make a “I broke SmartThings” shirt, only “I broke @garyd9’s hope for a dream of a tshirt I’ll never print.”


Yes you can edit directly on github and create the pull request from there message me if you want help going through that.

Otherwise github does have this

1 Like

Another alternative Git client to consider is SourceTree from Atlassian (available for free for both Windows and Mac):

@Jim, I made the pull request as …umm… requested. (I was able to do it completely via github without anything locally.)

What I did NOT include was an explanation of why “sendEvent()” is being used instead of “createEvent().” I’m afraid I tend to be a bit too blunt for good “user friendly” documentation.

I couldn’t think of anything better than: createEvent() can’t seem to used (and expected to work) when also using response(). As a workaround, just use sendEvent() and realize that the ST team is entirely too backlogged to fix something that can be trivially worked around."

(I bet you can’t guess what I do for a living… heh…)

@garyd9, Nice! Really appreciate it!

I merged in the PR.

Someday, SmartThings is going to hire a docs guy to clear this kind of stuff up.

Oh, wait…

I’m excited to dig into this stuff this week.

1 Like

Has something changed in the platform since Saturday? The code that wasn’t working before (and generated the whacky nested maps within maps 3 deep) now, today, seems to be working as expected. Instead of the example I posted above then: [[[descriptionText:Office Motion Sensor woke up, isStateChange:false, displayed:false, linkText:Office Motion Sensor], 8002, delay 1200, 8408]]
Today, very similar code is creating:

(notice the number of square brackets)

PLEASE tell me that something on the server side has changed. Pretty please? This is one time that I’d rather have a moving target. The alternative is that I’m losing what little is left of my mind.

1 Like

:slight_smile: just going to leave this here… ~ doot doot doo~ /whistle