Documentation ERRORS (not suggestions)


(Gary D) #1

@April, is there a better place to post this? If so, please move it…

@Jim

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


(Gary D) #2

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

(Jim Anderson) #3

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!


(Gary D) #4

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


(Jim Anderson) #5

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


(April Wong) #6

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


(Jeff Beck) #7

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 https://windows.github.com/


(Chuckles) #8

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


(Gary D) #9

@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…)


(Jim Anderson) #10

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


(Gary D) #11

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.


(April Wong) #12

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