Page 1 of 1
Dzvents turn on garden lights when time is x minutes before sunrise
Posted: Monday 24 September 2018 13:09
by snellejellep
Since the days are getting shorter again i want my garden lights to turn on in the morning.
Current situation:
I am using dzvents to turn on a group of lights at sunset and turn them off at 1.00 at night.
Request:
Add to the above script the following:
Turn on at 6.00 when sunrise time is 6.30 or later and turn off at sunrise.
The request above is something i can not seem to get to work.
Re: Dzvents turn on garden lights when time is x minutes before sunrise
Posted: Monday 24 September 2018 19:05
by snellejellep
My script right now is:
Code: Select all
return {
on = {
timer = { "at sunset",
"at sunrise",
"every 5 minutes"
}
},
execute = function(dz, device)
local garden_lights = dz.groups("Tuinverlichting") --group used to switch multiple garden lights/switches
local morningtime = "06:30" --time in minutes after midnight sunrise should be for the garden lights to turn on
if dz.time.matchesRule("at sunset") then
garden_lights.switchOn()
elseif dz.time.matchesRule("at 1:00") then
garden_lights.switchOff()
elseif (sunriseinMinutes.matchesRule('after 6:30')) and dz.time.matchesRule("at 6:00") then
garden_lights.switchOn()
elseif dz.time.matchesRule("at sunrise") then
garden_lights.switchOff()
end
end
}
Re: Dzvents turn on garden lights when time is x minutes before sunrise
Posted: Tuesday 25 September 2018 0:34
by waaren
snellejellep wrote: Monday 24 September 2018 13:09
I am using dzvents to turn on a group of lights at sunset and turn them off at 1.00 at night.
Request: Add to the above script the following:
Turn on at 6.00 when sunrise time is 6.30 or later and turn off at sunrise.
You are close; can you try this ?
Code: Select all
return { on = { timer = { "at sunset",
"at sunrise",
"at 01:00",
"at 06:00",
}},
execute = function(dz)
local garden_lights = dz.groups("Tuinverlichting") -- group used to switch multiple garden lights/switches
local checkTimeInMinutes = 6 * 60 + 30 -- 6:30
if dz.time.matchesRule("at sunset") then
garden_lights.switchOn()
elseif dz.time.matchesRule("at 6:00") then
if dz.time.sunriseInMinutes > checkTimeInMinutes then
garden_lights.switchOn()
end
elseif dz.time.matchesRule("at sunrise") or dz.time.matchesRule("at 1:00") then
garden_lights.switchOff()
end
end
}
Re: Dzvents turn on garden lights when time is x minutes before sunrise
Posted: Tuesday 25 September 2018 18:55
by snellejellep
thanks! i implemented it and will see if the lights will turn on.
Re: Dzvents turn on garden lights when time is x minutes before sunrise
Posted: Wednesday 26 September 2018 7:53
by snellejellep
It works great! Thanks!