SOLVED (script error)

Moderator: leecollings

Post Reply
User avatar
raymond1972
Posts: 32
Joined: Wednesday 28 February 2018 13:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

SOLVED (script error)

Post by raymond1972 »

Hi all,

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
}
When running my script i get this error
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')
and when I run a smaller portion just to debug the setLevel functionality it went fine and result in setting the correct setLevel value.
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
}
It seems to me that this is a bug.

Can anyone help me out?

Kind regards.
Last edited by raymond1972 on Wednesday 15 February 2023 13:42, edited 1 time in total.
HW:Raspberry Pi 3 B, Raspian stretch, Nano, Aeon Labs Aeotec Gen 5 Z-Wave USB
Raspberry Pi 4, Raspian buster, Nano, Aeon Labs Aeotec Gen 5 Z-Wave USB
User avatar
raymond1972
Posts: 32
Joined: Wednesday 28 February 2018 13:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: script error

Post by raymond1972 »

I have found the reason for the different behaviour.
My apologies.
Seems that line hl.setlevel(20) needed to be hl.setLevel(20) with a capital L.

Kind regards,
Raymond
HW:Raspberry Pi 3 B, Raspian stretch, Nano, Aeon Labs Aeotec Gen 5 Z-Wave USB
Raspberry Pi 4, Raspian buster, Nano, Aeon Labs Aeotec Gen 5 Z-Wave USB
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest