Newbie Scene Question

Just purchased the Vera2…think it has the “UI4” on it. Need to set a back door sensor to turn on a light between sunset and sunrise. I’ve used the Wizard and set up the sunset/sunrise timers, as well as the sensor to turn on the light. But it works all the time, instead of just the nighttime hours. Any pointers you can provide me would be appreciated. Thank you!

Ah, the elusive “if” command. If you do a search here you’ll find some code you can copy/paste into the scene but I’ve never tried it.

Here is some code that was shared a while back for this kind of thing. You’d edit the example times and add this to the LUUP tab in your scene. If the time when the scene is activated is between the two times, it’ll run the scene, otherwise it will stop with “return false”, meaning the scene won’t run.

local t ='*t')
local current_second = t.hour * 3600 + t.min * 60 + t.sec     -- number of seconds since midnight
local min_time_in_seconds = 16 * 3600 +  0 * 60             -- 16:00
local max_time_in_seconds = 21 * 3600 + 15 * 60             -- 21:15

if (current_second > min_time_in_seconds) and (current_second < max_time_in_seconds)
-- do something
return false

This and other examples are here: [url=][/url]

An alternate way to accomplish this is to use a scene to arm the sensor at sunset and a second scene to disarm the sensor at sunrise. The lights get turned on by creating a third scene that turns the light on when the ARMED sensor is tripped. (Arming appears to just be a state for the sensor that Vera keeps track of).

At least, this is how I accomplish this and doesn’t require writing any Lua code.

Ah yes, Good choice.

If you don’t want to get into coding, mvakoc’s method works great.