Je me suis équipé du tracker NUT détecté via Domoticz, cependant parfois il y a de très courtes déconnexion du dispositif.
Pour remédier à cela je souhaiterai une tempo sur le traitement de la variable quand celle ci passe sur "AWAY".
J'ai bidouillé et essayé plusieurs code, aucun n'a voulu prendre en compte la tempo donné (ici 2min).
Code : Tout sélectionner
time = os.date("*t")
t1 = os.time()
s = uservariables_lastupdate['NUT_dz']
-- Retourne la date au format --> 2016-10-11 17:23:12
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2))
commandArray = {}
-- Detection NUT ---> Si variable "AWAY" pendant 2 minute
if (uservariables['NUT_dz'] == 'AWAY' and difference > 120) then
commandArray['Presence-DZ']='Off'
end
return commandArray