Je suis débutant en programmation.
Je voudrais recevoir une notification quand un module a HaveTimeout = true en json.
J'ai essayé ce programme mais pas de notification. Je voudrais aussi surveiller plusieurs modules.
Pouvez-vous m'aider ?
Merci d'avance.
Code : Tout sélectionner
return {
on = {
timer = {'every minute'},
httpResponses = {'lastUP' }
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'http://monip:8080/json.htm?type=devices&rid=547',
callback = 'lastUP'
})
end
if (item.isHTTPResponse and item.ok) then
local last =item.json.result[1]['LastUpdate']
local HTimeout=item.json.result[1]['HaveTimeout']
print('------------------http reponse last update: ' .. last .. ' Have timeout:' .. tostring(HTimeout))
end
if ( HTimeout == 'true') then
message = message .. 'Device ' ..
name .. ' seems to be dead. No heartbeat for at least ' ..
minutes .. ' minutes.\r'
end
if (message) then
domoticz.email('Dead devices', message, 'monadresse@free.fr')
domoticz.log('Dead devices found: ' .. message, domoticz.LOG_ERROR)
end
end
}