50 lines
1.7 KiB
Lua
Executable File
50 lines
1.7 KiB
Lua
Executable File
require "scripts/lua/functions"
|
|
|
|
--recupere les minutes
|
|
time=os.time()
|
|
seconds=tonumber(os.date('%S',time))
|
|
minutes=tonumber(os.date('%M',time))
|
|
heures=tonumber(os.date('%H',time))
|
|
jour=tonumber(os.date('%w',time))
|
|
mois=tonumber(os.date('%M',time))
|
|
|
|
|
|
--Initialise la commande de retour finale
|
|
commandArray={}
|
|
|
|
|
|
-- ------------------------------------------------------------------------------
|
|
-- Lampes eteinte après 22 heures 30 / 23 heures si pas d'activite depuis 10 minutes
|
|
-- ------------------------------------------------------------------------------
|
|
-- Pas de traitement en cas d'alerte fumée
|
|
if otherdevices['DétecteurFuméeCuisine'] == "Normal"
|
|
-- Pas de traitement si lampe allumée il y a moins d'une heure
|
|
and (lastUpdateOfDevice('Lampe_Buffet') > 3600 and otherdevices['Lampe_Buffet'] == 'On')
|
|
then
|
|
if ((heures >= 23 or (heures == 22 and minutes >= 30)) and (minutes%5==0)) then
|
|
|
|
t1 = os.time()
|
|
s = uservariables_lastupdate['DerniereDetection'] --otherdevices_lastupdate['Detecteur Salon']
|
|
-- returns a date time like 2013-07-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)
|
|
minu = string.sub(s, 15, 16)
|
|
seconds = string.sub(s, 18, 19)
|
|
|
|
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minu, sec=seconds}
|
|
difference = (os.difftime (t1, t2))
|
|
debug("Eteindre les lumieres, DerniereDetection="..tostring(difference))
|
|
if (difference > 300 or heures >= 23) then
|
|
|
|
switchIfNeeded('Lampe_Halogene', 'Off')
|
|
switchIfNeeded('Lampe_Buffet', 'Off')
|
|
switchIfNeeded('Lampe_Tele', 'Off')
|
|
switchIfNeeded('SonoJasper', 'Off')
|
|
end
|
|
end
|
|
end
|
|
|
|
return commandArray
|