I have a set of hallway lights that are on a GE dimmer switch. However, the lights will primarily be turned on and off with a Leviton in-wall 4 button scene controller. There is no direct association between the scene controller and the lights - it goes through Vera.
Here is my concept— I don’t want to ‘waste’ buttons on my controller by having each button set a different lighting level. I want a single Vera scene to set the lighting level based on the time of day. I imagine that if I turn the lights on during the day, I want them full bright. If I turn them on in the evening, I want a dimmed level. And if I turn them on in the middle of the night, I want a low level. I can’t seem to get this working and am looking for the LUA help. If you are a real expert, I’d actually like to go one step further, and have the code also see if the lights are already on and if they are on already when the scene is activated, they go to full bright (so you can get full brightness during a normally dimmed period still using only one scene button).
The following is my attempted code:
local t = os.date(‘*t’)
local current_second = t.hour * 3600 + t.min * 60 + t.sec – number of sec since midnight
local highhr = 6 * 3600 + 0 * 60 – 06:00
local medhr = 18 * 3600 + 0 * 60 – 18:00
local lowhr = 21 * 3600 + 0 * 60 – 21:00
local halldimmer = 54
if (current_second > highhr) and (current_second < medhr) then
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “100”}, halldimmer)
else
return false
end
if (current_second > medhr) and (current_second < lowhr) then
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “50”}, halldimmer)
else
return false
end
The GUI scene itself then turns the light on at the middle of the night level. That way all issues with the midnight crossover would seem to be avoided in the LUA code.
The results I am getting with this seem to be my 100% light during the day, but no action at other times.
Thanks for your help.