nil is supposed to be false in conditionals but errors in dzVents
Posted: Friday 14 July 2023 2:48
In conditionals in Lua I read nil is considered false: https://www.tutorialspoint.com/lua/lua_ ... making.htm
For example if this sensor battery level is nil then this should be false and not fire:
Instead it errors out:
I did workaround it:
I noticed that dzVents / Lua is somewhat lagging Lua itself so I'm not sure if that is the issue?
https://www.lua.org/versions.html#5.4
For example if this sensor battery level is nil then this should be false and not fire:
Code: Select all
if domoticz.devices('Garage side door sensor').batteryLevel < 100 then
-- do something
endCode: Select all
2023-07-13 19:00:00.304 Error: dzVents: Error: (3.1.8) An error occurred when calling event handler Low battery notification
2023-07-13 19:00:00.304 Error: dzVents: Error: (3.1.8) ...s\dzVents\generated_scripts/Low battery notification.lua:61: attempt to compare nil with numberI did workaround it:
Code: Select all
if domoticz.devices('Garage side door sensor').batteryLevel ~= nil and domoticz.devices('Garage side door sensor').batteryLevel < 100 then
--do something
endhttps://www.lua.org/versions.html#5.4