J'ai adapté à mes besoins, n'y connaissant rien ça m'a pris pal mal d'heures mais ça marche !
Je pense que c'est très optimisable, si jamais vous avez le temps d'y jeter un oeil ce serait sympa
Mon besoin était en fait d'avoir la lumière qui s'allume pour me réveiller plus tôt en cas de gel pour avoir le temps de gratter la voiture
Code : Tout sélectionner
local sonde = 'Temperature exterieure'
local chambre = 'Lumiere de la grande chambre'
local chevet = 'Lampe de chevet'
commandArray = {}
time = os.date("*t")
--------------------------------------------------------------------------------------
-- Stocke la température la plus basse entre 3h et 5h59 du matin si réveil activé --
--------------------------------------------------------------------------------------
if (otherdevices['Reveil']=='On') then
if (devicechanged[sonde])
then
if (uservariables['T_mini'] > otherdevices_temperature[sonde]) and time.hour >= 3 and time.hour < 6
then
uservariables['T_mini'] = otherdevices_temperature[sonde]
commandArray['Variable:T_mini']= tostring(uservariables["T_mini"])
end
end
--------------------------------------------------------
-- Envoi la température la plus basse par prowl à 06h --
--------------------------------------------------------
if time.hour == 6 and time.min == 00 and uservariables['Notif'] == 1
then
commandArray['SendNotification']='Cette nuit il a fait #'..(string.format("%g",tostring(uservariables['T_mini'])))..'°C'
commandArray['Variable:Notif']= "0"
commandArray['Variable:T_mini']= tostring(uservariables["T_mini"])
end
---------------------------------------------------------------------------------
-- Si la température est descendue sous les 1°c alors démarre le réveil à 6h00 --
---------------------------------------------------------------------------------
if time.hour == 6 and time.min == 00 and time.sec == 00 and (uservariables['T_mini'] <= 1)
then commandArray[chambre] = 'Set Level 15'
end
if time.hour == 6 and time.min == 01 and time.sec == 00 and (uservariables['T_mini'] <= 1)
then commandArray[chambre] = 'Set Level 25'
end
if time.hour == 6 and time.min == 02 and time.sec == 00 and (uservariables['T_mini'] <= 1)
then commandArray[chambre] = 'Set Level 35'
end
if time.hour == 6 and time.min == 03 and time.sec == 00 and (uservariables['T_mini'] <= 1)
then commandArray[chevet] = 'On'
end
--------------------------------------------------------------------------------------
-- Si la température n'est pas descendue sous les 1° alors démarre le réveil à 6h15 --
--------------------------------------------------------------------------------------
if time.hour == 6 and time.min == 15 and time.sec == 00 and (uservariables['T_mini'] > 1)
then commandArray[chambre] = 'Set Level 15'
end
if time.hour == 6 and time.min == 16 and time.sec == 00 and (uservariables['T_mini'] > 1)
then commandArray[chambre] = 'Set Level 25'
end
if time.hour == 6 and time.min == 17 and time.sec == 00 and (uservariables['T_mini'] > 1)
then commandArray[chambre] = 'Set Level 35'
end
if time.hour == 6 and time.min == 18 and time.sec == 00 and (uservariables['T_mini'] > 1)
then commandArray[chevet] = 'On'
end
--------------------------------------------
-- réinitialisation des variables à 12h00 --
--------------------------------------------
if time.hour == 12 and time.min == 00
then
commandArray['Variable:T_mini']= "100"
commandArray['Variable:Notif']= "1"
end
end
return commandArrayPour l'allumage de la lampe j'ai été obligé de rajouter des "time.sec == 00" sinon la commande se lançait toutes les secondes de la minute...
Je me pencherai sur la notif sms plus tard, je bloque sur la récupération de la variable dans le script sh, je ne vois pas comment faire.