Help needed with garden irrigation program selector
Posted: Wednesday 22 May 2019 21:06
Hi, i need some help creating a dzvents stript for a selector switch to be used as some kind of irrigation program selector.
this is what i created so far but i can not figure out how to execute functions with a certain delay. i hope someone can help.
this is what i created so far but i can not figure out how to execute functions with a certain delay. i hope someone can help.
Code: Select all
return {
on = {
devices = {
'Sproeier programma'
}
},
execute = function(dz, device)
local selector = dz.devices("Sproeier programma")
local zone1 = dz.devices("Irrigatie zone 1")
local zone2 = dz.devices("Irrigatie zone 2")
local zone3 = dz.devices("Irrigatie zone 3")
local zone4 = dz.devices("Irrigatie zone 4")
local zone5 = dz.devices("Irrigatie zone 5")
local zone6 = dz.devices("Irrigatie zone 6")
local zone7 = dz.devices("Irrigatie zone 7")
if selector.state == "Alles" then
-- first turn on zone 4 and 1 min later zone 5, then after an hour turn off zone 4 and 5 and turn on first zone 1, then a minute later zone 2,3 and 7
elseif selector.state == "Voortuin" then
-- turn on zone 4 and 1 minute later zone 5, then after an hour turn off zone 4 and zone5
elseif selector.state == "Achtertuin" then
-- turn on zone 1, and 1 minute later zone 2, 3 and 7 and turn them off after an hour
elseif selector.state == "Waterstopcontact" then
-- turn on zone 6 and turn it off after an hour
elseif selector.state == "Off" then
-- force everything to turn off
zone1.switchOff()
zone2.switchOff()
zone3.switchOff()
zone4.switchOff()
zone5.switchOff()
zone6.switchOff()
zone7.switchOff()
end
end
}