Sudden error: attempt to compare number with table
Posted: Thursday 02 January 2020 10:10
I had a working script, and added a few LOG lines to it (All of them AFTER the error line #27! The log line before there was already there!), and now, suddenly, I get this error:
2020-01-02 10:00:11.305 Status: LUA: Device based event fired on 'Z-Wave node status', value 'Alive'
2020-01-02 10:00:11.321 Status: Set UserVariable Alive state = 1
2020-01-02 10:00:11.288 Error: dzVents: Error: (2.4.28) Z-wave alive monitor: An error occurred when calling event handler Z-Wave dead
2020-01-02 10:00:11.288 Error: dzVents: Error: (2.4.28) Z-wave alive monitor: ...moticz/scripts/dzVents/generated_scripts/Z-Wave dead.lua:27: attempt to compare number with table
I am probably missing something extremely basic, but here's the script details:
Line 27 reads:
With the 2 variables set earlier as:
The whole script below:
2020-01-02 10:00:11.305 Status: LUA: Device based event fired on 'Z-Wave node status', value 'Alive'
2020-01-02 10:00:11.321 Status: Set UserVariable Alive state = 1
2020-01-02 10:00:11.288 Error: dzVents: Error: (2.4.28) Z-wave alive monitor: An error occurred when calling event handler Z-Wave dead
2020-01-02 10:00:11.288 Error: dzVents: Error: (2.4.28) Z-wave alive monitor: ...moticz/scripts/dzVents/generated_scripts/Z-Wave dead.lua:27: attempt to compare number with table
I am probably missing something extremely basic, but here's the script details:
Line 27 reads:
Code: Select all
if (now >= ss30after) thenCode: Select all
local ss30after = domoticz.time.sunsetInMinutes + 30
local Time = require('Time')
local now = Time() -- current time
Code: Select all
return {
on = {
devices = {
'Z-Wave node status'
}
},
logging = {
level = domoticz.LOG_DEBUG,
marker = "Z-wave alive monitor"
},
execute = function(domoticz, device)
local ss30before = domoticz.time.sunsetInMinutes - 30
local ss0before = domoticz.time.sunsetInMinutes
local ss30after = domoticz.time.sunsetInMinutes + 30
local Time = require('Time')
local now = Time() -- current time
local Dressoir = domoticz.devices('Dressoir')
domoticz.log('Device ' .. device.name .. ' was changed to '..device.state, domoticz.LOG_INFO)
if (device.state=='Dead' and domoticz.variables('Alive state').value ~= 0) then
domoticz.scenes('Dressoir RED').switchOn()
domoticz.variables('Alive state').set(0)
domoticz.notify("ALARM", 'Een Z-Wave node has gone DEAD!', domoticz.PRIORITY_EMERGENCY)
elseif (device.state=='Alive' and domoticz.variables('Alive state').value ~= 1) then
domoticz.notify("ALARM", 'All Z-Wave nodes are ALIVE!', domoticz.PRIORITY_EMERGENCY)
domoticz.variables('Alive state').set(1)
if (now >= ss30after) then
domoticz.log('30 minutes after sunset, setting accordingly...', domoticz.LOG_INFO)
Dressoir.setColor(0, 0, 0, 3, 0, 0, 2, 192)
elseif (now >= ss0before) then
domoticz.log('Less than 30 minutes after sunset, setting accordingly...', domoticz.LOG_INFO)
Dressoir.setColor(0, 0, 0, 6, 0, 0, 2, 128)
elseif (now >= ss30before) then
domoticz.log('30 minutes before sunset, setting accordingly...', domoticz.LOG_INFO)
Dressoir.setColor(0, 0, 0, 10, 0, 0, 2, 96)
else
domoticz.log('Not even close to sunset, turning off...', domoticz.LOG_INFO)
Dressoir.switchOff()
end
end
domoticz.log("I'm done, have a nice day!...", domoticz.LOG_INFO)
end
}