Code: Select all
2017-12-08 17:55:00.513 Error: dzVents: Error: An error occured when calling event handler batt test2
2017-12-08 17:55:00.513 Error: dzVents: Error: ...icz/var/scripts/dzVents/generated_scripts/batt test2.lua:8: attempt to compare nil with number
Script (with test figures) is:
Code: Select all
return {
active = true,
on = {
timer = {
'at 18:16 on fri'
},
},
execute = function(domoticz,dummy)
local garagemotion = domoticz.devices('Xiaomi Motion Sensor')
local garagesensor = domoticz.devices('Xiaomi Door Sensor')
local switch1 = domoticz.devices('Xiaomi Switch 1')
local switch2 = domoticz.devices('Xiaomi Switch 2')
if (garagemotion.batteryLevel < 10) then
domoticz.email('Garage Motion Sensor Battery', 'Garage Motion Sensor battery is low.', '<email address>')
end
if (garagesensor.batteryLevel < 10) then
domoticz.email('Garage Door Sensor Battery', 'Garage Door Sensor battery is low.', '<email address>')
end
if (switch1.batteryLevel < 10) then
domoticz.email('Switch 1 Battery', 'Switch 1 battery is low.', '<email address>')
end
if (switch2.batteryLevel < 97) then
domoticz.email('Switch 2 Battery', 'Switch 2 battery is low.', '<email address>')
end
end
}