https://github.com/dannybloe/dzVents/bl ... evices.lua
The script I have adapted for my sensors runs, and if one the sensors has not been seen for a while, as expected I receive an email with a list of dead devices... great!
The problem is, that if there are no dead devices, I still receive an email with something like the following:
Unfortunately I do not understand dzVents enough yet to know what's happening here. I would expect that you would only get an email if there is a dead device? At the moment I get an email every 5 minutes regardless.----------------762475179556452285591111
Content-type: text/plain; charset=utf-8; format=flowed
Content-transfer-encoding: 7bit
Code: Select all
local devicesToCheck = {
{ ['name'] = 'Lounge Temperature', ['threshold'] = 30 },
{ ['name'] = 'Front Bedroom Temperature', ['threshold'] = 30 }
}
return {
active = true,
on = {
['timer'] = {
'every 5 minutes'
}
},
execute = function(domoticz)
local message = ""
for i, deviceToCheck in pairs(devicesToCheck) do
local name = deviceToCheck['name']
local threshold = deviceToCheck['threshold']
local minutes = domoticz.devices(name).lastUpdate.minutesAgo
if ( minutes > threshold) then
message = message .. 'Device ' ..
name .. ' seems to be dead. No heartbeat for at least ' ..
minutes .. ' minutes.\r'
end
end
if (message) then
domoticz.email('Dead devices', message, '[email protected]')
domoticz.log('Dead devices found: ' .. message, domoticz.LOG_ERROR)
end
end
}