Ceci est un programme de test et n'est pas finalisé !
La variable "alertCount" reste sur "1", elle ne s'incrémente pas
Voici mon script :
Code : Tout sélectionner
--[[
check-ouverture-porte-garage - 04/06/2023
voir https://easydomoticz.com/forum/viewtopic.php?t=8643
From the domoticz examples online: http://www.domoticz.com/wiki/Event_script_examples
Send a warning when the garage door has been open for more than 30 minutes
]]
return {
active = true,
on = {
--timer = {'every 5 minutes'}
timer = {'every minute'}
},
execute = function(domoticz, device)
local alertCount = 0
domoticz.log(alertCount)
local check_porte = domoticz.devices(628)
local etat_porte = domoticz.devices(412)
domoticz.log(' [-------------- START check-ouverture-porte-garage--------------] ')
if (check_porte.active) then
if (etat_porte.active) and (etat_porte.lastUpdate.minutesAgo >30 and alertCount < 3) then
domoticz.log(' [-------------- START etat-porte-garage 1--------------] ')
--domoticz.notify('Porte Garage', 'Porte Garage Ouverte depuis plus de 30 minutes...')
alertCount = alertCount + 1
domoticz.log ('Avertissement1 : ' .. alertCount)
domoticz.log(' [-------------- STOP etat-porte-garage 1---------------] ')
else
timer = {'every 15 minutes'}
domoticz.log(' [-------------- START etat-porte-garage--------------] ')
--domoticz.notify('Porte Garage', 'Porte Garage Ouverte depuis plus de 45 minutes...')
alertCount = alertCount + 1
domoticz.log ('Avertissement2 : ' .. alertCount)
domoticz.log(' [-------------- STOP etat-porte-garage---------------] ')
end
end
domoticz.log(' [-------------- STOP check-ouverture-porte-garage---------------] ')
end
}