return {
on = {
devices = {
'PIR hal beneden'
}
},
execute = function(dz, device)
dz.log('Device ' .. device.name .. ' was changed', dz.LOG_INFO)
local pir = dz.devices("PIR hal beneden")
local lamp = dz.devices("Lamp hal beneden")
local lux = dz.devices("LUX hal beneden").lux
local tijd = dz.time
if pir.state == "On" and lux < 20 then
lamp.cancelQueuedCommands()
lamp.switchOn().forMin(1)
if tijd > '23:00' and tijd < '06:00' then
lamp.dimTo(30)
elseif tijd > '06:00' and tijd < '23.00' then
lamp.dimTo(100)
end
end
end
}
2019-11-28 19:22:42.439 Error: dzVents: Error: (2.5.0) An error occurred when calling event handler Licht hal beneden
2019-11-28 19:22:42.439 Error: dzVents: Error: (2.5.0) .../scripts/dzVents/generated_scripts/Licht hal beneden.lua:18: attempt to compare string with table
dz.time is a table with methods, attributes and subtables and a table cannot be compared with a string like '23:00'
For this functionality the method matchesRule is available.
return {
on = {
devices = {
'PIR hal beneden'
}
},
execute = function(dz, item)
dz.log('Device ' .. item.name .. ' was changed', dz.LOG_INFO)
local lamp = dz.devices("Lamp hal beneden")
local lux = dz.devices("LUX hal beneden").lux
if item.state == "On" and lux < 20 then
lamp.cancelQueuedCommands()
lamp.switchOff().afterMin(1)
if dz.time.matchesRule('at 23:00-06:00') then
lamp.dimTo(30)
else
lamp.dimTo(100)
end
end
end
}
waaren wrote: Thursday 28 November 2019 19:43
dz.time is a table with methods, attributes and subtables and a table cannot be compared with a string like '23:00'
For this functionality the method matchesRule is available.
your script makes sense, i understand now. thanks again!
2019-11-28 19:56:57.860 Error: dzVents: Error: (2.5.0) An error occurred when calling event handler Licht hal beneden
2019-11-28 19:56:57.860 Error: dzVents: Error: (2.5.0) .../scripts/dzVents/generated_scripts/Licht hal beneden.lua:8: attempt to index a nil value (global 'device')
i removed the log line 8 and it was gone.
i guess it has something to do with device no longer being specified in line 7? there is item instead of device there.