I have a script where my pool pump goes on/off at specific times.
Code: Select all
return {
on = {
timer = { "at 12:00",
"at 16:00",
"at 20:00",
"at 23:59",
},
devices = { 'ZwembadPH' }
},
execute = function(dz)
local Zwembadpomp = dz.devices(47)
local ZwembadPH = dz.devices(108)
if dz.time.matchesRule("at 12:00") then
Zwembadpomp.switchOn()
elseif dz.time.matchesRule("at 16:00") then
Zwembadpomp.switchOff().checkFirst()
end
if dz.time.matchesRule("at 20:00") then
Zwembadpomp.switchOn()
elseif dz.time.matchesRule("at 23:59") then
Zwembadpomp.switchOff().checkFirst()
end
if ZwembadPH.state == "On" then
Zwembadpomp.switchOn().forHour(5)
end
end
}
Do I have to make another 'if' in the specific time rule? Something like:
Code: Select all
if dz.time.matchesRule("at 12:00") then
Zwembadpomp.switchOn()
elseif dz.time.matchesRule("at 16:00") and
ZwembadPH.state == "Off" then
Zwembadpomp.switchOff().checkFirst()
end