Il y a très longtemps dans ce même sujet j'avais dis que je trouverai, ou étaient stockées les informations de consommation de ma chaudière. Je n'avais pas trouvé dans un premier temps, et ensuite je n'avais plus eu le temps.
Mais grace notamment à l'information de @thetrueavatar, sur l'api viessmann, j'ai réussi a trouver les adresses des consommations.
Alors je vais toutefois ménager les ardeurs de certains, mais cela ne fonctionne (n'a été tester) que avec une regulation de type HO2B (écran tactile couleur)
Les adresses sont:
- A partir de 9000 pour la consommation de gaz pour le chauffage, d'une longueur de 4.
- A partir de 9134 pour la consommation de gaz pour l'eau chaude, d'une longueur de 4.
- A partir de 9268 pour la consommation électrique de la chaudière, d'une longueur de 4.
J'ai noté à partir de car les datas sont repartie comme ceci :
- 1 groupe de 8 glissant pour les données journalières
- 1 groupe de 52 glissant pour les données hebdomadaires
- 1 groupe de 12 glissant pour les données mensuelles
- 1 grouped 3 glissant pour les données annuelles
Et cela est valable pour les 3 types de consommation ci dessus.
J'ai donc modifier le vitalk standard afin de pouvoir extraire ce type de données (elles sont stockées en litle indian), et je lui rajouté une commande gcons qui permet de récupérer une consommation, il faut l'utiliser de la façon suivante:
gcons <adresse>
J'ai aussi adapté vitalk afin de refléter mieux mon installation (2 circuits) d'ou l'apparition de nouvelles commandes du genre mode2....
Voici un lien pour télécharger ma version modifiée de vitalk : https://www.dropbox.com/s/72ncim8ir6dne ... k.tgz?dl=0
Et voici ma version modifiée du domo2vito de @js-martin afin de refléter tout ça, j'ai aussi ajouter le fait de pouvoir changer les différentes températures de consigne (avec une detection de la provenance du changement de consigne afin de ne pas écraser un changement venant de la régule par example).
Afin de faire marcher cette version, il vous faudra créer 8 variables utilisateurs dans Domoticz. Le reste est similaire à celui de @js-martin sauf qu'il faut doubler les différents set point, les consignes de mode.
Donc voici ma version de domo2vito
Code : Tout sélectionner
#!/usr/bin/python
# domo2vito
# Based on JS MARTIN V2.11
# Mod by Nonolk
# version 3.0 - 26112017
# This version handle 2 heating circuit and get consumption from the boiler (with HO2B Touch only) you need a special vitalk version for This.
# This version can also change the temperature for ECS and Heating. It try to determine from where come the last temparature change, to avoid conflicts.
import telnetlib
import sys
import os
import time
import requests
from requests.auth import HTTPBasicAuth
import json
############# Parameters #################################
#~~~~~~~~~~ Parameters Domoticz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
domoticz_ip=''
domoticz_port='8080'
user=''
password=''
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Commands viTalk
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#autorized commands
commands = ["mode", "mode2","eco_mode","party_mode","norm_room_temp2","outdoor_temp","norm_room_temp","indoor_temp","boiler_temp","hot_water_set","hot_water_temp","boiler_gaz_temp","power","errors","runtime","red_room_temp","red_room_temp2","eco_mode2","party_mode2"]
#write only commands
write_only_commands = ["mode","saving","party","party_soll_temp","ww_soll_temp","red_raum_soll_temp","raum_soll_temp"]
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# IDX de Domoticz
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# remplacer XXX par votre idx de votre widget
dummy_idx={'mode':104, 'mode2':105, 'saving': 109, 'party':108, 'norm_room_temp2':116, 'outdoor_temp':112, 'raum_soll_temp':115, 'ww_soll_temp':117, 'ww_ist_temp':113, 'k_abgas_temp':114, 'power':120, 'error_log':125, 'problem':111, 'delta-rt':123, 'gas':126, 'red_raum_soll_temp':118, 'red_2_temp':119, 'saving2': 106, 'party2':107, 'gaz_ww':494, 'gaz_heating':493, 'elec':487}
user_idx={'runtime-boiler':1, 'pl_red':2, 'pl_norm':3, 'rad_norm':4, 'rad_red':5, 'ecs':6, 'g_heat':7, 'g_ww':8} # please create a user variable [integer] (overall boiler time) - see https://www.domoticz.com/wiki/User_variables
conso_addr={'cons_heating':9000, 'cons_ww':9134, 'cons_elec':9268}
# 0 mode : dummy selector switch OFF/Water/Heating (Boiler [FR:chaudiere] stand-by/water only/water+heating) {read/write}
# 1 saving : dummy switch ON/OFF (Boiler eco ON/OFF) {read/write}
# 2 party : dummy switch ON/OFF (party temporary manual control) - note : party ON does not work (vitalk bug ?) {read/write}
# 3 party_soll_temp : dummy thermostat setpoint (party temperature) {write only}
# 4 outdoor_temp : dummy temp (outdoor temperature) {read only}
# 5 raum_soll_temp : dummy temp (heating [FR:consigne] temperature ) {read only} - note : without vitotronic, you could use thermostat setpoint
# 6 raum_ist_temp : dummy temp (heating current [FR:actuelle] temperature) {read only}
# 7 k_ist_temp : dummy temp (boiler current temperature) {read only}
# 8 ww_soll_temp : dummy thermostat setpoint (hot water setpoint temperature) {write only}
# 9 ww_ist_temp : dummy temp (hot water current temperature) {read only}
#10 k_abgas_temp : dummy temp (exhaust gas [FR:gaz evacue'] temperature) {read only}
#11 power : dummy percentage (% boiler power) {read only}
#12 error_log : dummy alert (show the two last log codes) {read only}
# problem : dummy switch (set switch to On if there is a internal boiler problem)
#13 runtime : custom sensor [seconds] (Operating time of boiler since last script call) {read only}
# gas : dummy incremental counter [gas] (Estimation of Gas consumtion)
#14 red_raum_soll_temp: dummy thermostat setpoint (reduced temperature) {write only}
# holiday_temp : dummy thermostat setpoint (holiday temperature)
# raum_soll_temp_W : dummy thermostat setpoint (normal temperature) {write only} - note : does not work with vitotrol 300
# |_ for raum_soll_temp_W, you need to put the bolean Use_normal_temperature_setpoint to True
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Mode debug
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# if debug = True => verbose
debug=True
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Variable
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Debit max gas (need to be adjust to synchronize estimated and real gas consumption)
Deb=0.1099 #0.12 = trop fort 1400 l / 0.09 = trop faible 390 l - 1min
# 0.136 - 3min
# Activated normal temperature setpoint
Use_normal_temperature_setpoint=False
#######################################################################
###### viTalk_connect() : connect to viTalk localhost:83
#######################################################################
def viTalk_connect():
global debug
retry=3
while retry!=0:
try:
tn = telnetlib.Telnet("localhost", 3083)
if debug:
print "Connected to viTalk telnet !"
return tn
except:
print "Connection ERROR - I try to restart viTalk deamon"
#I try to restart viTalk
cmd = 'sudo service vitalk restart'
os.system(cmd)
time.sleep(10)
retry-=1
else:
tn.read_until(b"$", 5)
if retry==0:
tn.close()
print "Connection ERROR - I could not restart viTalk deamon"
sys.exit()
######
#######################################################################
###### viTalk_read(cmd) : read a value
#######################################################################
def viTalk_read(cmd):
global debug
global tn
retry=3
value=""
while retry!=0:
tn.read_until(b"$", 5)
tn.write(b"g "+cmd+"\n")
value=tn.read_until(b"$", 5).strip("\n$")
if value!="" and value!='NULL':
break
retry-=1
if retry==0:
print "Connection ERROR - I try to restart viTalk deamon"
os.system('sudo service vitalk restart')
#tn.close()
print(cmd+": "+value+" error")
sys.exit()
value = value.strip("\n$")
if debug:
print "get "+cmd+" : answer = "+value
return value
######
#######################################################################
###### viTalk_conso_read(cmd) : read a value
#######################################################################
def viTalk_conso_read(addr):
global debug
global tn
retry=3
value=""
while retry!=0:
tn.read_until(b"$", 5)
tn.write(b"gcons "+addr+"\n")
value=tn.read_until(b"$", 5).strip("\n$")
if value!="" and value!='NULL':
break
retry-=1
if retry==0:
print "Connection ERROR - I try to restart viTalk deamon"
os.system('sudo service vitalk restart')
#tn.close()
print(cmd+": "+value+" error")
sys.exit()
value = value.strip("\n$")
if debug:
# with open("/tmp/vito_debug.txt", "a") as myfile:
# myfile.write("Value:"+str(value)+"\n")
print "get "+addr+" : answer = "+value
return value
######
#######################################################################
###### viTalk_check() : test viTalk and restart it if needed
#######################################################################
def viTalk_check():
global debug
global tn
retry=3
value=""
while retry!=0:
tn.read_until(b"$", 5)
tn.write(b"g saving \n")
value=tn.read_until(b"$", 5).strip("\n$")
if value!="" and value!='NULL':
if debug:
print "Check viTalk data OK ! (no NULL data received)"
break
retry-=1
if retry==0:
print "Connection ERROR - I try to restart viTalk deamon"
os.system('sudo service vitalk restart')
sys.exit()
######
#######################################################################
###### viTalk_set(cmd,val) : unsecured write
#######################################################################
def viTalk_set(cmd,val):
global debug
global tn
tn.write(b"s "+cmd+" "+val+"\n")
tn.read_until(b"$", 5).strip("\n$")
if debug: print("set "+cmd+" "+val)
######
#######################################################################
###### viTalk_write(cmd,val) : secured write (I check if value is
###### really updated)
#######################################################################
def viTalk_write(cmd,val):
global debug
global tn
retry=3
value=""
while retry!=0:
viTalk_set(cmd,val)
tn.read_until(b"$", 5)
time.sleep(1)
value=viTalk_read(cmd)
if val==value:
break
retry-=1
if retry==0:
tn.close()
print(cmd+" "+val+" : error")
sys.exit()
if debug:
print "check last command set "+cmd+" "+val+" : OK"
#########
#######################################################################
###### check_command(cmd) : is it an authorized command ?
#######################################################################
def check_command(cmd):
global commands
global debug
try:
#check position of cmd in commands list
commands.index(cmd)
except:
print "command not found"
return False
else:
if debug:
print "this command "+cmd+" is known"
return True
####
#######################################################################
###### check_set_command(cmd) : is it an authorized write command ?
#######################################################################
def check_set_command(cmd):
global commands
global debug
try:
#check position of cmd in write only commands list
write_only_commands.index(cmd)
except:
print "set command not found (I can't write with this command)"
return False
else:
if debug:
print "this command "+cmd+" is known for writing"
return True
####
#######################################################################
###### get_setpoint_temp(idx) : get temperature from domoticz setpoint
#######################################################################
def get_setpoint_temp(idx):
r = requests.get('http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=devices&rid='+str(idx),auth=HTTPBasicAuth(user,password))
status=r.status_code
if status == 200:
r=r.json()
result={}
return r['result'][0]['Data']
else:
print "Get setpoint temp error - IDX:"+str(idx)
####
########################################################################
###### get_state(idx) : get dummy state from domoticz
########################################################################
def get_state(idx):
r = requests.get('http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=devices&rid='+str(idx),auth=HTTPBasicAuth(user,password))
status=r.status_code
if status == 200:
r=r.json()
result={}
return r['result'][0]['Data']
else:
print "Get state error - IDX:"+str(idx)+" not found ?"
####
########################################################################
###### get_last_runtime(idx) : get last runtime value from domoticz
########################################################################
def get_last_runtime(idx):
r = requests.get('http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=getuservariable&idx='+str(idx),auth=HTTPBasicAuth(user,password))
status=r.status_code
if status == 200:
r=r.json()
result={}
return r['result'][0]['Value']
else:
print "Get state error - IDX:"+str(idx)
####
########################################################################
###### get_last_temp(idx) : get last temperature value from domoticz
########################################################################
def get_last_temp(idx):
r = requests.get('http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=getuservariable&idx='+str(idx),auth=HTTPBasicAuth(user,password))
status=r.status_code
if status == 200:
r=r.json()
result={}
return r['result'][0]['Value']
else:
print "Get state error - IDX:"+str(idx)
####
########################################################################
###### get_last_value(idx) : get last value from domoticz
########################################################################
def get_last_value(idx):
r = requests.get('http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=getuservariable&idx='+str(idx),auth=HTTPBasicAuth(user,password))
status=r.status_code
if status == 200:
r=r.json()
result={}
return r['result'][0]['Value']
else:
print "Get state error - IDX:"+str(idx)
####
#-----------------------------------### START ###--------------------------------------------#
# arguments in command line
nb_arg=len(sys.argv)-1
if nb_arg==1 and sys.argv[1]!="update":
if check_command(sys.argv[1]):
if debug:
print "get "+sys.argv[1]
tn=viTalk_connect()
viTalk_read(sys.argv[1])
tn.close()
if nb_arg==0:
tn=viTalk_connect()
viTalk_check()
values=[]
i=0
tn.read_until(b"$", 5)
for command in commands:
tn.write(b"g "+command+"\n")
value=tn.read_until(b"$", 5).strip("\n$")
if debug:
print str(i)+") command : get "+command+ " => "+value
values.append(value)
i+=1
if debug: print "+Now I check if I need to update some values into Viessmann boiler or into Domoticz..."
mcur=time.localtime().tm_min # to update setpoint one time every hour - get minute of current hour
if mcur>40 and mcur<46: # Heartbeat - update setpoint in Domoticz one time per hour just to avoid "lost widget status"
setpoint_heartbeat=True
else:
setpoint_heartbeat=False
conso_gaz_heat=int(viTalk_conso_read(str(conso_addr['cons_heating'])))
last_conso_heat=int(get_last_value(user_idx['g_heat']))
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=updateuservariable&idx='+str(user_idx['g_heat'])+'&vname=conso_heat&vtype=0&vvalue='+str(conso_gaz_heat)
requests.get(req,auth=HTTPBasicAuth(user,password))
if last_conso_heat <= conso_gaz_heat:
conso_gaz_heat=conso_gaz_heat - last_conso_heat
conso_gaz_heat=conso_gaz_heat*1000
elif last_conso_heat > conso_gaz_heat:
conso_gaz_heat=conso_gaz_heat*1000
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['gaz_heating'])+'&svalue='+str(conso_gaz_heat)
requests.get(req,auth=HTTPBasicAuth(user,password))
conso_gaz_ww=int(viTalk_conso_read(str(conso_addr['cons_ww'])))
last_conso_ww=int(get_last_value(user_idx['g_ww']))
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=updateuservariable&idx='+str(user_idx['g_ww'])+'&vname=conso_ww&vtype=0&vvalue='+str(conso_gaz_ww)
requests.get(req,auth=HTTPBasicAuth(user,password))
if last_conso_ww <= conso_gaz_ww:
conso_gaz_ww=conso_gaz_ww - last_conso_ww
conso_gaz_ww=conso_gaz_ww*1000
elif last_conso_ww > conso_gaz_ww:
conso_gaz_ww=conso_gaz_ww*1000
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['gaz_ww'])+'&svalue='+str(conso_gaz_ww)
requests.get(req,auth=HTTPBasicAuth(user,password))
tmp_elec=viTalk_conso_read(str(conso_addr['cons_elec']))
conso_elec=float(tmp_elec) /1000
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['elec'])+'&nvalue=0&svalue='+str(conso_elec)
requests.get(req,auth=HTTPBasicAuth(user,password))
# get setpoint ww_soll_temp and update boiler if needed
last_ww=int(get_last_temp(user_idx['ecs']))
if debug: print "9) Last hot water value : "+str(last_ww)
temp=int(float(get_setpoint_temp(dummy_idx['ww_soll_temp'])))
if (temp!=int(float(values[9])) and (last_ww == int(float(values[9])))): #Viessmann ignore decimales
if temp<20: temp=20 # hot water mini temp
if temp>70: temp=70 # hot water maxi temp
if debug: print "9) hot water setpoint has changed : I update Viessmann boiler with hot water temperature = "+str(temp)
viTalk_set("hot_water_set",str(temp))
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=updateuservariable&idx='+str(user_idx['ecs'])+'&vname=ecs&vtype=0&vvalue='+str(temp)
requests.get(req,auth=HTTPBasicAuth(user,password))
else:
if (last_ww != int(float(values[9]))):
if debug: print "9) hot water changed on boiler or changed on both"+values[9]
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['ww_soll_temp'])+'&nvalue=0&svalue='+values[9]
requests.get(req,auth=HTTPBasicAuth(user,password))
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=updateuservariable&idx='+str(user_idx['ecs'])+'&vname=ecs&vtype=0&vvalue='+values[9]
requests.get(req,auth=HTTPBasicAuth(user,password))
if setpoint_heartbeat:
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['ww_soll_temp'])+'&nvalue=0&svalue='+str(temp)
requests.get(req,auth=HTTPBasicAuth(user,password))
last_rad_norm=int(get_last_temp(user_idx['rad_norm']))
if debug: print "6) Last norm rad value : "+str(last_rad_norm)
temp=int(float(get_setpoint_temp(dummy_idx['raum_soll_temp'])))
if (temp!=int(float(values[6])) and (last_rad_norm == int(float(values[6])))): #Viessmann ignore decimales
if temp<10: temp=10 # reduced mini temp
if temp>30: temp=30 # reduced maxi temp
if debug: print "6) Normal temp setpoint has changed : I update Viessmann boiler with normal temperature = "+str(temp)
viTalk_set("norm_room_temp",str(temp))
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=updateuservariable&idx='+str(user_idx['rad_norm'])+'&vname=rad_norm&vtype=0&vvalue='+str(temp)
requests.get(req,auth=HTTPBasicAuth(user,password))
else:
if (last_rad_norm != int(float(values[6]))):
if debug: print "6) hot water changed on boiler or changed on both"+values[6]
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['raum_soll_temp'])+'&nvalue=0&svalue='+values[6]
requests.get(req,auth=HTTPBasicAuth(user,password))
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=updateuservariable&idx='+str(user_idx['rad_norm'])+'&vname=rad_norm&vtype=0&vvalue='+values[6]
requests.get(req,auth=HTTPBasicAuth(user,password))
if setpoint_heartbeat:
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['raum_soll_temp'])+'&nvalue=0&svalue='+str(temp)
requests.get(req,auth=HTTPBasicAuth(user,password))
last_pl_norm=int(get_last_temp(user_idx['pl_norm']))
if debug: print "4) PL Last norm value : "+str(last_pl_norm)
temp=int(float(get_setpoint_temp(dummy_idx['norm_room_temp2'])))
if (temp!=int(float(values[4])) and (last_pl_norm == int(float(values[4])))): #Viessmann ignore decimales
if temp<10: temp=10 # reduced mini temp
if temp>30: temp=30 # reduced maxi temp
if debug: print "4) Normal temp setpoint has changed : I update Viessmann boiler with normal temperature = "+str(temp)
viTalk_set("norm_room_temp2",str(temp))
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=updateuservariable&idx='+str(user_idx['pl_norm'])+'&vname=pl_norm&vtype=0&vvalue='+str(temp)
requests.get(req,auth=HTTPBasicAuth(user,password))
else:
if (last_pl_norm != int(float(values[4]))):
if debug: print "4) hot water changed on boiler or changed on both"+values[4]
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['norm_room_temp2'])+'&nvalue=0&svalue='+values[4]
requests.get(req,auth=HTTPBasicAuth(user,password))
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=updateuservariable&idx='+str(user_idx['pl_norm'])+'&vname=pl_norm&vtype=0&vvalue='+values[4]
requests.get(req,auth=HTTPBasicAuth(user,password))
if setpoint_heartbeat:
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['norm_room_temp2'])+'&nvalue=0&svalue='+str(temp)
requests.get(req,auth=HTTPBasicAuth(user,password))
last_pl_red=int(get_last_temp(user_idx['pl_red']))
if debug: print "16) PL Last red value : "+str(last_pl_red)
temp=int(float(get_setpoint_temp(dummy_idx['red_2_temp'])))
if (temp!=int(float(values[16])) and (last_pl_red == int(float(values[16])))): #Viessmann ignore decimales
if temp<10: temp=10 # reduced mini temp
if temp>30: temp=30 # reduced maxi temp
if debug: print "16) Normal temp setpoint has changed : I update Viessmann boiler with normal temperature = "+str(temp)
viTalk_set("red_room_temp2",str(temp))
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=updateuservariable&idx='+str(user_idx['pl_red'])+'&vname=pl_red&vtype=0&vvalue='+str(temp)
requests.get(req,auth=HTTPBasicAuth(user,password))
else:
if (last_pl_red != int(float(values[16]))):
if debug: print "16) hot water changed on boiler or changed on both"+values[16]
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['red_2_temp'])+'&nvalue=0&svalue='+values[16]
requests.get(req,auth=HTTPBasicAuth(user,password))
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=updateuservariable&idx='+str(user_idx['pl_red'])+'&vname=pl_red&vtype=0&vvalue='+values[16]
requests.get(req,auth=HTTPBasicAuth(user,password))
if setpoint_heartbeat:
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['red_2_temp'])+'&nvalue=0&svalue='+str(temp)
requests.get(req,auth=HTTPBasicAuth(user,password))
last_rad_red=int(get_last_temp(user_idx['rad_red']))
if debug: print "15) PL Last red value : "+str(last_rad_red)
temp=int(float(get_setpoint_temp(dummy_idx['red_raum_soll_temp'])))
if (temp!=int(float(values[15])) and (last_rad_red == int(float(values[15])))): #Viessmann ignore decimales
if temp<10: temp=10 # reduced mini temp
if temp>30: temp=30 # reduced maxi temp
if debug: print "15) Normal temp setpoint has changed : I update Viessmann boiler with normal temperature = "+str(temp)
viTalk_set("red_room_temp",str(temp))
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=updateuservariable&idx='+str(user_idx['rad_red'])+'&vname=rad_red&vtype=0&vvalue='+str(temp)
requests.get(req,auth=HTTPBasicAuth(user,password))
else:
if (last_rad_red != int(float(values[15]))):
if debug: print "15) hot water changed on boiler or changed on both"+values[15]
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['red_raum_soll_temp'])+'&nvalue=0&svalue='+values[15]
requests.get(req,auth=HTTPBasicAuth(user,password))
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=updateuservariable&idx='+str(user_idx['rad_red'])+'&vname=rad_red&vtype=0&vvalue='+values[15]
requests.get(req,auth=HTTPBasicAuth(user,password))
if setpoint_heartbeat:
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['red_raum_soll_temp'])+'&nvalue=0&svalue='+str(temp)
requests.get(req,auth=HTTPBasicAuth(user,password))
if setpoint_heartbeat:
temp=int(float(get_setpoint_temp(dummy_idx['red_raum_soll_temp'])))
if temp<10: temp=10 # reduced mini temp
if temp>30: temp=30 # reduced maxi temp
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['red_raum_soll_temp'])+'&nvalue=0&svalue='+str(temp)
requests.get(req,auth=HTTPBasicAuth(user,password))
if Use_normal_temperature_setpoint:
temp=int(float(get_setpoint_temp(dummy_idx['raum_soll_temp_W'])))
if temp<10: temp=10 # normal mini temp
if temp>30: temp=30 # normal maxi temp
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['raum_soll_temp_W'])+'&nvalue=0&svalue='+str(temp)
requests.get(req,auth=HTTPBasicAuth(user,password))
tn.close()
# mode (selector level : 0=OFF 10=water 20=heating 30=holidays 40=always On)
previous_value=get_state(dummy_idx['mode'])
if previous_value=="Off": previous_value="Set Level: 0 %"
if int(previous_value[11:-1])!=int(values[0])*10:
if debug: print "0) Value MODE has changed : I update domoticz with mode = "+values[0]
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=switchlight&idx='+str(dummy_idx['mode'])+'&switchcmd=Set%20Level&level='+str(int(values[0])*10)
requests.get(req,auth=HTTPBasicAuth(user,password))
# mode2 (selector level : 0=OFF 10=water 20=heating 30=holidays 40=always On)
previous_value=get_state(dummy_idx['mode2'])
if previous_value=="Off": previous_value="Set Level: 0 %"
if int(previous_value[11:-1])!=int(values[1])*10:
if debug: print "0) Value MODE2 has changed : I update domoticz with mode = "+values[1]
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=switchlight&idx='+str(dummy_idx['mode2'])+'&switchcmd=Set%20Level&level='+str(int(values[1])*10)
requests.get(req,auth=HTTPBasicAuth(user,password))
# saving : dummy switch ON/OFF (Boiler eco ON/OFF) : if a user modify boiler or vitotrol, update Domoticz
previous_value=get_state(dummy_idx['saving'])
if (previous_value=="On" and values[2]=="0") or (previous_value=="Off" and values[2]=="1"):
if debug: print "1) Value SAVING has changed : I update domoticz with saving = "+values[2]
if values[2]=="0":
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=switchlight&idx='+str(dummy_idx['saving'])+'&switchcmd=Off'
else:
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=switchlight&idx='+str(dummy_idx['saving'])+'&switchcmd=On'
requests.get(req,auth=HTTPBasicAuth(user,password))
# saving2 : dummy switch ON/OFF (Boiler eco ON/OFF) : if a user modify boiler or vitotrol, update Domoticz
previous_value=get_state(dummy_idx['saving2'])
if (previous_value=="On" and values[17]=="0") or (previous_value=="Off" and values[17]=="1"):
if debug: print "1) Value SAVING has changed : I update domoticz with saving = "+values[17]
if values[17]=="0":
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=switchlight&idx='+str(dummy_idx['saving2'])+'&switchcmd=Off'
else:
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=switchlight&idx='+str(dummy_idx['saving2'])+'&switchcmd=On'
requests.get(req,auth=HTTPBasicAuth(user,password))
# party : dummy switch ON/OFF (party temporary manual control) : if a user modify boiler or vitotrol, update Domoticz
previous_value=get_state(dummy_idx['party'])
if (previous_value=="On" and values[3]=="0") or (previous_value=="Off" and values[3]=="1"):
if debug: print "2) Value PARTY has changed : I update domoticz with party = "+values[3]
if values[3]=="0":
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=switchlight&idx='+str(dummy_idx['party'])+'&switchcmd=Off'
else:
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=switchlight&idx='+str(dummy_idx['party'])+'&switchcmd=On'
requests.get(req,auth=HTTPBasicAuth(user,password))
previous_value=get_state(dummy_idx['party2'])
if (previous_value=="On" and values[18]=="0") or (previous_value=="Off" and values[18]=="1"):
if debug: print "2) Value PARTY has changed : I update domoticz with party = "+values[18]
if values[18]=="0":
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=switchlight&idx='+str(dummy_idx['party2'])+'&switchcmd=Off'
else:
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=switchlight&idx='+str(dummy_idx['party2'])+'&switchcmd=On'
requests.get(req,auth=HTTPBasicAuth(user,password))
# outdoor_temp : dummy temp (outdoor temperature)
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['outdoor_temp'])+'&nvalue=0&svalue='+values[5]
requests.get(req,auth=HTTPBasicAuth(user,password))
# ww_ist_temp : dummy temp (hot water current temperature)
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['ww_ist_temp'])+'&nvalue=0&svalue='+values[10]
requests.get(req,auth=HTTPBasicAuth(user,password))
# power : dummy percentage (% boiler power)
previous_power_value=get_state(dummy_idx['power'])[:-1] # on supprime le % a la fin de la chaine
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['power'])+'&nvalue=0&svalue='+values[12]
requests.get(req,auth=HTTPBasicAuth(user,password))
# Get previous boiler runtime value from Domoticz database (user variable)
last_rt=int(get_last_runtime(user_idx['runtime-boiler']))
delta_rt=int(values[14])-last_rt # delta-runtime
# update boiler-runtime since last update
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['delta-rt'])+'&nvalue=0&svalue='+str(delta_rt)
requests.get(req,auth=HTTPBasicAuth(user,password))
# Set overall boiler runtime into Domoticz database (user variable)
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=updateuservariable&idx='+str(user_idx['runtime-boiler'])+'&vname=runtime-boiler&vtype=0&vvalue='+values[14]
requests.get(req,auth=HTTPBasicAuth(user,password))
# if debug: print "+Now I calculate the gas consumed since last script call:"
# gas : gas estimation
# power_average=(float(previous_power_value)+float(values[12]))/2
# gas_used=delta_rt*Deb*power_average/10000
# if debug:
# print " -Viessmann boiler runtime since last script call (sec) = "+str(delta_rt)
# print " -Viessmann boiler power average (%) = "+ str(power_average)
# print " -Estimated gas used (liter) = "+str(gas_used)
#req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['gas'])+'&nvalue=0&svalue='+str(gas_used)
#requests.get(req,auth=HTTPBasicAuth(user,password))
if debug: print "+Now I check boiler error..."
# error_log : dummy alert (show the two last log codes)
# problem : dummy switch (set switch to On if there is a internal boiler problem)
#values[12]="123,255,235,244,244,244,244,244,244,244 ;"
V_error=values[13][0:3]
V_previous_error=values[13][4:7]
V_error_hexa=str(hex(int(V_error)))[2:4] # hexa convertion
V_previous_error_hexa=str(hex(int(V_previous_error)))[2:4] # hexa convertion
V_previous_error_state=get_state(str(dummy_idx['error_log']))[0:2]
V_previous_problem_state=get_state(str(dummy_idx['problem']))
if V_error=="000":
if debug: print " -no internal error : all it is OK"+" (previous code="+V_previous_error_hexa+")"
if V_previous_error_state!="OK": # I update error_log alert only if state is modified
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['error_log'])+'&nvalue=1&svalue='+'OK (previous='+V_previous_error_hexa+')'
requests.get(req,auth=HTTPBasicAuth(user,password))
if V_previous_problem_state=="On": # I update problem switch only if state is modified
if debug: print " -state of boiler error status changed (no problem): I update the Domotics boiler problem switch"
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=switchlight&idx='+str(dummy_idx['problem'])+'&switchcmd=Off'
requests.get(req,auth=HTTPBasicAuth(user,password))
else:
if debug: print " -there is an internal error : code="+V_error_hexa+" ( previous ="+V_previous_error_hexa+")"
if V_previous_error_state!=V_error_hexa: # I update error_log alert only if state is modified
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=udevice&idx='+str(dummy_idx['error_log'])+'&nvalue=4&svalue='+V_error_hexa+' error (previous='+V_previous_error_hexa+')'
requests.get(req,auth=HTTPBasicAuth(user,password))
if V_previous_problem_state=="Off": # I update problem switch only if state is modified
if debug: print " -state of boiler error status changed (problem): I update the Domotics boiler problem switch"
req='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command¶m=switchlight&idx='+str(dummy_idx['problem'])+'&switchcmd=On'
requests.get(req,auth=HTTPBasicAuth(user,password))
if nb_arg==2:
if check_set_command(sys.argv[1]):
print "set "+sys.argv[1]+" "+sys.argv[2]
tn=viTalk_connect()
viTalk_write(sys.argv[1],sys.argv[2])
tn.close()
Bonne fin de week-end.
Edit : j ai oublié un détail, il faut aussi créer 3 compteurs pour les consommations
- 1 compteur incremental pour la consommation de gaz pour le chauffage
- 1 compteur incremental pour la consommation de gaz pour l eau chaude
- 1 compteur de type custom pour la consommation d électricité