The script works, but it shouldn't. Why?
Posted: Wednesday 14 October 2020 21:18
Hello, I have a script that should execute in time.
Domoticz last beta.
Why is it working now?
It's October
The date and time in domoticz is up to date
The full script is here
Domoticz last beta.
Why is it working now?
It's October
The date and time in domoticz is up to date
Code: Select all
return {
on = {
timer = {'at 21:17 on mon,wed,fri,sun on 20/04-28/09'},
devices = {'Przekaźnik 1'}
},
logging = {
-- level = domoticz.LOG_ERROR,
level = domoticz.LOG_DEBUG,
marker = "Time and relay"
},
execute = function(dz, item)
local relay = dz.devices("Przekaźnik 1")
local relay2 = dz.devices("Przekaźnik 2")
if (item.isTimer) then
relay.switchOn()
elseif relay.state == "On" then
relay2.switchOn().afterSec(4)
end
end
}The full script is here
Code: Select all
return {
on = {
timer = {'at 3:00 on mon,wed,fri,sun on 20/04-28/09'},
devices = {'Nawadnianie'}
},
logging = {
level = domoticz.LOG_ERROR,
-- level = domoticz.LOG_DEBUG,
marker = "Nawadnianie ogrodu"
},
execute = function(dz, item)
local selector = dz.devices("Nawadnianie")
local zone1 = dz.devices("Podlew Róże")
local zone2 = dz.devices("Podlew Front")
local zone3 = dz.devices("Podlew Trawnik1")
local zone4 = dz.devices("Podlew Trawnik2")
local zone5 = dz.devices("Podlew Trawnik3")
local zone6 = dz.devices("Podlew Trawnik4")
local zones = { zone1, zone2, zone3, zone4,zone5, zone6 }
dz.log(selector.name .. ' Jest w trybie ' .. selector.state, dz.LOG_DEBUG)
for _, zone in ipairs(zones) do
zone.cancelQueuedCommands() -- usuwa stare zaplanowane start / stop
zone.switchOff().checkFirst()
if (item.isTimer) then
selector.switchSelector(10)
elseif selector.state == "Auto" then
zone1.switchOn().forMin(40)
zone2.switchOn().afterMin(10).forMin(30)
zone3.switchOn().afterMin(40).forMin(30)
zone4.switchOn().afterMin(70).forMin(30)
zone5.switchOn().afterMin(100).forMin(30)
zone6.switchOn().afterMin(130).forMin(30)
selector.switchSelector(0).afterMin(161)
elseif selector.state == "Stop" then
zone1.switchOff()
zone2.switchOff()
zone3.switchOff()
zone4.switchOff()
zone5.switchOff()
zone6.switchOff()
end
end
end
}