01.02.2019, 09:38
Hello,
I would like to send an email when there is a modbus disconnection for 30 minutes, the fact that there is random disconnection any time makes that the sending of the mail can occur while the modbus still works . I wish I could have a return of this defect but if it is continual during 30 minutes ... is it possible?
B. R.
Current Script :
require('luamodbus')
mb = luamodbus.tcp()
-- IP: xxx.xxx.xxx.xxx, port: 502
mb:open('xxx.xxx.xxx.xxx', 502)
mb:connect()
conectMB = mb:readregisters(5)
mb:close()
-- CREATION DES SUJET ET MESSAGE POUR MAIL
subject = 'subject'
message = 'message'
subject1 = 'subject1'
message1 = 'message1'
-- ENVOI DU MAIL SI ALARME VRAI
defaut_conectMB = storage.get('defaut_conectMB', false)
if conectMB == nil then
if not defaut_conectMB then
mail('@', subject, message)
storage.set('defaut_conectMB', true)
end
else
if defaut_conectMB then
mail('@', subject1, message1)
storage.set('defaut_conectMB', false)
end
end
I would like to send an email when there is a modbus disconnection for 30 minutes, the fact that there is random disconnection any time makes that the sending of the mail can occur while the modbus still works . I wish I could have a return of this defect but if it is continual during 30 minutes ... is it possible?
B. R.
Current Script :
require('luamodbus')
mb = luamodbus.tcp()
-- IP: xxx.xxx.xxx.xxx, port: 502
mb:open('xxx.xxx.xxx.xxx', 502)
mb:connect()
conectMB = mb:readregisters(5)
mb:close()
-- CREATION DES SUJET ET MESSAGE POUR MAIL
subject = 'subject'
message = 'message'
subject1 = 'subject1'
message1 = 'message1'
-- ENVOI DU MAIL SI ALARME VRAI
defaut_conectMB = storage.get('defaut_conectMB', false)
if conectMB == nil then
if not defaut_conectMB then
mail('@', subject, message)
storage.set('defaut_conectMB', true)
end
else
if defaut_conectMB then
mail('@', subject1, message1)
storage.set('defaut_conectMB', false)
end
end