Maybe some one can help me to get it working.
What i want is this:
- Turn on the lights in the evening when it becomes dark and turn them off on 10:30.
- Turn on the lights on 6:30 in the morning, but only when it is dark.
I think is is dark from 12 minutes before sunset to 10 minutes after sunrise
In my opinion this should work, but nothing happens in the morning.
I hope someone can tell me what i am doing wrong.
Code: Select all
return { on =
{ timer = {
"12 minutes before sunset",
"10 minutes after sunrise",
"at 22:30",
"at 06:30",
}},
execute = function(dz)
local ochtend_verlichting = dz.groups("Ochtend verlichting") -- group used to switch multiple lights/switches
local checkTimeInMinutes = 6 * 60 + 30 -- 6:30
if dz.time.matchesRule("12 minutes before sunset") then
ochtend_verlichting.switchOn()
elseif dz.time.matchesRule("at 6:30") then
if dz.time.sunriseInMinutes < checkTimeInMinutes then
ochtend_verlichting.switchOn()
end
elseif dz.time.matchesRule("10 minutes after sunrise") or dz.time.matchesRule("at 22:30") then
ochtend_verlichting.switchOff()
end
end
}