How to set up scene to trigger device based on schedule?

I have a scene that opens my gate and garage whenever I come home. I want to add so that only in the evening, so that certain lights would come on and if I use the scene in the daytime, it doesn’t trigger those lights.

I think you want some simple luup code that controls when the scene is “active”. In this case the scene is blocked from 4am to 5am. Welcome to Vera, where nothing is as simple as it seems LOL…

local pStart = “04:00” – Start of time period
local pEnd = “05:00” – End of time period
local allow = false – true runs scene during period, false blocks it
local hS, mS = string.match(pStart,“(%d+)%:(%d+)”)
local mStart = (hS * 60) + mS
local hE, mE = string.match(pEnd,“(%d+)%:(%d+)”)
local mEnd = (hE * 60) + mE
local tNow = os.date(“*t”)
local mNow = (tNow.hour * 60) + tNow.min
local mWeekday = os.date(“*t”).wday – Sunday = 1
if mEnd >= mStart then
return (((mNow >= mStart) and (mNow <= mEnd)) == allow)
else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)
end

NOTE: There is similar code that can detect sunset and sunrise.

Check out the thread http://forum.micasaverde.com/index.php/topic,18679.0.html (Conditional Scene Execution). I suspect the statement “luup.is_night()” is all you need.

I would create two scenes, both triggered the same. The one scene that controls the light has the “is_night” test to see if it should run. The other scene just runs.

thanks for all the info. Finally got a chance to read over it. Correct me if I’m wrong but that link you provided seems to disable/enable the entire scene based on time of day. Is it possible to run the same scene but only trigger the device at certain time of day?

At the moment, my scene looks like this

Arriving: Manual trigger
Device action: immediately Garage, Gate, Lights 1, lights 2, lights 3 - On
Delay action: 1 sec, Garage, Gate - Off

So how would I write the LUN so that lights 1, 2 and 3 only turn on say between 5pm to 7pm when I trigger scene “Arriving”

Trying to avoid having too much clutter of scenes

In scene processing … once you start processing device commands (immediate and delayed) … the code is going to do all of the actions … there is no stopping it.

OPTIONS are:

  1. Different Scenes for different set of actions.
  2. Call the Actions in LUA code with conditional code to decide which actions to run.
  3. PLEG with different conditions to decide with actions to run.