I am new to the Smartthings platform and is now trying out some simple stuff. Wanted to write a program that at button press sends a notification with a certain delay. For this I am using the runIn() function. However when I capture the button press and call the runIn() with a delay, it instantly calls my function instead of delaying. It does not seem to matter what delay I use, it always returns instantly. What have I missed? Thanks!
Ok, solved it. I get this behavior because of the sendMessage(Evt) in runIn call. It cannot pass an event, and I should only use the name of the function: runIn(5 * 60, sendMessage) for it to work. Confusing though that the sendMessage call was done.
Might I politely suggest you’ve overthought that one? Just as 5 * 60 gets evaluated and becomes 300, sendMessage(evt) gets evaluated and calls sendMessage.
True! However I expected that the whole expression would fail, since the second argument to runIn() is faulty. I thought the evaluation of that would generate an exception, which would have been helpful to find the fault. But clearly that is not how groovy works
Replace dealyTime with the dealy you want (in integer)
Replace methodCalled with the function you want to run
Replace dataToPass with the data you want to pass but keep the brackets and the data: