Ton script peut rester de type device
Je parle de cela
Ce code signifie toutes les minutes
Ou toutes les x minutes en remplaçant le 1 par x
Il doit juste être précèdé par
(a placer au début du script)
Ce qui donnerait
Code : Tout sélectionner
commandArray = {}
--- Each Time a device with a name who start by : PIR, statut change On or Off and Alarm is On : Timer 30 = On and led blanche ON quand timer off led blanche off
local tc=next(devicechanged)
local v=tostring(tc)
local time = os.date("*t")
if ((v:sub(1,3) == 'PIR') or (v:sub(1,3) == 'DET')) and otherdevices['Alarme en service'] == 'On' then
print("******Intrusion******")
commandArray['Alarme détection'] = 'On'
if time.min % 1 == 0 then
commandArray['OpenURL'] = 'https://maker.ifttt.com/trigger/notification/with/key/blabla?value1=Intrusion%20maison'
end
end
return commandArray
Maintenant que je re lis le code, non ça ne va pas fonctionner..
Il vaudrait mieux avoir 2 script.
Un de type device pour passer ton device alarme à On
Code : Tout sélectionner
commandArray = {}
--- Each Time a device with a name who start by : PIR, statut change On or Off and Alarm is On : Timer 30 = On and led blanche ON quand timer off led blanche off
local tc=next(devicechanged)
local v=tostring(tc)
if ((v:sub(1,3) == 'PIR') or (v:sub(1,3) == 'DET')) and otherdevices['Alarme en service'] == 'On' then
print("******Intrusion******")
commandArray['Alarme détection'] = 'On'
end
return commandArray
Et un de type Time pour checker son état et notifier toutes les minutes.. Ou plus comme expliqué
Code : Tout sélectionner
commandArray = {}
-- send notification each 5 min when alarm is On
local time = os.date("*t")
if otherdevices['Alarme détection'] == 'On' and time.min % 5 == 0 then
commandArray['OpenURL'] = 'https://maker.ifttt.com/trigger/notification/with/key/blabla?value1=Intrusion%20maison'
end
return commandArray
Que tu peux, à souhait agrémenter de la fonction lastseen pour par exemple stopper les notifications après 1h d'alarme.
Il faudra aussi penser à repasser alarme à Off