i have a script i use to take actions depending on a selector state.
now on line 50 i use a soil moisture sensor which is a custom sensor with percentage in domoticz see picture for more details:

the thing is that i get the following error:
Code: Select all
2020-06-24 20:22:08.902 Error: dzVents: Error: (3.0.2) Sproeier: An error occurred when calling event handler Sproeier programma
2020-06-24 20:22:08.902 Error: dzVents: Error: (3.0.2) Sproeier: ...scripts/dzVents/generated_scripts/Sproeier programma.lua:50: attempt to compare table with numberCode: Select all
return {
on = {
devices = {
'Sproeier programma'
}
},
logging = {
level = domoticz.LOG_ERROR,
-- level = domoticz.LOG_DEBUG,
marker = "Sproeier"
},
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")
local zone8 = dz.devices("Irrigatie zone 8")
local zone9 = dz.devices("Irrigatie zone 9")
local zone10 = dz.devices("Irrigatie zone 10")
local soil7 = dz.devices("Grondvochtigheid zone 7")
local zones = { zone1, zone2, zone3, zone4, zone5, zone6, zone7, zone8, zone9, zone10 }
dz.log(selector.name .. ' switched to ' .. selector.state, dz.LOG_DEBUG)
for _, zone in ipairs(zones) do
zone.cancelQueuedCommands() -- remove all 'old' scheduled starts / stops
zone.switchOff().checkFirst()
end
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
zone8.switchOn()
zone10.switchOn().afterMin(1)
zone4.switchOn().afterMin(3)
zone5.switchOn().afterMin(2)
zone1.switchOn().afterMin(61)
zone2.switchOn().afterMin(62)
zone3.switchOn().afterMin(62)
zone9.switchOn().afterMin(62)
selector.switchOff().afterMin(122).silent()
if soil7 < 80 then
zone7.switchOn().afterMin(63)
end
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
zone8.switchOn()
zone10.switchOn().afterMin(1)
zone4.switchOn().afterMin(2)
zone5.switchOn().afterMin(3)
selector.switchOff().afterMin(61).silent()
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
zone1.switchOn().forMin(60)
zone2.switchOn().afterMin(1)
zone3.switchOn().afterMin(1)
zone9.switchOn().afterMin(2)
selector.switchOff().afterMin(61).silent()
if soil7 < 80 then
zone7.switchOn().afterMin(1)
end
elseif selector.state == "Waterstopcontact" then
-- turn on zone 6 and turn it off after an hour
zone6.switchOn()
selector.switchOff().afterMin(60).silent()
elseif selector.state == "Off" then
-- force everything to turn off
-- Already done
end
end
}