require "scripts/lua/functions" commandArray = {} local HEURE_DEB = 9 local HEURE_FIN = 17 local TEMP_MAX = 24 local TEMP_MAX_2 = 28 --recupere les minutes time=os.time() minutes=tonumber(os.date('%M',time)) --jour=tonumber(os.date('%w',time)) heures=tonumber(os.date('%H',time)) local saison = uservariables["Saison"] local jourS = josdGetJourSemaine() -- ------------------------------------------------------------------- -- Verification des volets ouverts si température trop basse -- ------------------------------------------------------------------- if (minutes == 0 or minutes == 30 ) then debug('########## Lancement du check fermeture velux du grenier ' ..heures..'h'..minutes) tab = getValuesInTab('BarometreLaGacilly') local tmp = tonumber(tab[1]) debug('########## Lancement du check fermeture velux du grenier ' ..heures..'h'..minutes..' tmp='..tostring(tmp)) if (tmp < 14.0 and (otherdevices['Velux droit'] == 'Open' or otherdevices['Velux gauche'] == 'Open')) then commandArray['notification']="Volet ouvert#Un des volets du grenier est reste ouvert #0" end end -- ----------------------- -- Fermeture volet central -- ----------------------- if minutes%30 == 0 and (saison ~= "Ete") and (heures >= 22) -- or uservariables['Dark'] == "True") then debug('------------------------------------------------------') debug(' Test fermeture volet Central '..otherdevices['VoletPorteSalon']) debug('------------------------------------------------------') if (otherdevices['VoletPorteSalon'] ~= 'Closed') then commandArray['VoletPorteSalon']='On' end end -- --------------------------------------------------------------------------------------- -- Fermeture des volets en fonction de la temperature exterieure Pas l'ETE -- --------------------------------------------------------------------------------------- --print("DARK=="..tostring(uservariables['Dark'] == "True")) if minutes%9 == 0 and (saison ~= "Ete") and (otherdevices['VoletCuisine'] == 'Open' or otherdevices['VoletSalonTele'] == 'Open') and (heures >= 18 or ( heures >= 17 and ( uservariables['Dark'] == "True") or (tonumber(otherdevices['Lux']) < tonumber(uservariables["LuxMini"])) ) ) then debug('------------------------------------------------------') debug(' Test fermeture volet ') debug('------------------------------------------------------') debug('####### Comparaison heure vs Couche du soleil ========>'..uservariables["Heure"].." "..uservariables["Couche"]) debug('####### Lancement du check test ' ..heures..'h'..minutes..' volet cuisine '..otherdevices['BarometreLaGacilly']..' svalues='..otherdevices_svalues['BarometreLaGacilly']..' VoletCuisine='..otherdevices['VoletCuisine']) tmp = otherdevices_svalues['BarometreLaGacilly'] tab = split(tmp, ";") debug("######### Check fermeture : temperature lue par BarometreLaGacilly "..tab[1]) temp = tonumber(tab[1]) if ( ( ( (temp < 6.0 and whenDark() <= 30) or (temp < 8 and whenDark() <= 15) or (temp < 10 and whenDark() <= 0) ) ) or ( uservariables['Dark'] == "True" ) ) then debug("######### Dans temperature") if (otherdevices['VoletCuisine'] == 'Open') then -- or (minutes % 10 == 0 and heures <=20) ) then commandArray['VoletCuisine']='On' end if (otherdevices['VoletSalonTele'] == 'Open') then -- or (minutes % 10 == 0 and heures <=20)) then commandArray['VoletSalonTele']='On' end else debug("############ PAS DANS LE IF") end end -- ------------------------------------------------------------------------------ -- Ouverture des volets en fonction de la temperature exterieure Hiver et Automne -- ------------------------------------------------------------------------------ if minutes%5 == 0 and heures <= HEURE_DEB and ((heures >= 9 and josdJourChome()) or (heures > 6 and not josdJourChome())) and (saison == "Hiver" or saison == "Automne") and (greater2(uservariables["Heure"],uservariables["Lever"], - 30)) -- heures >= 20 and (otherdevices['VoletCuisine'] == 'Closed' or otherdevices['VoletSalonTele'] == 'Closed' or otherdevices['VoletPorteSalon'] == 'Closed' ) then debug('------------------------------------------------------') debug(' Test ouverture volet ') debug('------------------------------------------------------') debug('####### Comparaison heure vs Lever du soleil ========>'..uservariables["Heure"].. " "..uservariables["Lever"]) debug('####### Lancement du check test ' ..heures..'h'..minutes..' volet cuisine ' ..otherdevices['BarometreLaGacilly']..' svalues='..otherdevices_svalues['BarometreLaGacilly']..' VoletCuisine='..otherdevices['VoletCuisine']) tmp = otherdevices_svalues['BarometreLaGacilly'] tab = split(tmp, ";") debug("######### Check Ouverture : temperature lue par BarometreLaGacilly "..tab[1]) temp = tonumber(tab[1]) if (temp > 12.0 or (heures >=9 and minutes >= 30)) then if (otherdevices['VoletCuisine'] == 'Closed' or (minutes % 10 == 0 and heures == 9)) then commandArray['VoletCuisine']='Off' end if (otherdevices['VoletSalonTele'] == 'Closed' or (minutes % 10 == 0 and heures == 9)) then commandArray['VoletSalonTele']='Off' end if (otherdevices['VoletPorteSalon'] == 'Closed' or (minutes % 10 == 0 and heures == 9)) then commandArray['VoletPorteSalon']='Off' end end end -- ------------------------------------------------------------------------------ -- fermeture des volets en fonction de la temperature interieure en ete -- ------------------------------------------------------------------------------ if minutes%5 == 0 --and uservariables['Dark'] == "False" and (heures > HEURE_DEB and heures <= HEURE_FIN) --and (saison == "ete") --and (greater(uservariables["Heure"] , uservariables["Lever"])) -- heures >= 20 --and (otherdevices['VoletCuisine'] == 'Open' or otherdevices['VoletSalonTele'] == 'Open' or otherdevices['VoletPorteSalon'] == 'Open') then debug('------------------------------------------------------') debug(' Test fermeture volet Ete') debug('------------------------------------------------------') debug('####### Lancement du check test ' ..heures..'h'..minutes..' volet cuisine '..otherdevices['BarometreLaGacilly']..' svalues='..otherdevices_svalues['BarometreLaGacilly']..' VoletCuisine='..otherdevices['VoletCuisine']) local val local val2 val, val2 = otherdevices_svalues['BarometreLaGacilly']:match("([^;]+);([^;]+)") debug("BarometreLaGacilly"..otherdevices["BarometreLaGacilly"]..val.." "..val2..otherdevices['VoletCuisine'].." "..otherdevices['VoletSalonTele'].." "..otherdevices['VoletPorteSalon']) local temp = tonumber(val) if temp >= TEMP_MAX and (otherdevices['VoletCuisine'] == 'Open' and otherdevices['VoletSalonTele'] == 'Open' and otherdevices['VoletPorteSalon'] == 'Open') then debug("fermeture volets : temp élevée") if temp >= TEMP_MAX_2 then os.execute("/opt/domoticz/scripts/volets2.sh On &") else os.execute("/opt/domoticz/scripts/volets.sh On &") end end end -- ------------------------------------------------------------------------------ -- Réouverture après la vague de chaleur ETE -- ------------------------------------------------------------------------------ if minutes%5 == 0 and (heures > HEURE_FIN and heures <= 19) and (saison == "ete" ) then local val local val2 val, val2 = otherdevices_svalues['BarometreLaGacilly']:match("([^;]+);([^;]+)") print("BarometreLaGacilly"..otherdevices["BarometreLaGacilly"].." "..val.." "..val2..otherdevices['VoletCuisine'].." "..otherdevices['VoletSalonTele'].." "..otherdevices['VoletPorteSalon']) local temp = tonumber(val) if ((temp <= 24 or (temp <= TEMP_MAX and heures >= 18)) and (otherdevices['VoletCuisine'] == 'Closed' and otherdevices['VoletSalonTele'] == 'Closed' and otherdevices['VoletPorteSalon'] == 'Closed')) then debug("Ouverture volets : temp en baisse") os.execute("/opt/domoticz/scripts/volets.sh Off &") end end return commandArray