runIn with Device

I’m trying to use runIn in a smart app and i’m trying to pass a device variable to the method that is being called and I can’t seem to get it to work. So, in the first method, I am doing the following:

log.debug time
def device = myDevices.find{it.label == name}
log.debug device.label
device.on()
runIn(time, turnOff, [data:device])
}

And that is working perfectly. But when I get to the method that is being called, this doesn’t work.

def turnOff(device){
    device.off()
}

Am I not able to do this? Do I have to “find” the device again from the input “myDevices”? Is that the only thing that will work?

Thanks!!!

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.