Page 1 sur 1

[LUA] Thermostat Simple avec Interrupteur.

Publié : 08 nov. 2016, 16:10
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 !

Re: Thermostat Simple avec Interrupteur.

Publié : 08 nov. 2016, 20:31
par Gaz
Merci pour le partage.

Re: Thermostat Simple avec Interrupteur.

Publié : 09 nov. 2016, 12:44
par foudepc83
Gaz a écrit :Merci pour le partage.
Mais c'est normal ;)

Re: Thermostat Simple avec Interrupteur.

Publié : 18 nov. 2016, 09:35
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

Re: Thermostat Simple avec Interrupteur.

Publié : 18 nov. 2016, 16:58
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 .