[quote=“electricessence, post:8, topic:172461”]The settimeout idea is really good. I need to do that myself. My MCE scenes don’t have dependencies so if I fire one off when the computer is off, it eventually fails, but no biggie…
Using a “call_timer” will allow the scene to complete and the failure actually occurs in another thread (so to speak).
Here’s a sample of code I used before I found the timer and combo switch:
[code]function deferLockScene(package)
if(lockInsecuredId == package) then
local veraUri = “urn:micasaverde-com:serviceId:HomeAutomationGateway1”
luup.call_action(veraUri , “RunScene”, {SceneNum = “1”}, 0)
end
end
lockInsecuredId = os.time() … “”
luup.call_timer(“deferLockScene”, 1, “1m”, “”, lockInsecuredId )[/code]
What this code does is sets a global variable to ensure that only the very last ‘deferLockScene’ actually executes and nothing executes prematurely.
If there was a ‘cancel_timer’ function I would have done this differently, but they don’t have that yet in UI5. (Similar to JavaScript’s setTimeout and clearTimeout).
Are you using the WakeOnLAN plugin to make sure the PC wakes up first?[/quote]
This is getting a bit complex for my simple understanding of programming, if I have clear instructions to follow I can get by but to start code new stuff on my own I’d be lost. I will have to read the above again for half an hour lol to try and understand what that code does!
I am not using WOL with this scene no.
Here is what I have setup.
Scene1: Motion Detected - Lights On
Scene is triggered by Foscam Sensor on outdoor IP Cam (If Armed)
Scene turns on Light in the kitchen
Scene starts a 60 second count down timer.
Scene has all that Luup code in it I posted above - So if MCE PC is on I get a popup and it jumps to live video for camera.
If MCE PC is asleep then so am I probably! But scene continues to run and the Light is still switched on within about 25 secs?
Scene2: Motion Detected - Lights Off
Scene is triggered by CountDown Complete (CountDown Timer)
Scene turns off the Light in the kitchen.
It seems to work fairly well as I have it setup now, if the MCE PC is on or asleep… But always happy to try and learn new things. Loving VeraLite only been using it a week and I have pretty much fully recreated my old Home Automation system based on mControl on my WHS server and then some!
Thanks