Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update counter update #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions gazpar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Expand All @@ -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;
Expand All @@ -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)
Expand Down