Custom Device Attributes and Commands: Subtleties

Dumb and dumber…

While trying to execute my Custom Device Command reportNext() from a SmartApp, the Command WAS executed, but the SmartApp aborted immediately after with this luminous (!) error message :

"groovy.lang.MissingMethodException: No signature of method: physicalgraph.device.CommandService.executeAction() is applicable for argument types: (physicalgraph.device.cache.DeviceDTO, java.lang.Boolean) values: [JJG, true] @ line 93"

Guess what : the error was NOT within my SmartApp @ line 93 but instead in my Custom Device Handler, where adding a single line just before the exit of my Custom Command Handler solved my problem :

def reportNext() {
    state.forcedWakeUp = true
    return []  // <-- absolutely needed to avoid an abort in the calling SmartApp !
}

Sooooo many subtelties… :frowning:

Yes… It takes some careful reading and translation of the error message to figure out what it means.

When a SmartApp calls a Command, the Platform actually uses executeAction(<command>) method to invoke it.

And command() should be of Type void (i.e. No return code), per Documentation. I wonder if some non-void types work, but with no return statement, Groovy returns the value of the last expression, which, for your command, is a boolean. Thus, at line 93, the Platform couldn’t find a way to execute a command of type boolean.

https://graph.api.smartthings.com/ide/doc/device