Code: Select all
local device0 = 'test 1'
local device1 = 'test 2'
local device2 = 'test 3'
local device3 = 'test 4'
local device4 = 'test 5'
local device5 = 'test 6'
local device6 = 'test 7'
local device7 = 'test 8'
local device8 = 'test 9'
local device9 = 'test 10'
local device10 = 'test 11'
local device11 = 'test 12'
return {
on = {
devices = {
device0,
device1,
device2,
device3,
device4,
device5,
device6,
device7,
device8,
device9,
cevice10,
device11,
device12,
device13,
device14,
device15,
device16,
device17,
devcie18,
device19,
},
},
-- custom logging level for this script
logging = {
level = domoticz.LOG_INFO,
marker = "test"
},
execute = function(dz, device)
local kogelKraan= 'test 00'
local waarde=0
dz.log('device0 is '.. dz.devices(device0).state,dz.LOG_INFO)
dz.log('device1 is '.. dz.devices(device1).state,dz.LOG_INFO)
dz.log('device2 is '.. dz.devices(device2).state,dz.LOG_INFO)
dz.log('device3 is '.. dz.devices(device3).state,dz.LOG_INFO)
dz.log('device4 is '.. dz.devices(device4).state,dz.LOG_INFO)
dz.log('device5 is '.. dz.devices(device5).state,dz.LOG_INFO)
dz.log('device6 is '.. dz.devices(device6).state,dz.LOG_INFO)
dz.log('device7 is '.. dz.devices(device7).state,dz.LOG_INFO)
dz.log('device8 is '.. dz.devices(device8).state,dz.LOG_INFO)
dz.log('device9 is '.. dz.devices(device9).state,dz.LOG_INFO)
dz.log('device10 is '.. dz.devices(device10).state,dz.LOG_INFO)
dz.log('device11 is '.. dz.devices(device11).state,dz.LOG_INFO)
dz.log('device12 is '.. dz.devices(device12).state,dz.LOG_INFO)
dz.log('device13 is '.. dz.devices(device13).state,dz.LOG_INFO)
dz.log('device14 is '.. dz.devices(device14).state,dz.LOG_INFO)
dz.log('device15 is '.. dz.devices(device15).state,dz.LOG_INFO)
dz.log('device16 is '.. dz.devices(device16).state,dz.LOG_INFO)
dz.log('device17 is '.. dz.devices(device17).state,dz.LOG_INFO)
dz.log('device18 is '.. dz.devices(device18).state,dz.LOG_INFO)
dz.log('device19 is '.. dz.devices(device19).state,dz.LOG_INFO)
if (dz.devices(device0).state == 'On') then
waarde=waarde+1
end
if (dz.devices(device1).state == 'On') then
waarde=waarde+1
end
if (dz.devices(device2).state == 'On') then
waarde=waarde+1
end
if (dz.devices(device3).state == 'On') then
waarde=waarde+1
end
if (dz.devices(device4).state == 'On') then
waarde=waarde+1
end
if (dz.devices(device5).state == 'On') then
waarde=waarde+1
end
if (dz.devices(device6).state == 'On') then
waarde=waarde+1
end
if (dz.devices(device7).state == 'On') then
waarde=waarde+1
end
if (dz.devices(device8).state == 'On') then
waarde=waarde+1
end
if (dz.devices(device9).state == 'On') then
waarde=waarde+1
end
if (dz.devices(device10).state == 'On') then
waarde=waarde+1
end
if (dz.devices(device11).state == 'On') then
waarde=waarde+1
end
dz.log('waarde is '.. waarde,dz.LOG_INFO)
dz.log('result switch was '.. dz.devices(kogelKraan).state,dz.LOG_INFO)
if waarde >= 5 then
dz.log('waarde => 5',dz.LOG_INFO)
dz.devices(kogelKraan).switchOff()
else
if waarde < 5 then
dz.log('waarde < 5',dz.LOG_INFO)
dz.devices(kogelKraan).switchOn()
end
end
end
}
2023-09-22 12:31:02.082 Error: dzVents: Error: (3.1.8) test: An error occurred when calling event handler test
2023-09-22 12:31:02.082 Error: dzVents: Error: (3.1.8) test: .../domoticz/scripts/dzVents/generated_scripts/test.lua:68: attempt to concatenate a nil value (field 'state')
Can someone tell me what is wrong. This scripts is a test script that when there are less that 5 test devices on the test 00 needs to go on. And when there are 5 or more test devices on the test 00 needs to go off.