Bonjour,
J'utilise ce type de script depuis Novembre 2014, basé sur un autre script avec hystérésis, c'est (très) efficace j'ai apporté pls amélioration avec le temps, mode Confort, mode Eco, mode Eco++
j'enregistre les log dans un fichier externe au raspbery avec la température ext prise via accuweather
Alerte SMS, si les mode absence et présent sont actif en même temps par ex:
La fonction round permet d'arrondir la valeur des capteurs de T°à +/- 0,1°
Absence -> bouton absent -> permet de passé le chauffage en mode ECO++
Présent -> Bouton Présent -> prend la priorité sur les horaires de planning du thermostat (bouton virtuel qui déclenche les radiateur via planification)
Les valeurs de chauffage sont prise dans les variables utilisateurs (plus facile a changer a distance qu'un script)
L’hystérésis permet de ne pas faire des marches/arrêt en permanences des radiateurs
le changement d'état des radiateurs ce fait toutes les 2/3 minutes (0,3,5,8), cela permet d'éviter une hausse ou baisse trop éloigné de la température souhaité.
J'ai mis sondebak et sondeext mais elle ne sont pas utilisé dans le script
Code : Tout sélectionner
#####
local sonde = 'TEMP_SAM' -- nom de la Sonde de temperature à surveiller
local sondebak = 'TEMP_CUISINE' -- nom de la Sonde de temperature de backup à surveiller
local sondeExt = 'TEMP_GRENIER' -- nom de la Sonde de temperature ext
local thermostat = 'Thermostat_SAM' -- Interrupteur virtuel du thermostat (a planifier)
local radiateurRDC = 'RADIATEUR_RDC' -- Nom du radiateur a allumer/eteindre
local Absence = 'Absence' -- Thermostat On/Off pour gerer les vacances/absences, a planifier
local Present = 'Present' -- Thermostat On/Off pour gerer les présences, a planifier
function round(num, dec,src)
if num then
local mult = 10^(dec or 2)
return math.floor(num * mult + 0.5) / mult
else
print('La sonde ('.. src..') déconne ???')
return 50
end
end
function echo(msg)
print('Therm log -> '..msg)
local temps = os.date("*t")
if ((temps.min % 10)==0) then
local namefile = '/mnt/dell/e/rpi_chauf_rdc_'..temps.year..'-'..temps.month..'.log'
local file = io.open(namefile, "a")
print('Print in file '..namefile)
file:write(os.date()..';'..msg, "\n")
file:flush()
file:close()
if unexpected_condition then
print('Err ecriture vers DELL')
end
end
return ""
end
commandArray = {}
local consigneCONF = uservariables["consigneCONF"] -- Temperature de consigne CONFORT
local consigneECO = uservariables["consigneECO"] -- Temperature de consigne ECO
local consigneECOpp = uservariables["consigneECOpp"] -- Temperature de consigne ECO++
local hysteresis = uservariables["hysteresis"] -- Valeur seuil pour eviter que le relai ne cesse de commuter dans les 2 sens
local time2 = os.date("*t")
if ((otherdevices[Absence]=='On') and (otherdevices[Present]=='On')) then
echo('********* ABSENT ET PRESENT EN MEME TPS ??? *********')
if (time2.min==0) then
os.execute('curl -isk "https://smsapi.free-mobile.fr/sendmsg?user=#USER&pass=#PASSWORD&msg=ABSENT ET PRESENT EN MEME TPS ???"')
end
end
if (otherdevices[Absence]=='Off') then
-- Absent=Off (mode 'normal')
-- Check toutes les 10 minutes 0, 10, 20, 30, 40, 50
-- if (devicechanged[sondeext]) then
-- local tempeext = round(devicechanged[string.format('%s_Temperature', sondeext)],1)
-- print('Temperature EXT = '..tempext)
-- end
if ( (devicechanged[sonde]) and ( ((time2.min % 10)==0) or ((time2.min % 10)==3) or ((time2.min % 10)==5) or ((time2.min % 10)==8) )) then
local temperature = round(devicechanged[string.format('%s_Temperature', sonde)],1,sonde)
print('Temperature sonde Salon = '..temperature)
if otherdevices[Present]=='On' then
print('Mode PRESENT H24=ON, mode Confort seulement')
end
-- on utilise que HUM
WU_sWeatherTemp, hum = otherdevices_svalues['WU_ACHERES']:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
-- on utilise sWeatherTemp (temp resenti)
dir1, dir2, speed,Vval4,Vval5,WU_RESENT_TEMP = otherdevices_svalues['WU_VENTS']:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
if (otherdevices[thermostat]=='On') or (otherdevices[Present]=='On') then
print('Thermostat RDC OFF --> CONFORT ('..(consigneCONF-hysteresis)..' => *'.. consigneCONF ..'* <= '..(consigneCONF+hysteresis)..')')
if (temperature <= (consigneCONF - hysteresis) ) then
commandArray[radiateurRDC]='Off'
echo(temperature..';Trop Froid;Allumage du chauffage RDC;(Mode CONFORT);'..tonumber(WU_RESENT_TEMP)..';'..tonumber(hum))
elseif (temperature >= (consigneCONF + hysteresis)) then
commandArray[radiateurRDC]='On'
echo(temperature..';Trop chaud;Extinction du chauffage au RDC;(Mode CONFORT);'..tonumber(WU_RESENT_TEMP)..';'..tonumber(hum))
end
end
if ((otherdevices[thermostat]=='Off') and (otherdevices[Present]=='Off')) then
print('Thermostat RDC ON --> ECO ('..(consigneECO-hysteresis)..' => *'.. consigneECO ..'* <= '..(consigneECO+hysteresis)..')')
if (temperature <= (consigneECO - hysteresis) ) then
commandArray[radiateurRDC]='Off'
echo(temperature..';Trop froid;Allumage du chauffage RDC;(Mode ECO);'..tonumber(WU_RESENT_TEMP)..';'..tonumber(hum))
elseif (temperature > (consigneECO + hysteresis)) then
commandArray[radiateurRDC]='On'
echo(temperature..';Trop chaud;Extinction du chauffage RDC;(Mode ECO);'..tonumber(WU_RESENT_TEMP)..';'..tonumber(hum))
end
end
end
else
-- mode Absence
if ((devicechanged[sonde]) and ((time2.min % 10)==0)) then
local temperature = round(devicechanged[string.format('%s_Temperature', sonde)],1,sonde)
print('Temperature sonde Salon = '..temperature)
print('Mode Absence Actif -> ECO++ ('..(consigneECOpp-hysteresis)..' => *'.. consigneECOpp ..'* <= '..(consigneECOpp+hysteresis)..')')
if (temperature <= (consigneECOpp - hysteresis)) then
commandArray[radiateurRDC]='Off'
echo(temperature..';Trop froid;Allumage du chauffage RDC;(Mode ECO++);'..tonumber(WU_RESENT_TEMP)..';'..tonumber(hum))
elseif (temperature > (consigneECOpp + hysteresis)) then
commandArray[radiateurRDC]='On'
echo(temperature..';Trop chaud;Extinction du chauffage RDC;(Mode ECO++);'..tonumber(WU_RESENT_TEMP)..';'..tonumber(hum))
end
end
end
return commandArray