Today i was debugging a new dzvents script I wrote.
The script is to switch on some selector switches in a specific selector value in case of an emergency.
My is is as follows
- Spoiler: show
- return
{
on =
{
devices =
{
'Rookmelder woonkamer hitte',
'Rookmelder woonkamer rook',
'Rookmelder speelkamer hitte',
'Rookmelder speelkamer rook',
'Rookmelder overloop rook',
'Rookmelder overloop hitte',
'Rookmelder zolder rook',
'Rookmelder zolder hitte',
'Test rookmelder',
},
},
logging = { level = domoticz.LOG_DEBUG, marker = "Rookmelder" },
execute = function(dz, item)
local rmwh = dz.devices('Rookmelder woonkamer hitte')
local rmwr = dz.devices('Rookmelder woonkamer rook')
local rmsh = dz.devices('Rookmelder speelkamer hitte')
local rmsr = dz.devices('Rookmelder speelkamer rook')
local rmor = dz.devices('Rookmelder overloop rook')
local rmoh = dz.devices('Rookmelder overloop hitte')
local rmzr = dz.devices('Rookmelder zolder rook')
local rmzh = dz.devices('Rookmelder zolder hitte')
local ov = dz.devices('Overloop verlichting')
local hl = dz.devices('Hal verlichting')
local sr = dz.devices('Slaapkamer rolluik')
local test = dz.devices('Test rookmelder')
local dummy = dz.devices('Dummy')
if (rmwh.active) or (rmwr.active) or (rmsh.active) or (rmsr.active) or (rmor.active) or (rmoh.active) or (rmzh.active) or (rmzr.active) or (test.active) then
ov.setLevel(20)
hl.setlevel(20)
sr.setLevel(0)
dummy.switchOn()
dz.log("Dummy switch geactiveerd", dz.LOG_DEBUG)
dz.log("Overloop verlichting status:" .. ov.state, dz.LOG_DEBUG)
dz.log("Hal verlichting status:" .. hl.state, dz.LOG_DEBUG)
else
dz.log("Rookmelder woonkamer hitte status:" .. rmwh.state, dz.LOG_DEBUG)
dz.log("Rookmelder woonkamer rook status:" .. rmwr.state, dz.LOG_DEBUG)
dz.log("Rookmelder speelkamer hitte status:" .. rmsh.state, dz.LOG_DEBUG)
dz.log("Rookmelder speelkamer rook status:" .. rmsr.state, dz.LOG_DEBUG)
dz.log("Rookmelder overloop rook status:" .. rmor.state, dz.LOG_DEBUG)
dz.log("Rookmelder overloop hitte status:" .. rmoh.state, dz.LOG_DEBUG)
dz.log("Rookmelder zolder rook status:" .. rmzr.state, dz.LOG_DEBUG)
dz.log("Rookmelder zolder hitte status:" .. rmzh.state, dz.LOG_DEBUG)
dz.log("Test rookmelder status:" .. test.state, dz.LOG_DEBUG)
dz.log("Overloop verlichting status:" .. ov.state, dz.LOG_DEBUG)
dz.log("Hal verlichting status:" .. hl.state, dz.LOG_DEBUG)
end
end
}
- Spoiler: show
- 2023-02-15 13:22:58.181 Error: dzVents: Error: (3.1.8) Rookmelder: An error occurred when calling event handler rookmelder_new
2023-02-15 13:22:58.181 Error: dzVents: Error: (3.1.8) Rookmelder: ...icz/scripts/dzVents/generated_scripts/rookmelder_new.lua:36: attempt to call a nil value (field 'setlevel')
- Spoiler: show
- return {
on = { devices = { 'Dummy' }},
logging = { level = domoticz.LOG_DEBUG, marker = "Test" },
execute = function(dz, item)
local hl = dz.devices('Hal verlichting')
local dummy = dz.devices('Dummy')
if (dummy.active) then
hl.setLevel(20)
end
end
}
Can anyone help me out?
Kind regards.