Skip to content

Commit

Permalink
manage erreur lors du call contract
Browse files Browse the repository at this point in the history
meilleure gestion des reprises sur erreur
  • Loading branch information
saniho committed Jun 2, 2021
1 parent dd3b54b commit d4db63f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion custom_components/apiEnedis/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
""" Constants """

__VERSION__ = "1.2.0.3" # attention updater aussi manifest.json
__VERSION__ = "1.2.0.4rc1" # attention updater aussi manifest.json
__name__ = "myEnedis"

try:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/apiEnedis/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "myEnedis sensor",
"documentation": "https://github.com/saniho/apiEnedis/",
"config_flow": true,
"version": "1.2.0.3",
"version": "1.2.0.4rc1",
"requirements": [
],
"dependencies": [],
Expand Down
20 changes: 11 additions & 9 deletions custom_components/apiEnedis/myCheckData.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ def analyseValueAndAdd(self, data):
raise Exception('call', None)
else:
tot = 0
for x in data["meter_reading"]["interval_reading"]:
tot += int(x["value"])
if ( "meter_reading" in data.keys()): # meter reading present
for x in data["meter_reading"]["interval_reading"]:
tot += int(x["value"])
return tot

def analyseValueAndMadeDico(self, data):
Expand All @@ -19,13 +20,14 @@ def analyseValueAndMadeDico(self, data):
raise Exception('call', None)
else:
niemejour = 0
for x in reversed(data["meter_reading"]["interval_reading"]):
niemejour += 1
days = {}
days['date'] = x['date']
days['niemejour'] = niemejour
days['value'] = int(x['value'])
dicoLast7days.append(days)
if ( "meter_reading" in data.keys()): # meter reading present
for x in reversed(data["meter_reading"]["interval_reading"]):
niemejour += 1
days = {}
days['date'] = x['date']
days['niemejour'] = niemejour
days['value'] = int(x['value'])
dicoLast7days.append(days)
return dicoLast7days

def analyseValue(self, data):
Expand Down
2 changes: 2 additions & 0 deletions custom_components/apiEnedis/myClientEnedis.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ def update(self):
self.updateYesterdayProduction()
self.updateTimeLastCall()
self.updateStatusLastCall(True)
log.error("myEnedis ...%s update termine, status courant : %s, lastCall :%s" \
% (self.getContract().get_PDL_ID(), self.getStatusLastCall(), self.getLastMethodCallError()))

except Exception as inst:
if (inst.args == ("call", None)):
Expand Down
2 changes: 1 addition & 1 deletion testEnedis.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def testMulti():

# Lecture fichier Json de sortie
dataJson = readDataJson()
#dataJson = {}
dataJson = {}
myDataEnedis = myClientEnedis.myClientEnedis( token=token, PDL_ID=PDL_ID, delai=3600,
heuresCreuses=heureCreusesCh, heuresCreusesCost=0.0797, heuresPleinesCost=0.1175,
version = __version__, heuresCreusesON=heuresCreusesON )
Expand Down

0 comments on commit d4db63f

Please sign in to comment.