[LUA] Thermostat Simple avec Interrupteur.

Vous avez créé un script LUA dont vous êtes fier, un .sh génial, un programme Python hors du commun, un Tuto, c'est ici que vous pouvez les partager.
foudepc83
Messages : 230
Inscription : 15 août 2016, 11:58

[LUA] Thermostat Simple avec Interrupteur.

Message par foudepc83 »

Bonjour,

Je partage mon script de thermostat simple avec interrupteur pour activer ou désactiver.

Je laisse l'entête du créateur du script car c'est basé de ce script.

A vous d'adapter le niveau de l'interrupteur du chauffage ( Pilote ou On/Off ) :

Il faut préalablement créer un interrupteur virtuel On/Off pour activer ou désactiver le thermostat , et éventuellement un interrupteur de type "Consigne de thermostat".

Code : Tout sélectionner

 -- Alexandre DUBOIS - 2014
 -- This script allows to maintain the temperatue between 19°C et 21°C when virtual
 -- 'Thermostat salon' is ON.
 
 --------------------------------
 ------ Start of edit section ------
 --------------------------------
 local consigne = 'Thermostat Salon'  -- Température de thermostat
 local hysteresis = 0.5 --Valeur seuil pour éviter que le relai ne cesse de commuter dans les 2 sens
 local sonde = 'Home : Salon' --Nom de la sonde de température
 local thermostat = 'Interrupteur Thermostat Salon' --Nom de l'interrupteur virtuel du thermostat
 local radiateur = 'Chauffage Salon' --Nom du radiateur à allumer/éteindre
 
 --------------------------------
 -- End of edit section --
 --------------------------------
 local temp_consign = tonumber(otherdevices_svalues[consigne])
 
 commandArray = {}
 --Oregon sensor 'Salon' send temperature every 40s. This will be the execution frequency of this script.
 if (devicechanged[sonde]) then
        local temperature = devicechanged[string.format('%s_Temperature', sonde)] --Temperature relevée dans le salon
        
             
         
     --On n'agit que si le "Thermostat" est actif
     if (otherdevices[thermostat]=='On') then
         print('-- Gestion du thermostat pour le salon --')
 
         if (temperature < (temp_consign - hysteresis) ) then
             print('Allumage du chauffage dans le salon')
             commandArray[radiateur]='Set Level 30'
 
             elseif (temperature > (temp_consign + hysteresis)) then
                 print('Extinction du chauffage dans le salon')
             commandArray[radiateur]='Off'
 
             end
         end

 end
 return commandArray
 
Amusez vous bien !
Gaz
Messages : 224
Inscription : 17 oct. 2015, 10:30

Re: Thermostat Simple avec Interrupteur.

Message par Gaz »

Merci pour le partage.
foudepc83
Messages : 230
Inscription : 15 août 2016, 11:58

Re: Thermostat Simple avec Interrupteur.

Message par foudepc83 »

Gaz a écrit :Merci pour le partage.
Mais c'est normal ;)
nissart
Messages : 145
Inscription : 20 avr. 2016, 15:00

Re: Thermostat Simple avec Interrupteur.

Message par nissart »

Hello,

je pense que tu peux simplifier ton premier "if"... dis moi ce que tu en penses

Code : Tout sélectionner

commandArray = {}

 if (devicechanged[sonde]) then
        local temperature = devicechanged[string.format('%s_Temperature', sonde)] 
 -- là tu fais fonctionner ton script à chaque fois que la valeur change. Est ce qu'on s'en fiche pas un peu si le thermostat est sur Off ?
             
    
     if (otherdevices[thermostat]=='On') then
         print('-- Gestion du thermostat pour le salon --')
 
         if (temperature < (temp_consign - hysteresis) ) then
             print('Allumage du chauffage dans le salon')
             commandArray[radiateur]='Set Level 30'
 
             elseif (temperature > (temp_consign + hysteresis)) then
                 print('Extinction du chauffage dans le salon')
             commandArray[radiateur]='Off'
 
             end
         end

 end
 return commandArray
Dis moi ce que tu penses de ca:

Code : Tout sélectionner

commandArray = {}

if (devicechanged[sonde]) and otherdevices[thermostat]=='On' then 
	local temperature = devicechanged[string.format('%s_Temperature', sonde)] 
 	print('-- Gestion du thermostat pour le salon --')
 
         if (temperature < (temp_consign - hysteresis) ) then
		print('Allumage du chauffage dans le salon')
		commandArray[radiateur]='Set Level 30'
 	elseif (temperature > (temp_consign + hysteresis))
		print('Extinction du chauffage dans le salon')
		commandArray[radiateur]='Off'
 	end
end
return commandArray
Rpi3 Domoticz v3.9389 - RFX433e - Kira128

Odroid C2/OpenPHT/ Pour le salon
Rpi3/Rasplex/ Pour la chambre

Rpi2/Runeaudio/ Pour le salon + terrasse
Rpi2 hifiberry AMP+/Runeaudio/ pour la sdb

Que j'aime ces petites bestioles !!!
foudepc83
Messages : 230
Inscription : 15 août 2016, 11:58

Re: Thermostat Simple avec Interrupteur.

Message par foudepc83 »

nissart a écrit :Hello,

je pense que tu peux simplifier ton premier "if"... dis moi ce que tu en penses

Code : Tout sélectionner

commandArray = {}

 if (devicechanged[sonde]) then
        local temperature = devicechanged[string.format('%s_Temperature', sonde)] 
 -- là tu fais fonctionner ton script à chaque fois que la valeur change. Est ce qu'on s'en fiche pas un peu si le thermostat est sur Off ?
             
    
     if (otherdevices[thermostat]=='On') then
         print('-- Gestion du thermostat pour le salon --')
 
         if (temperature < (temp_consign - hysteresis) ) then
             print('Allumage du chauffage dans le salon')
             commandArray[radiateur]='Set Level 30'
 
             elseif (temperature > (temp_consign + hysteresis)) then
                 print('Extinction du chauffage dans le salon')
             commandArray[radiateur]='Off'
 
             end
         end

 end
 return commandArray
Dis moi ce que tu penses de ca:

Code : Tout sélectionner

commandArray = {}

if (devicechanged[sonde]) and otherdevices[thermostat]=='On' then 
	local temperature = devicechanged[string.format('%s_Temperature', sonde)] 
 	print('-- Gestion du thermostat pour le salon --')
 
         if (temperature < (temp_consign - hysteresis) ) then
		print('Allumage du chauffage dans le salon')
		commandArray[radiateur]='Set Level 30'
 	elseif (temperature > (temp_consign + hysteresis))
		print('Extinction du chauffage dans le salon')
		commandArray[radiateur]='Off'
 	end
end
return commandArray
Pas faux , ca fais tourner le script même si l'interrupteur est en OFF !

Je vais corriger ca chez moi .
Répondre