Error in simple script -- groovy.lang.MissingMethodException: No signature of method:

I am getting and error which I have no idea what it means… new to Groovy but the script is fairly basic. Should turn on a light switch on and then after x seconds turn it off. After the x seconds I get the following error:

groovy.lang.MissingMethodException: No signature of method: scriptid.null() is applicable for argument types: () values: []
Possible solutions: url(), url(java.util.Map), dump(), now(), run(), dump()

Any guidance?

def updateSwitches() {
def device = switches.find { it.id == params.id }
if (!device) {
httpError(404, “Device not found”)
} else {
device.on()
log.debug 'Turned on’
runIn(10, turnOffSwitch(device))
}
}

def turnOffSwitch(device) {
device.off()
log.debug ‘turned off’
}

you cannot pass args that way in runIn. See docs.

1 Like

thanks for that… so that being the case how can I handle this to turn off the switch that was turned on? How would turnOffSwitch now which switch to turn off?

you can pass arguments with runIn, just not in the way you showed.

You can store what is turned on in state variables, and have the off method use the state variables.

do you have an example you could share as to how to pass args using runIn?

Here’s how to pass parameters in a map

http://docs.smartthings.com/en/latest/smartapp-developers-guide/scheduling.html?highlight=runin#passing-data-to-the-handler-method

Sometimes it is useful to pass data to the handler method. This is possible by passing in a map as the last argument to the various schedule methods with data as the key and another map as the value.

in your case it would be
runIn(60, turnOffSwitch, [data: [switch: device]])

and in turnOffSwitch
data.switch.off()

2 Likes