error with dzventz script  [SOLVED]

Moderator: leecollings

Post Reply
mcmikev
Posts: 146
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: right here
Contact:

error with dzventz script

Post 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?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: error with dzventz script

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
mcmikev
Posts: 146
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: right here
Contact:

Re: error with dzventz script  [SOLVED]

Post by mcmikev »

Replaced the Off with 0 (zero) as level and the error is gone.

Thanks!!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest