Second log.debug in on method causes havoc

I have another puzzle.

I have this method (which comes straight out of the sample dimmer device handler with the addition of one log.debug, and it works fine:

def on() {
log.debug "${state.myName} on()"
delayBetween([
zwave.basicV1.basicSet(value: 0xFF).format(),
zwave.switchMultilevelV1.switchMultilevelGet().format()
],5000)
}

However, if I add a second log.debug after the delayBetween(), it acts as though the delayBetween is never executed.

def on() {
log.debug "${state.myName} on entered"
delayBetween([
zwave.basicV1.basicSet(value: 0xFF).format(),
zwave.switchMultilevelV1.switchMultilevelGet().format()
],5000)
log.debug “${state.myName} on completed”
}

Color me puzzled. (Removing ${state.myName} makes no difference, of course).

The return in device handlers is the commands, so they must be last in the method.

You made log.debug last in the method, so the result of the log.debug command is what is returned to execute rather than the commands in the delayBetween.

Nothing after the delayBetween…

Thanks. I had kind of come to that conclusion after I made the post. Is that actually documented somewhere - I was about to look, and will look.

[This is also a Groovy pet peeve of mine. By using “def” they make code a lot less self-documenting. Had the method indicated it returned a list of commands, well, then it would have been pretty obvious.]

Mine, as well. I ALWAYS use return statements for documentation reasons and it helps keep me sane. And makes it obvious to another person reading the code for the first time…