LowBat warning for device with no battery
Posted: Wednesday 20 December 2017 10:59
from the dzvents examples in Domoticz I installed the "check battery levels.lua" The scripts reports the low batteries just fine.
Yesterday i added a new switch to the system. A 220V switch (klik-aan-klik-uit) without a battery, but the script reports a low battery condition for that switch. Delete the switch and add it again is no solution.
I tried a if..then script to filter out the specific switch, but my skills are insufficient.
Can anyone help?
Yesterday i added a new switch to the system. A 220V switch (klik-aan-klik-uit) without a battery, but the script reports a low battery condition for that switch. Delete the switch and add it again is no solution.
I tried a if..then script to filter out the specific switch, but my skills are insufficient.
Can anyone help?
Code: Select all
[local BATTERY_THRESHOLD = 10
return {
active = true,
on = {
['timer'] = {
'every hour'
}
},
execute = function(domoticz)
local message = ''
-- first filter on low battery level
local lowOnBat = domoticz.devices().filter(function(device)
local level = device.batteryLevel -- level is 0-100
return (level ~= nil and -- not all devices have this attribute
level <= BATTERY_THRESHOLD)
end)
-- then loop over the results
lowOnBat.forEach(function(lowDevice)
message = message .. 'Device ' ..
lowDevice.name .. ' is low on batteries (' .. tostring(lowDevice.batteryLevel) .. '), '
end)
if (message ~= '') then
domoticz.notify('Low battery warning', message, domoticz.PRIORITY_NORMAL)
domoticz.log('Low battery warning: ' .. message, domoticz.LOG_ERROR)
end
end
}