From ff5cd1ed660745fb51950bfec688d0c6d7b45941 Mon Sep 17 00:00:00 2001 From: Sylvain PERON <48243214+SylvainPer@users.noreply.github.com> Date: Fri, 30 Dec 2022 21:36:31 +0100 Subject: [PATCH] Update counter update index need to be in Wh like conso to fix "comparing usage" graph --- gazpar.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gazpar.py b/gazpar.py index c832588..62f6f48 100755 --- a/gazpar.py +++ b/gazpar.py @@ -142,7 +142,7 @@ def update_counters(session, start_date, end_date): j = json.loads(data) #print (j) - index = j[str(numPce)]['releves'][0]['indexDebut'] + index = j[str(numPce)]['releves'][0]['indexDebut']*1000 #print(index) for releve in j[str(numPce)]['releves']: @@ -156,7 +156,8 @@ def update_counters(session, start_date, end_date): try : #volume = round(int(conso)/int(coeffConversion),2) - index = index + conso + conso *= 1000 + index += conso except TypeError: print(req_date, conso, index, "Invalid Entry") continue; @@ -165,16 +166,16 @@ def update_counters(session, start_date, end_date): #print(req_date, conso, index) if devicerowid: - logging.debug("Data to inject : " + req_date + ";" + devicerowid + ";" + str(int(conso)*1000) + ";" + str(index)) + logging.debug("Data to inject : " + req_date + ";" + devicerowid + ";" + str(conso) + ";" + str(index)) # Generate URLs, for historique and for update - args = {'type': 'command', 'param': 'udevice', 'idx': devicerowid, 'svalue': str(index) + ";" + str(int(conso)*1000) + ";" + req_date} + args = {'type': 'command', 'param': 'udevice', 'idx': devicerowid, 'svalue': str(index) + ";" + str(conso) + ";" + req_date} url_historique = '/json.htm?' + urlencode(args) - args['svalue'] = str(index) + ";" + str(int(conso)*1000) + ";" + date_time + args['svalue'] = str(index) + ";" + str(conso) + ";" + date_time url_daily = '/json.htm?' + urlencode(args) - args['svalue'] = str(int(conso)*1000) + args['svalue'] = str(conso) url_current = '/json.htm?' + urlencode(args) domoticzrequest(url_historique)