Turning lights on for a certain amount of time

Forgive me, I’m new at Vera but learning a lot. I’m trying to turn a lighting module on from sunset +6 hours when my alarm is armed to stay mode. I’ve got the stay mode on my alarm figured out but I can’t figure out how to turn the light off after 6 hours.

Can anyone help me with how to go about doing this? I’m on UI5.

Welcome! This is definitely something you can do with PLEG. See here: [url=http://forum.micasaverde.com/index.php/topic,21603.0.html]http://forum.micasaverde.com/index.php/topic,21603.0.html[/url]

PLEG will allow to do much more than the built in Scene Editor.

Member RexBecket made a superb tutorial on conditional scenes with plenty of LUUP examples. Have a look at http://forum.micasaverde.com/index.php/topic,18679.msg154756.html#msg154756 which should help you solve your problem.

An even easier way would be to use the stay mode on your alarm as a trigger and run a deleyed scene 6 hours after that. Which can be done without LUUP even.

thanks @qwen3579, I’ll check out PLEG.

@BOFH-I can turn on the light each time my alarm comes on with no problem, it’s the turning off that I can’t figure out. I’d like for this to only happen after sunset also. I’ve looked briefly at the link you posted but it’s too late for me to be thinking this hard. I’ll look at it again tomorrow…

Thanks for the replies!

Under UI5, in the scene you use to switch the light on.
Under the LUUP tab, enter below line in the code box and click teh SAVE LUA button

return luup.is_night() 

(This will make the scene only run at night)

Under the Schedule tab, click on the down arrow in the IMMEDIATE BOX and select Manage delays.
In the pop up window that comes up, enter 6 in the ADD box at the bottom and clock the Hours button. Then click close.
Go to the Advance tab.
Pick your light from the ‘Device: Please select drop’ box and then click add.
You should now have an entry for that light under the Delay: 6 hours entry.
Click the ‘Please Select’ box next to the name of you light and select the SETTARGET entry
Enter 0 into the newTargetValue box to have Vera switch off the light. (Value 1 will switch it on)
Save the scene.

Basically, the scene will only run at night and 6 hours after it initially ran and switched on the light, it will switch it back off again.

Note that with a 6 hour delay there is a good probability that Vera will restart during that time.

If you do this with a scene and Vera restarts, the delayed action will never run.

If you do this with PLEG (either as two conditions, or a delayed action, similar to the scene solution) the delayed actions will work as expected even if Vera restarts.