@greg : j'ai fait deux petites modifications dans ton script.
1- Il me semble qu'il y a une petite erreur dans le calcul de l'utilisation des radiateurs
Dans la fonction
commandHeating(sCommand,iTime)
Avant modif :
Code : Tout sélectionner
if( sCommand == sHeatingOnForCommand ) then
fIntervalEnergy = fIntervalEnergy + (tonumber(fInstantPower) / 60 ) * iHeatingCycleDuration
else
fIntervalEnergy = fIntervalEnergy + tonumber(fInstantPower) / 60
end
Après modif :
Code : Tout sélectionner
if( sCommand == sHeatingOnForCommand ) then
fIntervalEnergy = fIntervalEnergy + (tonumber(fInstantPower) / 60 ) * iTime
elseif (sCommand ~= sHeatingOffCommand ) then
fIntervalEnergy = fIntervalEnergy + tonumber(fInstantPower) / 60 * iHeatingCycleDuration
end
En effet, lorsque le radiateur reçoit une commande "ON FOR", il va chauffer pendant iTime minutes, pas pendant iHeatingCycleDuration minutes.
Et si on envoie la commande "ON" et pas "ON FOR", alors le radiateur va chauffer pendant iHeatingCycleDuration minutes.
Pourquoi j'enverrai "ON" et pas "ON FOR" me diras-tu ? Dans quel cas ?
2- Eviter deux ordres successifs
Lorsque le temps de chauffe est calculé à la même valeur que iHeatingCycleDuration, cela pose un pb à mes récepteurs X2D.
Je m'explique avec iHeatingCycleDuration = 10 minutes (par exemple) :
- Disons que le calcul donne 6 minutes de chauffe : j'utilise l'ordre ON FOR 6 ==> au bout de 6 minutes le récepteur X2D reçoit l'ordre OFF et attend 4 minutes avant la prochaine instruction.
- Si par contre le calcul donne 10 minutes de chauffe, j'appelle "ON" car l'ordre "ON FOR 10" va envoyer un ordre OFF au bout de 10 minutes suivi quelques millièmes de secondes plus tard par un autre ordre (ON, ON FOR ou OFF) : ce second ordre n'est pas forcément pris en compte par mon récepteur.
Peut-être qu'un module DIO accepte deux ordre séparés de quelques millièmes, et les traite bien tous les deux ? Mais pas mes RF660FP.
Du coup, voici mon autre modif (spécifique au protocole X2D, mais peut être généralisée dans le script) :
Script d'origine :
Code : Tout sélectionner
-- Heating cycle duration calculation
if( fPIDOutput > 0 ) then -- heat
fCycleDuration = round(fPIDOutput * iHeatingCycleDuration / 255,0)
if( fCycleDuration == 0 ) then fCycleDuration = 1 end -- Heating is needed, let's go for at least 1 minute
prDebug('Going to heat for : ' ..fCycleDuration..' minutes during the next '..round(iHeatingCycleDuration*60)..' seconds ('..iHeatingCycleDuration..' minutes) period.' )
commandHeating(sHeatingOnForCommand,fCycleDuration)
else -- Output null or negative, stop the heating
bDebug = true
prDebug(sZoneName..' : Temp='..fCurrentTemp..', Consigne='..fSetPointTemp..', Pas de chauffage dans les '..iHeatingCycleDuration..' prochaines minutes')
bDebug = false
commandHeating(sHeatingOffCommand)
end
Petite évolution qui évite deux ordres successifs :
Code : Tout sélectionner
-- Heating cycle duration calculation
if( fPIDOutput > 0 ) then -- heat
fCycleDuration = round(fPIDOutput * iHeatingCycleDuration / 255,0)
if( fCycleDuration == 0 ) then fCycleDuration = 1 end -- Heating is needed, let's go for at least 1 minute
prDebug('Going to heat for : ' ..fCycleDuration..' minutes during the next '..round(iHeatingCycleDuration*60)..' seconds ('..iHeatingCycleDuration..' minutes) period.' )
if (fCycleDuration == iHeatingCycleDuration)
then commandHeating(sHeatingComfortCommand)
else
commandHeating(sHeatingOnForCommand,fCycleDuration)
end
else -- Output null or negative, stop the heating
bDebug = true
prDebug(sZoneName..' : Temp='..fCurrentTemp..', Consigne='..fSetPointTemp..', Pas de chauffage dans les '..iHeatingCycleDuration..' prochaines minutes')
bDebug = false
commandHeating(sHeatingOffCommand)
end