Page 1 of 1

error with dzventz script

Posted: Sunday 23 June 2019 14:06
by mcmikev
Hi,

Running latest (from source) domoticz version 4.10926 and have a script that works with a rfxcom device.

The script is this

Code: Select all

return {
    active = true,
    on = {
        devices = {
            'KaKu-GangBgg'
        }
    },
	logging = {
    level = domoticz.LOG_INFO, --log level can be domoticz.LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG or domoticz.LOG_ERROR
    marker = "KaKu-GangBgg" --info to see what device did what in the log
    },
    execute = function(domoticz, device)
        if (device.name == 'KaKu-GangBgg' and device.state == 'On') then
	    domoticz.devices('DIM-GangkastR-Boven').dimTo(25)
	    domoticz.devices('DIM-GangkastG-Onder').dimTo(25)
	    domoticz.devices('Gangkast').switchSelector(20) end
        if (device.name == 'KaKu-GangBgg' and device.state == 'Off') then
	    domoticz.devices('DIM-GangkastR-Boven').dimTo(0)
	    domoticz.devices('DIM-GangkastG-Onder').dimTo(0)
	    domoticz.devices('Gangkast').switchSelector(Off) end
end
}
The error I get is only when I turn the switch off. With turining ON there is no issue at all. The light goes off and on as expected but there is this error :

Code: Select all

2019-06-23 14:04:38.347 Error: dzVents: Error: (2.4.23) KaKu-GangBgg: An error occurred when calling event handler 2-Gang-KakuTrap
2019-06-23 14:04:38.347 Error: dzVents: Error: (2.4.23) KaKu-GangBgg: ...moticz/dzVents/runtime/device-adapters/switch_device.lua:118: attempt to perform arithmetic on local 'val' (a nil value)
What can be the cause of this error?

Re: error with dzventz script

Posted: Sunday 23 June 2019 15:34
by waaren
mcmikev wrote: Sunday 23 June 2019 14:06 The script is this

Code: Select all

  domoticz.devices('Gangkast').switchSelector(Off) end
}
What can be the cause of the error?
The error is in the word Off
If you want to use it as a string then it is 'Off'. Other option is to replace it with 0.
Lua is interpreting the Off as variable but as this is not set, it is nil

Re: error with dzventz script  [SOLVED]

Posted: Sunday 23 June 2019 16:49
by mcmikev
Replaced the Off with 0 (zero) as level and the error is gone.

Thanks!!