J'utilise depuis longtemps le thermostat virtuel de YCSimon.
Je recupere mes temperatures via XapMcs1wire et McsXAP.
J'utilise DEUX thermostats.
J'ai modifié le script comme suit:
- Code: Tout sélectionner
' =================================================================================================
' =================================================================================================
' Création d'un thermostat virtuel dans Homeseer avec la temperature d'une sonde ou station météo
' ycsimon@free.fr
' =================================================================================================
' =================================================================================================
' =================================================================================================
' Polling (obtention régulière des données du thermostat) en minutes de 10 à 1440 (24h), 1mn si 0
' =================================================================================================
' pas d'obtention si >1440, y compris lors de l'initialisation si la ligne est supprimée
' L'apostrophe d'annotation ne doit pas être supprimé pour fonctionner
' [pollrate=1]
' =================================================================================================
' Le thermostat supporte le mode eco? Rq: comme il est virtuel on peut choisir... donc oui
' =================================================================================================
Function SupportsCoolSetPoint (device)
' 1 Le thermostat supporte le CoolSetPoint (Enregistrement de la valeur du mode eco)
' 0 Le thermostat ne supporte pas le CoolSetPoint
SupportsCoolSetPoint = 1
End Function
' =================================================================================================
' Renvoi la température et Gère les modules
' =================================================================================================
Function GetTemp (device)
device = Trim (hs.StringItem (device,1,":"))
' Création des variables au démarrage de Homeseer
If hs.CreateVar (device & "Affichage") = "" Then
hs.CreateVar (device & "Mode")
hs.CreateVar (device & "SetPoint")
hs.CreateVar (device & "CoolSetPoint")
hs.CreateVar (device & "OffSetPoint")
hs.CreateVar (device & "AuxSetPoint")
hs.CreateVar (device & "WaterSetPoint")
hs.CreateVar (device & "Devices")
hs.CreateVar (device & "IntSensor")
hs.CreateVar (device & "IntFactor")
hs.CreateVar (device & "ExtSensor")
hs.CreateVar (device & "ExtFactor")
hs.CreateVar (device & "WatSensor")
hs.CreateVar (device & "WatFactor")
hs.CreateVar (device & "RegTemp")
hs.CreateVar (device & "RegWatTemp")
hs.CreateVar (device & "MinWatTemp")
hs.CreateVar (device & "MaxWatTemp")
hs.CreateVar (device & "Delta")
hs.CreateVar (device & "Clim")
hs.CreateVar (device & "BtnSup")
IniExists = false
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists (hs.GetAppPath & "\config\VThermostat.ini") Then
Set f = fs.OpenTextFile (hs.GetAppPath & "\config\VThermostat.ini")
Do While Not f.AtEndOfStream
ThermoData = f.ReadLine
If hs.StringItem (ThermoData,1,",") = device Then
IniExists = true
Exit Do
End If
Loop
f.close
Set f = Nothing
End If
Set fs = Nothing
If IniExists Then
hs.SaveVar device & "Affichage", hs.StringItem (ThermoData,2,",")
hs.SaveVar device & "Mode", hs.StringItem (ThermoData,3,",")
hs.SaveVar device & "SetPoint", hs.StringItem (ThermoData,4,",")
hs.SaveVar device & "CoolSetPoint", hs.StringItem (ThermoData,5,",")
hs.SaveVar device & "OffSetPoint", hs.StringItem (ThermoData,6,",")
hs.SaveVar device & "AuxSetPoint", hs.StringItem (ThermoData,7,",")
hs.SaveVar device & "Devices", hs.StringItem (ThermoData,8,",")
hs.SaveVar device & "IntSensor", hs.StringItem (ThermoData,9,",")
hs.SaveVar device & "IntFactor", hs.StringItem (ThermoData,10,",")
hs.SaveVar device & "ExtSensor", hs.StringItem (ThermoData,11,",")
hs.SaveVar device & "ExtFactor", hs.StringItem (ThermoData,12,",")
hs.SaveVar device & "WatSensor", hs.StringItem (ThermoData,13,",")
hs.SaveVar device & "WatFactor", hs.StringItem (ThermoData,14,",")
hs.SaveVar device & "RegTemp", hs.StringItem (ThermoData,15,",")
hs.SaveVar device & "RegWatTemp", hs.StringItem (ThermoData,16,",")
hs.SaveVar device & "MinWatTemp", hs.StringItem (ThermoData,17,",")
hs.SaveVar device & "MaxWatTemp", hs.StringItem (ThermoData,18,",")
hs.SaveVar device & "Delta", hs.StringItem (ThermoData,19,",")
hs.SaveVar device & "Clim", hs.StringItem (ThermoData,20,",")
hs.SaveVar device & "BtnSup", hs.StringItem (ThermoData,21,",")
Else
IniThermo (device)
End If
' Création des boutons supplémentaires au démarrage de Homeseer
hs.GetDeviceByRef (hs.GetDeviceRef (device)).buttons = ""
hs.DeviceButtonAdd device, "VThermostat.thm (""ResetThermo"", " & device & ")", "Reset"
BtnSup = hs.GetVar (device & "BtnSup")
If BtnSup = "1" or BtnSup = "2" Then
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointP1"", " & device & ")", "<br>H+1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointM1"", " & device & ")", "H-1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointP01"", " & device & ")", "H+0.1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointM01"", " & device & ")", "H-0.1"
End If
If BtnSup ="1" or BtnSup = "3" Then
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointP1"", " & device & ")", "<br>C+1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointM1"", " & device & ")", "C-1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointP01"", " & device & ")", "C+0.1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointM01"", " & device & ")", "C-0.1"
ElseIf BtnSup = "4" Then
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointP1"", " & device & ")", "<br>H+1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointM1"", " & device & ")", "H-1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointP1"", " & device & ")", "C+1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointM1"", " & device & ")", "C-1"
ElseIf BtnSup = "5" Then
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointP01"", " & device & ")", "H+0.1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointM01"", " & device & ")", "H-0.1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointP01"", " & device & ")", "C+0.1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointM01"", " & device & ")", "C-0.1"
End If
End If
' Défintion du seuil et de la string du mode
m = hs.GetVar (device & "Mode")
s = hs.GetVar (device & "SetPoint")
c = hs.GetVar (device & "CoolSetPoint")
o = hs.GetVar (device & "OffSetPoint")
a = hs.GetVar (device & "AuxSetPoint")
astring = "-" & a
If hs.GetVar (device & "Clim") = "1" Then
astring = "+" & a
a = 0 - a
End If
Select Case m
Case 00, 01
sp = o
m = "Hors-gel"
Case 10, 11, 30
sp = s
If m = 30 Then m = "Auto(Confort)" Else m = "Confort" End If
Case 20, 21, 31
sp = c
If m = 31 Then m = "Auto(Eco)" Else m = "Eco" End If
Case 40
sp = s - a
m = "Aux(Confort" & astring & ")"
Case 41
sp = c - a
m = "Aux(Eco" & astring & ")"
End Select
' Défintion de la commande de chauffe
delta = 0
If hs.GetVar (device & "ExtSensor") <> "" and hs.GetVar (device & "WatSensor") <> "" Then
tint = sp
text = GetExteriorTemp (device)
twat = GetWaterTemp (device)
tr = CInt (hs.GetVar (device & "RegTemp"))
trwat = CInt (hs.GetVar (device & "RegWatTemp"))
w = ((trwat - 20) / (20 - tr)) * (sp - text) + 20
tstring = twat & "°"
If hs.GetVar (device & "IntSensor") <> "" Then
tint = GetInteriorTemp (device)
w = w + 0.25 * (trwat - 20) * Sgn (sp - tint) * Sin ((pi / 4) * Min (2, Abs (sp - tint)))
tstring = tint & "°(" & tstring & ")"
End If
w = Round (w, 1)
wstring = w & "° "
hs.SaveVar device & "WaterSetPoint", w
If hs.GetVar (device & "Delta") <> "" Then
delta = (CInt (hs.GetVar (device & "Delta")) / 200) * ((trwat - 20) / (20 - tr)) * Max (0, tint - text)
dstring = "±" & Round (delta, 1) & "° "
End If
If twat > w + delta Then
commande = "Off"
ElseIf twat <= w - delta Then
commande = "On"
End If
Else
tint = GetInteriorTemp (device)
' hs.writelog "Info_2", "temp Sonde "& tint &" "& device
' hs.writelog "Info_3", "temp BASE "& sp
If hs.GetVar (device & "Delta") <> "" Then
delta = CInt (hs.GetVar (device & "Delta")) / 10
dstring = "±" & Round (delta, 1) & "° "
End If
If tint > sp + delta Then
commande = "Off"
ElseIf tint <= sp - delta Then
commande = "On"
End If
' hs.writelog "Info_4", "Commande "& commande
tstring = tint & "°"
If hs.GetVar (device & "WatSensor") <> "" Then
twat = GetWaterTemp (device)
tstring = tstring & "(" & twat & "°)"
End If
End If
' Inversion de la commande en cas de clim
If hs.GetVar (device & "Clim") = "1" Then
If commande = "On" Then
commande = "Off"
ElseIf commande = "Off" Then
commande = "On"
End If
End If
' Respect des limites de la température d'eau
If hs.GetVar (device & "WatSensor") <> "" Then
If hs.GetVar (device & "MinWatTemp") <> "" Then
If twat <= CInt (hs.GetVar (device & "MinWatTemp")) Then commande = "On" End If
End If
If hs.GetVar (device & "MaxWatTemp") <> "" Then
If twat >= CInt (hs.GetVar (device & "MaxWatTemp")) Then commande = "Off" End If
End If
End If
' Envoi de la commande aux modules de chauffage
i=1
Do
module = Trim (hs.StringItem (hs.GetVar (device & "Devices"), i, "-"))
If module = "" Then Exit Do
If (commande = "On" and hs.IsOff(module)) or (commande = "Off" and hs.IsOn(module)) Then
hs.ExecX10 "" & module, commande, 0, 0
hs.WriteLog "info", "commande du module " & module & " Ă " & commande
hs.SetDeviceLastChange device, Now
End If
i = i + 1
Loop
' Mise Ă jour du status du thermostat
Select Case hs.GetVar (device & "Affichage")
Case 1 hs.SetDeviceString device, tstring & " [ " & m & " ]</small>"
Case 2 hs.SetDeviceString device, tstring & " [ " & wstring & s & "° " & c & "° " & m & " ]</small>"
Case 3 hs.SetDeviceString device, tstring & " [ " & wstring & dstring & s & "° " & c & "° " & o & "° " & a & "° " & m & " ]</small>"
End Select
' -----------------------------------------------------
' Modification JF LAGARDE 08/05/2009
' hs.WriteLog "info1", tstring
' hs.WriteLog "info2", wstring
' hs.WriteLog "info3", dstring
' hs.WriteLog "info4", s
' hs.WriteLog "info5", c
' hs.WriteLog "info6", o
' hs.WriteLog "info7", a
' hs.WriteLog "info8", m
'm = Mode du chauffage / type
'hs.WriteLog "Info_m" , m
Mode_1 = InStr(1 , m ,"(")
'hs.writelog "info_mode1" , Mode_1
Mode1Len = len(m)
'hs.writelog "info_mode1len" , Mode1Len
'Type1 = left(m,Mode_1)
'hs.writelog "info_Type1" , Type1'
If Mode_1 > 0 then
Type1 = left(m,Mode_1-1)
If Type1 <> "Aux" Then
hs.SetDeviceString device&"1", Mid(m ,Mode_1+1,Mode1Len-Mode_1-1)
hs.SetDeviceLastChange device&"1", Now
hs.SetDeviceString device&"9", Type1
Else
hs.SetDeviceString device&"1", Mid(m ,Mode_1+1,Mode1Len-Mode_1-3)
hs.SetDeviceLastChange device&"1", Now
hs.SetDeviceString device&"9", Type1
End if
Else
hs.SetDeviceString device&"1", Mid(m ,Mode_1+1,Mode1Len-Mode_1)
hs.SetDeviceString device&"9", "None"
End If
's = HeatSetPoint
hs.SetDeviceString device&"2", s
'c = CoolsetPoint
hs.SetDeviceString device&"3", c
'o = OffSetPoint
hs.SetDeviceString device&"4", o
'a = AuxSetPoint
hs.SetDeviceString device&"5", a
'wstring = Watersetpoint
hs.SetDeviceString device&"6", wstring
'dstring = Deltasetpoint
hs.SetDeviceString device&"7", dstring
'tstring = Temperature
'hs.WriteLog "info5", tstring
tstring_l = len(tstring)
'hs.WriteLog "info6", tstring_l
hs.SetDeviceString device&"8", left(tstring,tstring_l-1)
hs.SetDeviceValue device&"8", left(tstring,tstring_l-1) * 10
' Fin de modifications
' -----------------------------------------------------
' Renvoi de la température intérieure ou de la consigne
GetTemp = tint
End Function
' =================================================================================================
' Renvoi la température intérieure
' =================================================================================================
Function GetInteriorTemp (device)
device = Trim (device)
i=1
tint=0
Do
sensor = Trim (hs.StringItem (hs.GetVar (device & "IntSensor"), i, "+"))
If sensor = "" Then Exit Do
If hs.GetVar (device & "IntFactor") = 0 Then
' -----------------------------------------------------
' Modification JF LAGARDE 15/02/2009
' tint = tint + Trim (Replace (Replace (Replace (hs.DeviceString (sensor), "°", ""), "C", ""), "F", ""))
' -----------------------------------------------------
' Modification JF LAGARDE 15/02/2009
tint = tint + text2
' -----------------------------------------------------
Else
text1 = hs.DeviceString (sensor)
'hs.writelog "info_6" , hs.DeviceValue (sensor)
position1 = InStr(1 , Text1 ,"left'>")
'hs.writelog "info_7" , position1
position2 = InStr(1 , Text1 ,"C<")
'hs.writelog "info_8" , position2
longueur = position2-12-position1
'hs.writelog "info_9" , longueur
text2 = mid(Text1 , position1 +6 , longueur)
'hs.writelog "info_sensor_text2" , text2
' -----------------------------------------------------
' Modification JF LAGARDE 15/02/2009
' tint = tint + (hs.DeviceValue (sensor) / hs.GetVar (device & "IntFactor")*10)
'
' tint = tint + text2 / hs.GetVar (device & "IntFactor")
tint = tint + text2
' hs.writelog "info_TINT_1", "valeur tint du sensor text "& text2
' -----------------------------------------------------
End If
i = i + 1
Loop
If i > 1 Then tint = Round ((tint / (i - 1)), 2) Else tint = Round (tint, 2) End If
GetInteriorTemp = tint
' hs.writelog "info_TINT", "valeur tint du sensor "& tint
End Function
' =================================================================================================
' Renvoi la température extérieure
' =================================================================================================
Function GetExteriorTemp (device)
device = Trim (device)
i=1
text=0
Do
sensor = Trim (hs.StringItem (hs.GetVar (device & "ExtSensor"), i, "+"))
If sensor = "" Then Exit Do
If hs.GetVar (device & "ExtFactor") = 0 Then
text = text + Trim (Replace (Replace (Replace (hs.DeviceString (sensor), "°", ""), "C", ""), "F", ""))
Else
text = text + (hs.DeviceValue (sensor) / hs.GetVar (device & "ExtFactor"))
End If
i = i + 1
Loop
If i > 1 Then text = Round ((text / (i - 1)), 1) Else text = Round (text, 1) End If
GetExteriorTemp = text
End Function
' =================================================================================================
' Renvoi la température d'eau
' =================================================================================================
Function GetWaterTemp (device)
device = Trim (device)
i=1
twat=0
Do
sensor = Trim (hs.StringItem (hs.GetVar (device & "WatSensor"), i, "+"))
If sensor = "" Then Exit Do
If hs.GetVar (device & "WatFactor") = 0 Then
twat = twat + Trim (Replace (Replace (Replace (hs.DeviceString (sensor), "°", ""), "C", ""), "F", ""))
Else
twat = twat + (hs.DeviceValue (sensor) / hs.GetVar (device & "WatFactor"))
End If
i = i + 1
Loop
If i > 1 Then twat = Round ((twat / (i - 1)), 1) Else twat = Round (twat, 1) End If
GetWaterTemp = twat
End Function
' =================================================================================================
' Renvoi le SetPoint
' =================================================================================================
Function GetSetPoint (device)
device = Trim (device)
GetSetPoint = hs.GetVar (device & "SetPoint")
End Function
' =================================================================================================
' Renvoi le CoolSetPoint
' =================================================================================================
Function GetCoolSetPoint (device)
device = Trim (device)
GetCoolSetPoint = hs.GetVar (device & "CoolSetPoint")
End Function
' =================================================================================================
' Renvoi le OffSetPoint
' =================================================================================================
Function GetOffSetPoint (device)
device = Trim (device)
GetOffSetPoint = hs.GetVar (device & "OffSetPoint")
End Function
' =================================================================================================
' Renvoi le AuxSetPoint
' =================================================================================================
Function GetAuxSetPoint (device)
device = Trim (device)
GetAuxSetPoint = hs.GetVar (device & "AuxSetPoint")
End Function
' =================================================================================================
' Renvoi le WaterSetPoint
' =================================================================================================
Function GetWaterSetPoint (device)
device = Trim (device)
GetWaterSetPoint = hs.GetVar (device & "WaterSetPoint")
End Function
' =================================================================================================
' Renvoi le mode de fonctionnement: 0/1/2/3/4 pour Hors-gel/Confort/Eco/Auto/Aux
' =================================================================================================
Function GetMode (device)
device = Trim (device)
GetMode = Left (hs.GetVar (device & "Mode"), 1)
End Function
' =================================================================================================
' Renvoi le mode de fonctionnement Auto: 0/1 pour Auto(Confort/Eco)
' =================================================================================================
Function GetFan (device)
device = Trim (device)
GetFan = Right (hs.GetVar (device & "Mode"), 1)
End Function
' =================================================================================================
' Change et renvoi le SetPoint
' =================================================================================================
Function SetSetPoint (params) ' params = device:SetPoint
device = Trim (hs.StringItem (params, 1, ":"))
SetSetPoint = Trim (hs.StringItem (params, 2, ":"))
If SetSetPoint <> hs.GetVar (device & "SetPoint") Then
hs.SaveVar device & "SetPoint", SetSetPoint
hs.SetDeviceLastChange device, Now
SaveThermo (device)
GetTemp (device)
End If
End Function
' =================================================================================================
' Change et renvoi le SetPoint +1
' =================================================================================================
Function SetSetPointP1 (device)
device = Trim (device)
SetSetPoint (device & ":" & hs.GetVar (device & "SetPoint") + 1)
End Function
' =================================================================================================
' Change et renvoi le SetPoint -1
' =================================================================================================
Function SetSetPointM1 (device)
device = Trim (device)
SetSetPoint (device & ":" & hs.GetVar (device & "SetPoint") - 1)
End Function
' =================================================================================================
' Change et renvoi le SetPoint +0.1
' =================================================================================================
Function SetSetPointP01 (device)
device = Trim (device)
SetSetPoint (device & ":" & hs.GetVar (device & "SetPoint") + 1 / 10)
End Function
' =================================================================================================
' Change et renvoi le SetPoint -0.1
' =================================================================================================
Function SetSetPointM01 (device)
device = Trim (device)
SetSetPoint (device & ":" & hs.GetVar (device & "SetPoint") - 1 / 10)
End Function
' =================================================================================================
' Change et renvoi le CoolSetPoint
' =================================================================================================
Function SetCoolSetPoint (params) ' params = device:CoolSetPoint
device = Trim (hs.StringItem (params, 1, ":"))
SetCoolSetPoint = Trim (hs.StringItem (params, 2, ":"))
If SetCoolSetPoint <> hs.GetVar (device & "CoolSetPoint") Then
hs.SaveVar device & "CoolSetPoint", SetCoolSetPoint
hs.SetDeviceLastChange device, Now
SaveThermo (device)
GetTemp (device)
End If
End Function
' =================================================================================================
' Change et renvoi le CoolSetPoint +1
' =================================================================================================
Function SetCoolSetPointP1 (device)
device = Trim (device)
SetCoolSetPoint (device & ":" & hs.GetVar (device & "CoolSetPoint") + 1)
End Function
' =================================================================================================
' Change et renvoi le CoolSetPoint -1
' =================================================================================================
Function SetCoolSetPointM1 (device)
device = Trim (device)
SetCoolSetPoint (device & ":" & hs.GetVar (device & "CoolSetPoint") - 1)
End Function
' =================================================================================================
' Change et renvoi le CoolSetPoint +0.1
' =================================================================================================
Function SetCoolSetPointP01 (device)
device = Trim (device)
SetCoolSetPoint (device & ":" & hs.GetVar (device & "CoolSetPoint") + 1 / 10)
End Function
' =================================================================================================
' Change et renvoi le CoolSetPoint -0.1
' =================================================================================================
Function SetCoolSetPointM01 (device)
device = Trim (device)
SetCoolSetPoint (device & ":" & hs.GetVar (device & "CoolSetPoint") - 1 / 10)
End Function
' =================================================================================================
' Change et renvoi le OffSetPoint
' =================================================================================================
Function SetOffSetPoint (params) ' params = device:OffSetPoint
device = Trim (hs.StringItem (params, 1, ":"))
SetOffSetPoint = Trim (hs.StringItem (params, 2, ":"))
If SetOffSetPoint <> hs.GetVar (device & "OffSetPoint") Then
hs.SaveVar device & "OffSetPoint", SetOffSetPoint
hs.SetDeviceLastChange device, Now
SaveThermo (device)
GetTemp (device)
End If
End Function
' =================================================================================================
' Change et renvoi le AuxSetPoint
' =================================================================================================
Function SetAuxSetPoint (params) ' params = device:AuxSetPoint
device = Trim (hs.StringItem (params, 1, ":"))
SetAuxSetPoint = Trim (hs.StringItem (params, 2, ":"))
If SetAuxSetPoint <> hs.GetVar (device & "AuxSetPoint") Then
hs.SaveVar device & "AuxSetPoint", SetAuxSetPoint
hs.SetDeviceLastChange device, Now
SaveThermo (device)
GetTemp (device)
End If
End Function
' =================================================================================================
' Change et renvoi le mode de fonctionnement: 0/1/2/3/4 pour Hors-gel/Confort/Eco/Auto/Aux
' =================================================================================================
Function SetMode (params) ' params = device:mode
device = Trim (hs.StringItem (params, 1, ":"))
mode = hs.GetVar (device & "Mode")
SetMode = CInt (Left (Trim (hs.StringItem (params, 2, ":")), 1))
If SetMode <> CInt (Left (mode, 1)) and SetMode <= 4 Then
hs.SaveVar device & "Mode", SetMode & Right (mode, 1)
hs.SetDeviceLastChange device, Now
SaveThermo (device)
GetTemp (device)
End If
End Function
' =================================================================================================
' Change et renvoi le mode de fonctionnement Auto: 0/1 pour Auto(Confort/Eco)
' =================================================================================================
Function SetFan (params) ' params = device:mode
device = Trim (hs.StringItem (params, 1, ":"))
mode = hs.GetVar (device & "Mode")
SetFan = CInt (Right (Trim (hs.StringItem (params, 2, ":")), 1))
If SetFan <> CInt (Right (mode, 1)) and SetFan <= 1 Then
hs.SaveVar device & "Mode", Left (mode, 1) & SetFan
hs.SetDeviceLastChange device, Now
SaveThermo (device)
GetTemp (device)
End If
End Function
' =================================================================================================
' Sauvegarde des paramètres du thermostat
' =================================================================================================
Function SaveThermo (device)
device = Trim (device)
ThermoData = ""
ecrit = false
Set fs = CreateObject ("Scripting.FileSystemObject")
If fs.FileExists (hs.GetAppPath & "\config\VThermostat.ini") Then
Set f = fs.OpenTextFile (hs.GetAppPath & "\config\VThermostat.ini")
Do While Not f.AtEndOfStream
temp = f.ReadLine
If hs.StringItem (temp,1,",") = device Then
ThermoData = Thermodata & device & "," & _
hs.GetVar (device & "Affichage") & "," & _
hs.GetVar (device & "Mode") & "," & _
hs.GetVar (device & "SetPoint") & "," & _
hs.GetVar (device & "CoolSetPoint") & "," & _
hs.GetVar (device & "OffSetPoint") & "," & _
hs.GetVar (device & "AuxSetPoint") & "," & _
hs.GetVar (device & "Devices") & "," & _
hs.GetVar (device & "IntSensor") & "," & _
hs.GetVar (device & "IntFactor") & "," & _
hs.GetVar (device & "ExtSensor") & "," & _
hs.GetVar (device & "ExtFactor") & "," & _
hs.GetVar (device & "WatSensor") & "," & _
hs.GetVar (device & "WatFactor") & "," & _
hs.GetVar (device & "RegTemp") & "," & _
hs.GetVar (device & "RegWatTemp") & "," & _
hs.GetVar (device & "MinWatTemp") & "," & _
hs.GetVar (device & "MaxWatTemp") & "," & _
hs.GetVar (device & "Delta") & "," & _
hs.GetVar (device & "Clim") & "," & _
hs.GetVar (device & "BtnSup") & VbCrLf
ecrit = true
Else
ThermoData = Thermodata & temp & VbCrLf
End If
Loop
f.close
End If
If ecrit = false Then
ThermoData = Thermodata & device & "," & _
hs.GetVar (device & "Affichage") & "," & _
hs.GetVar (device & "Mode") & "," & _
hs.GetVar (device & "SetPoint") & "," & _
hs.GetVar (device & "CoolSetPoint") & "," & _
hs.GetVar (device & "OffSetPoint") & "," & _
hs.GetVar (device & "AuxSetPoint") & "," & _
hs.GetVar (device & "Devices") & "," & _
hs.GetVar (device & "IntSensor") & "," & _
hs.GetVar (device & "IntFactor") & "," & _
hs.GetVar (device & "ExtSensor") & "," & _
hs.GetVar (device & "ExtFactor") & "," & _
hs.GetVar (device & "WatSensor") & "," & _
hs.GetVar (device & "WatFactor") & "," & _
hs.GetVar (device & "RegTemp") & "," & _
hs.GetVar (device & "RegWatTemp") & "," & _
hs.GetVar (device & "MinWatTemp") & "," & _
hs.GetVar (device & "MaxWatTemp") & "," & _
hs.GetVar (device & "Delta") & "," & _
hs.GetVar (device & "Clim") & "," & _
hs.GetVar (device & "BtnSup") & VbCrLf
End If
Set f = fs.CreateTextFile (hs.GetAppPath & "\config\VThermostat.ini", true)
f.Write (ThermoData)
f.Close
Set f = Nothing
Set fs = Nothing
End Function
' =================================================================================================
' Remise à zero des paramètres du thermostat
' =================================================================================================
Function ResetThermo (device)
device = Trim (device)
' Effacement des boutons
hs.GetDeviceByRef (hs.GetDeviceRef (device)).buttons = ""
' Création du bouton Reset
hs.DeviceButtonAdd device, "VThermostat.thm (""ResetThermo"", " & device & ")", "Reset"
' Effacement des variables
hs.DeleteVar (device & "Affichage")
hs.DeleteVar (device & "Mode")
hs.DeleteVar (device & "SetPoint")
hs.DeleteVar (device & "CoolSetPoint")
hs.DeleteVar (device & "OffSetPoint")
hs.DeleteVar (device & "AuxSetPoint")
hs.DeleteVar (device & "WaterSetPoint")
hs.DeleteVar (device & "Devices")
hs.DeleteVar (device & "IntSensor")
hs.DeleteVar (device & "IntFactor")
hs.DeleteVar (device & "ExtSensor")
hs.DeleteVar (device & "ExtFactor")
hs.DeleteVar (device & "WatSensor")
hs.DeleteVar (device & "WatFactor")
hs.DeleteVar (device & "RegTemp")
hs.DeleteVar (device & "RegWatTemp")
hs.DeleteVar (device & "MinWatTemp")
hs.DeleteVar (device & "MaxWatTemp")
hs.DeleteVar (device & "Delta")
hs.DeleteVar (device & "Clim")
hs.DeleteVar (device & "BtnSup")
' Création des variables
hs.CreateVar (device & "Affichage")
hs.CreateVar (device & "Mode")
hs.CreateVar (device & "SetPoint")
hs.CreateVar (device & "CoolSetPoint")
hs.CreateVar (device & "OffSetPoint")
hs.CreateVar (device & "AuxSetPoint")
hs.CreateVar (device & "WaterSetPoint")
hs.CreateVar (device & "Devices")
hs.CreateVar (device & "IntSensor")
hs.CreateVar (device & "IntFactor")
hs.CreateVar (device & "ExtSensor")
hs.CreateVar (device & "ExtFactor")
hs.CreateVar (device & "WatSensor")
hs.CreateVar (device & "WatFactor")
hs.CreateVar (device & "RegTemp")
hs.CreateVar (device & "RegWatTemp")
hs.CreateVar (device & "MinWatTemp")
hs.CreateVar (device & "MaxWatTemp")
hs.CreateVar (device & "Delta")
hs.CreateVar (device & "Clim")
hs.CreateVar (device & "BtnSup")
' Attribution des valeurs
IniThermo (device)
' Création du bouton suplémentaires
BtnSup = hs.GetVar (device & "BtnSup")
If BtnSup = "1" or BtnSup = "2" Then
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointP1"", " & device & ")", "<br>H+1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointM1"", " & device & ")", "H-1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointP01"", " & device & ")", "H+0.1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointM01"", " & device & ")", "H-0.1"
End If
If BtnSup ="1" or BtnSup = "3" Then
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointP1"", " & device & ")", "<br>C+1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointM1"", " & device & ")", "C-1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointP01"", " & device & ")", "C+0.1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointM01"", " & device & ")", "C-0.1"
ElseIf BtnSup = "4" Then
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointP1"", " & device & ")", "<br>H+1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointM1"", " & device & ")", "H-1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointP1"", " & device & ")", "C+1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointM1"", " & device & ")", "C-1"
ElseIf BtnSup = "5" Then
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointP01"", " & device & ")", "<br>H+0.1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetSetPointM01"", " & device & ")", "H-0.1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointP01"", " & device & ")", "C+0.1"
hs.DeviceButtonAdd device, "VThermostat.thm (""SetCoolSetPointM01"", " & device & ")", "C-0.1"
End If
hs.WriteLog "Thermostat virtuel", "Vous avez initilalisé le thermostat de code " & device
GetTemp (device)
End Function
Function IniThermo (device)
device = Trim (device)
IniExists = false
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists (hs.GetAppPath & "\config\VThermostat.ini") Then
Set f = fs.OpenTextFile (hs.GetAppPath & "\config\VThermostat.ini")
Do While Not f.AtEndOfStream
ThermoData = f.ReadLine
If hs.StringItem (ThermoData,1,",") = device Then
IniExists = true
Exit Do
End If
Loop
f.close
Set f = Nothing
End If
Set fs = Nothing
If IniExists Then
Ini2 = hs.StringItem (ThermoData,2,",")
Ini3 = hs.StringItem (ThermoData,3,",")
Ini4 = hs.StringItem (ThermoData,4,",")
Ini5 = hs.StringItem (ThermoData,5,",")
Ini6 = hs.StringItem (ThermoData,6,",")
Ini7 = hs.StringItem (ThermoData,7,",")
Ini8 = hs.StringItem (ThermoData,8,",")
Ini9 = hs.StringItem (ThermoData,9,",")
Ini10 = hs.StringItem (ThermoData,10,",")
Ini11 = hs.StringItem (ThermoData,11,",")
Ini12 = hs.StringItem (ThermoData,12,",")
Ini13 = hs.StringItem (ThermoData,13,",")
Ini14 = hs.StringItem (ThermoData,14,",")
Ini15 = hs.StringItem (ThermoData,15,",")
Ini16 = hs.StringItem (ThermoData,16,",")
Ini17 = hs.StringItem (ThermoData,17,",")
Ini18 = hs.StringItem (ThermoData,18,",")
Ini19 = hs.StringItem (ThermoData,19,",")
Ini20 = hs.StringItem (ThermoData,20,",")
Ini21 = hs.StringItem (ThermoData,21,",")
Else
Ini2 = "1"
Ini3 = "30"
Ini4 = "20"
Ini5 = "16"
Ini6 = "8"
Ini7 = "1"
End If
hs.SaveVar device & "Affichage", InputBox ("Entrez le type d'affichage du status du thermostat:" & Chr(13) & Chr(13)_
& "1 simple" & Chr(13)_
& "2 détaillé" & Chr(13)_
& "3 complet" & Chr(13)_
, "Thermostat virtuel Setup", Ini2)
hs.SaveVar device & "Mode", Ini3
hs.SaveVar device & "SetPoint", Ini4
hs.SaveVar device & "CoolSetPoint", Ini5
hs.SaveVar device & "OffSetPoint", InputBox ("Entrez le seuil en mode Hors-gel:" & Chr(13), "Thermostat virtuel Setup", Ini6)
hs.SaveVar device & "AuxSetPoint", InputBox ("Entrez l'abaissement du mode Aux:" & Chr(13)_
& "En mode Aux, le thermostat fonctionne comme en mode Auto mais avec un seuil abaissé de cette valeur." & Chr(13) & Chr(13)_
& "Ce mode est fait pour les courtes abscences, une fois de retour il suffit de repasser sur Auto." & Chr(13)_
, "Thermostat virtuel Setup", Ini7)
hs.SaveVar device & "Devices", InputBox ("Entrez le(s) module(s) de chauffage Ă controller:" & Chr(13)_
& "exemple: A1" & Chr(13) & Chr(13)_
& "Pour plusieurs modules, séparez-les par '-'." & Chr(13)_
& "exemple: A1-B2-C3" & Chr(13) & Chr(13)_
& "Pour plusieurs modules d'un même code maison, séparez-les par '+' pour une mise en marche synchronisée." & Chr(13)_
& "exemple: A1+2+3" & Chr(13) & Chr(13)_
& "Vous pouvez combiner les deux." & Chr(13)_
& "exemple: A1+2+3-B2-C3" & Chr(13)_
, "Thermostat virtuel Setup", Ini8)
If MsgBox ("Voulez-vous utiliser ce thermostat en mode clim?" & Chr(13) & Chr(13)_
& "En mode clim le thermostat fonctionnera de la même façon sauf que la mise en marche/arrêt de vos appareils sera inversée." & Chr(13)_
, vbYesNo + vbQuestion, "Thermostat virtuel Setup") = vbYes Then
hs.SaveVar device & "Clim", "1"
End If
hs.SaveVar device & "BtnSup", InputBox ("Voulez-vous des boutons suplémentaires?:" & Chr(13) & Chr(13)_
& "Cette valeur est optionelle, laissez vide pour ne pas l'utiliser." & Chr(13)_
& "Ces boutons permettent de faire varier les consignes au degrès ou/et au dixième par l'interface." & Chr(13)_
& "1 Tous les boutons" & Chr(13)_
& "2 Tous ceux du mode Confort" & Chr(13)_
& "3 Tous ceux du mode Eco" & Chr(13)_
& "4 Ceux du mode Confort et Eco mais au degrès" & Chr(13)_
& "5 Ceux du mode Confort et Eco mais au dixième" & Chr(13)_
, "Thermostat virtuel Setup", Ini21)
MsgBox "Vous allez maintenant indiquer quelles sondes vous allez utiliser." & Chr(13) & Chr(13)_
& "En fonction de la combinaison intérieure/extérieure/eau le thermostat va fonctionner suivant un mode différent." & Chr(13) & Chr(13)_
& "int + ext + eau : Loi d'eau avec auto-correction" & Chr(13)_
& "ext + eau : Loi d'eau sans auto-correction" & Chr(13)_
& "int : Fonctionnement normal" & Chr(13)_
& "int + eau : Fonctionnement normal avec limites de températures d'eau" & Chr(13)_
, 64, "Thermostat virtuel Setup"
hs.SaveVar device & "IntSensor", InputBox ("Entrez le code de votre sonde intérieure:" & Chr(13)_
& "exemple: w1" & Chr(13) & Chr(13)_
& "Pour plusieurs sondes, séparez-les par '+'." & Chr(13)_
& "exemple: w1+w2+w3" & Chr(13) & Chr(13)_
& "Pour utilser une moyenne pondérée, repetez chaque sonde un nombre de fois egal à sa pondération." & Chr(13)_
& "exemple: w1+w1+w1+w2+w3+w3" & Chr(13) & Chr(13)_
& "Si vous n'utilisez pas de sonde intérieure, laissez vide." & Chr(13)_
, "Thermostat virtuel Setup", Ini9)
If hs.GetVar (device & "IntSensor") <> "" Then
hs.SaveVar device & "IntFactor", InputBox ("Entrez le muliplicateur appliqué à la valeur des sondes Int:" & Chr(13) & Chr(13)_
& "1 si la sonde affiche 20 et sa valeur est 20" & Chr(13)_
& "10 si la sonde affiche 20,2 et sa valeur est 202" & Chr(13)_
& "etc." & Chr(13) & Chr(13)_
& "Souvent 10 pour les stations météo, 10000 pour du 1-Wire" & Chr(13) & Chr(13)_
& "Entrez 0 si vous utilisez la chaine de caractères et non la valeur." & Chr(13)_
& "Dans ce cas la chaine ne doit pas contenir de caractères spéciaux autres que °CT" & Chr(13)_
, "Thermostat virtuel Setup", Ini10)
End If
hs.SaveVar device & "ExtSensor", InputBox ("Entrez le code de votre sonde extérieure:" & Chr(13)_
& "exemple: w1" & Chr(13) & Chr(13)_
& "Pour plusieurs sondes, séparez-les par '+'." & Chr(13)_
& "exemple: w1+w2+w3" & Chr(13) & Chr(13)_
& "Pour utilser une moyenne pondérée, repetez chaque sonde un nombre de fois egal à sa pondération." & Chr(13)_
& "exemple: w1+w1+w1+w2+w3+w3" & Chr(13) & Chr(13)_
& "Si vous n'utilisez pas de sonde intérieure, laissez vide." & Chr(13)_
, "Thermostat virtuel Setup", Ini11)
If hs.GetVar (device & "ExtSensor") <> "" Then
hs.SaveVar device & "ExtFactor", InputBox ("Entrez le muliplicateur appliqué à la valeur des sondes Ext:" & Chr(13) & Chr(13)_
& "1 si la sonde affiche 20 et sa valeur est 20" & Chr(13)_
& "10 si la sonde affiche 20,2 et sa valeur est 202" & Chr(13)_
& "etc." & Chr(13) & Chr(13)_
& "Souvent 10 pour les stations météo, 10000 pour du 1-Wire" & Chr(13) & Chr(13)_
& "Entrez 0 si vous utilisez la chaine de caractères et non la valeur." & Chr(13)_
& "Dans ce cas la chaine ne doit pas contenir de caractères spéciaux autres que °CT" & Chr(13)_
, "Thermostat virtuel Setup", Ini12)
End If
hs.SaveVar device & "WatSensor", InputBox ("Entrez le code de votre sonde d'eau:" & Chr(13)_
& "exemple: w1" & Chr(13) & Chr(13)_
& "Pour plusieurs sondes, séparez-les par '+'." & Chr(13)_
& "exemple: w1+w2+w3" & Chr(13) & Chr(13)_
& "Pour utilser une moyenne pondérée, repetez chaque sonde un nombre de fois egal à sa pondération." & Chr(13)_
& "exemple: w1+w1+w1+w2+w3+w3" & Chr(13) & Chr(13)_
& "Si vous n'utilisez pas de sonde intérieure, laissez vide." & Chr(13)_
, "Thermostat virtuel Setup", Ini13)
If hs.GetVar (device & "WatSensor") <> "" Then
hs.SaveVar device & "WatFactor", InputBox ("Entrez le muliplicateur appliqué à la valeur des sondes d'eau:" & Chr(13) & Chr(13)_
& "1 si la sonde affiche 20 et sa valeur est 20" & Chr(13)_
& "10 si la sonde affiche 20,2 et sa valeur est 202" & Chr(13)_
& "etc." & Chr(13) & Chr(13)_
& "Souvent 10 pour les stations météo, 10000 pour du 1-Wire" & Chr(13) & Chr(13)_
& "Entrez 0 si vous utilisez la chaine de caractères et non la valeur." & Chr(13)_
& "Dans ce cas la chaine ne doit pas contenir de caractères spéciaux autres que °CT" & Chr(13)_
, "Thermostat virtuel Setup", Ini14)
End If
If hs.GetVar (device & "ExtSensor") <> "" and hs.GetVar (device & "WatSensor") <> "" Then
hs.SaveVar device & "RegTemp", InputBox ("Entrez votre température minimale régionale:" & Chr(13), "Thermostat virtuel Setup", Ini15)
hs.SaveVar device & "RegWatTemp", InputBox ("Entrez votre température d'eau minimale régionale:" & Chr(13) & Chr(13)_
& "C'est la température d'eau qu'il faut pour maintenir 20° à l'intérieur avec une température extérieure égale à la température minimale régionale." & Chr(13) & Chr(13)_
& "Si votre système est bien dimensioné elle devrait être proche du maximum, de l'ordre de 45° pour un plancher chauffant et 70° pour des radiateurs." & Chr(13) & Chr(13)_
& "Si vous utilisez des températures de retour d'eau pensez à abaisser cette valeur en fonction des pertes de températures." & Chr(13)_
, "Thermostat virtuel Setup", Ini16)
hs.SaveVar device & "Delta", InputBox ("Entrez le delta:" & Chr(13) & Chr(13)_
& "Cette valeur est optionelle, laissez vide pour ne pas l'utiliser." & Chr(13)_
& "Sinon entrez une valeur de 0 Ă 100." & Chr(13) & Chr(13)_
& "Plus ce chiffre est haut et moins votre chaudière ou pac sera solicitée mais vous augmentez l'hysteresis, doù une perte de confort." & Chr(13)_
& "Cette valeur baisse le seuil de mise en marche et augmente le seuil d'arrêt pour espacer les déclanchements dans le temps." & Chr(13)_
, "Thermostat virtuel Setup", Ini19)
Else
hs.SaveVar device & "Delta", InputBox ("Entrez le delta:" & Chr(13) & Chr(13)_
& "Cette valeur est optionelle, laissez vide pour ne pas l'utiliser." & Chr(13)_
& "Sinon entrez une valeur de 1 pour chaque dixième de degrès." & Chr(13) & Chr(13)_
& "Plus ce chiffre est haut et moins vos appareils seront solicités mais vous augmentez l'hysteresis, doù une perte de confort." & Chr(13)_
& "Cette valeur est ajoutée/retirée au seuil de mise en arrêt/marche pour espacer les déclanchements dans le temps." & Chr(13)_
, "Thermostat virtuel Setup", Ini19)
End If
If hs.GetVar (device & "WatSensor") <> "" Then
hs.SaveVar device & "MinWatTemp", InputBox ("Entrez votre température minimale du circuit d'eau:" & Chr(13)_
& "Cette valeur est optionelle, laissez vide pour ne pas l'utiliser." & Chr(13)_
& "Peut être utile par exemple pour une chaudière ou ballon tampon pour maintenir l'eau au dessus d'une certaine température." & Chr(13)_
, "Thermostat virtuel Setup", Ini17)
hs.SaveVar device & "MaxWatTemp", InputBox ("Entrez votre température maximale du circuit d'eau:" & Chr(13)_
& "Cette valeur est optionelle, laissez vide pour ne pas l'utiliser." & Chr(13)_
& "Peut être utile par exemple pour un plancher chauffant pour ne pas dépasser la température de condensation." & Chr(13)_
, "Thermostat virtuel Setup", Ini18)
End If
SaveThermo (device)
End Function
Function Min(a,b)
if a<b Then Min=a Else Min=b
End Function
Function Max(a,b)
if a<b Then Max=b else Max=a
End function
Surtout la partie "Mise Ă jour du Thermostat"
J'ai créer des devices supplementaires pour chaque fonction à visualiser dans les thermostats sous HSTOUCH (puisque celui-ci ne voit pas le thermostat virtuel)
J'ai créer un event pour chaque fonction , et un script pour la fonction AUX
Je suis partie sur la base RCS Thermostat.xml du skin par default.
J'ai mis le status des differents mode sur le thermostat
J'ai dupliqué le bouton MODE et appliqué un event pour chaque bouton.
J'ai rajouté un petit voyant pour le device commandé par le thermostat
La mise Ă jour du mode est immediate

Jean-Francois.