first commit

This commit is contained in:
Souti
2025-03-06 11:09:58 +01:00
commit 11f7d440ff
330 changed files with 38306 additions and 0 deletions

92
lua/script_time_Lumieres.lua Executable file
View File

@@ -0,0 +1,92 @@
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={}
-- -----------------------------------------------------------------------
-- Test le nombre d'erreur dans le log toutes les heures
-- -----------------------------------------------------------------------
if (false and minutes == 0) then
local var = os.capture("grep Error /var/log/domoticz.log |wc -l")
--print(var)
if (tonumber(var) > 0 and tonumber(uservariables['Variable:Erreurs']) == 0) then
commandArray['SendNotification']='Alerte Erreur '..var..'#Attention Il y a des erreurs dans domoticz #0'
end
commandArray['Variable:Erreurs']=var
end
-- -----------------------------------------------------------------------
-- Vérifie le nombre de sequences capturées par motion
-- -----------------------------------------------------------------------
if (minutes % 10 == 1) then
local f = io.popen("ls /media/WDBlue/motion/CAM21/*.avi |grep avi |uniq| wc -l") -- runs command
local l = f:read("*a") -- read output of command
debug("Nombre de detection "..l)
f:close()
commandArray['PhotoMotion']=tostring(l)
commandArray['UpdateDevice']="136|0|"..l
end
-- ------------------------------------------------------------------------------
-- Lampes eteinte après 22 heures 30 / 23 heures si pas d'activite depuis n minutes
-- ------------------------------------------------------------------------------
-- Pas de traitement en cas d'alerte fumée
if (minutes%1==0)
and otherdevices['DétecteurFuméeCuisine'] == "Normal"
-- Pas de traitement si lampe allumée il y a moins d'une 1/2 heure
--and (lastUpdateOfDevice('Lampe_Buffet') > 1800) -- and otherdevices['Lampe_Buffet'] == 'On')
then
debug('Test extinction lumieres')
if (
(
(heures == 22 and minutes >= 0) or
(heures >= 23 and heures <= 5) or
(heures >= 09 and heures <= 10 ) or
(otherdevices['Presence'] == 'Off')
)
) 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)..' heures='..tostring(heures))
if (difference > 300 and (
(heures >= 22 and (minutes >= 0))
or (heures >= 23)
or (heures <= 5)
)
)
then
debug("Extinction des lumieres")
switchIfNeeded('Lampe_Halogene', 'Off')
sleep(1)
switchIfNeeded('Lampe_Buffet', 'Off')
sleep(1)
switchIfNeeded('Lampe_Tele', 'Off')
--switchIfNeeded('SonoJasper', 'Off')
end
end
end
return commandArray