I want to use a scene to run various luup commands, but I need to have a delay between some of the commands. For example I switch on my TV with a on/off switch, but then need to wait a few seconds for the next command. This is just one example. Most of the commands are IR based, here is an example of one:
so if I wanted to run a similar command after that, but want to wait lets say 10 seconds before execution, how could I do that ? The normal way for scene delay ‘manage delays’ does not work in this case
luup.call_delay() is what you need. I’m mobile so can’t point you at examples but the forum is stuffed with them, so do a search and you’ll find plenty.
I have searched on the forum, but have not seen the function with just a delay, only as a call to a function after a delay. But I think it might work like this:
luup.call_delay(10)
with 10 being the 10 second delay. I am not sure if I need to specify a function. My code would look like this then:
It did look to easy… so i’ll have to define the IR command as a function, then call it in the luup delay I guess. I’ll do a search to see if I can find any examples. I’ve never done anything in Luup so newbie in that area. But its probably good to learn as it should give me more flexibility in the long run
Started some research on the forum, there is a function luup.sleep() I believe, which is defines in milliseconds. Could I use that ?
I thought you’d find that. luup.sleep() is dangerous and can cause the Luup engine to deadlock and restart. For more than about two seconds’ delay, I wouldn’t trust it.
The easy way out did not work again… I did see that and thought there could be a problem. I was trying to avoid learning of how to define a function…
I have a few IR macros (SQ remote IR) I am trying to replicate, I think I will not need more than 0.5 sec delays so I can probably use the luup.sleep, but there are others where I need longer delays. So back to doing research on how to use and define functions…
Rather than use Call Delay to sleep, which can cause problem to the Vera, suggest using call_timer instead.
function TimeUnlockFrontDoor(stuff)
-- Do whatever you wanted to do when the time intrerval happens
end
luup.call_timer("TimeUnlockFrontDoor", 1, "10", "", "")
Look up Call Timer in the wiki for the explanation of the parameters.
Richard, taking advantage you here, what your evaluation about the UI7 versus our existing hardware Vera3… will we must change ? vera home control launch an best hardware ?
Best Home Automation shopping experience. Shop at Ezlo!