Skip to content

Commit

Permalink
gestion probleme reboot après minuit et avant horaire possible
Browse files Browse the repository at this point in the history
correction comparaison version git
  • Loading branch information
saniho committed Jul 27, 2021
1 parent f411ea7 commit c221e66
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 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 """
# attention updater aussi manifest.json
__VERSION__ = "1.3.1.10"
__VERSION__ = "1.3.1.11"
__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.3.1.10",
"version": "1.3.1.11",
"requirements": [
],
"dependencies": [],
Expand Down
22 changes: 15 additions & 7 deletions custom_components/apiEnedis/myClientEnedis.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ def setNbCall(self, nbCall):
self._nbCall += nbCall

def updateStatusLastCall(self, status):
self._statusLastCall = status
if ( not self._forceCallJson ): # pour eviter d'ecraser le statut quand on recupere la date depuis le json
self._statusLastCall = status

def getErrorLastCall(self):
return self._errorLastCall
Expand Down Expand Up @@ -705,10 +706,17 @@ def updateGitVersion(self):
def getCallPossible(self, currentDateTime = datetime.datetime.now(), trace = False):
# new callpossible ???
callpossible = ( self.getHorairePossible() and
( self.getLastCallHier() or (self.getTimeLastCall() == None) or
(self.getStatusLastCall() == False and self.getDelaiIsGoodAfterError(currentDateTime))
)
( self.getLastCallHier() or
( self.getTimeLastCall() == None) or
( self.getStatusLastCall() == False
and self.getDelaiIsGoodAfterError(currentDateTime)
)
)
)
#if ( self.getDelaiIsGoodAfterError(currentDateTime) ):
# trace = True # pour activer la trace ... et voir comprendre quelque choose
#if ( self.getStatusLastCall() == False ):
# trace = True # pour activer la trace ... et voir comprendre quelque choose
if ( self._forceCallJson ):
callpossible = True
if ( trace ):
Expand Down Expand Up @@ -737,15 +745,15 @@ def update(self):
if (self.getContract().getValue() != None):
if self.getCallPossible():
try:
log.info("myEnedis(%s) ...%s update lancé, status precedent : %s, lastCall :%s, forcejson :%s" \
log.info("myEnedis(%s) ...%s update lancé, status precedent : %s, lastMethodCall :%s, forcejson :%s" \
% (self.getVersion(), self.getContract().get_PDL_ID(),
self.getStatusLastCall(), self.getLastMethodCallError(),
self._forceCallJson))
log.error("myEnedis(%s) ...%s update lancé, status precedent : %s, lastCall :%s, forcejson :%s" \
log.error("myEnedis(%s) ...%s update lancé, status precedent : %s, lastMethodCall :%s, forcejson :%s" \
% (self.getVersion(), self.getContract().get_PDL_ID(),
self.getStatusLastCall(), self.getLastMethodCallError(),
self._forceCallJson))
self.getCallPossible()
#self.getCallPossible()
self._nbCall = 0
self.updateGitVersion()
self.updateErrorLastCall("")
Expand Down
11 changes: 2 additions & 9 deletions testEnedis.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def testMulti():
myDataEnedis = myClientEnedis.myClientEnedis( token=token, PDL_ID=PDL_ID, delai=7200,
heuresCreuses=heureCreusesCh, heuresCreusesCost=0.0797, heuresPleinesCost=0.1175,
version = __version__, heuresCreusesON=heuresCreusesON )
path = getLocalDirectory( PDL_ID, "20210713" )
path = getLocalDirectory( PDL_ID, "20210727" )
myDataEnedis.setPathArchive(path)
dataJson = {}
dataJson = myDataEnedis.readDataJson()
Expand All @@ -49,20 +49,13 @@ def testMulti():

log.info("" )
log.info("=================>>>> 2 <<<<============" )
time = datetime.datetime.now() + datetime.timedelta(hours=2)
callPossible = myDataEnedis.getCallPossible()
log.info("possible ? %s "%(callPossible))
log.info("** on tente une maj ??")
#myDataEnedis.getData()
log.info("=================< on a fini le call : %s ============" %(myDataEnedis.getNbCall()))

log.info("" )
log.info("=================>>>> 3 <<<<============" )
callPossible = myDataEnedis.getCallPossible()
log.info("possible ? %s "%(callPossible))
log.info("** on tente une maj ??")
#myDataEnedis.getData()
log.info("=================< on a fini le call : %s ============" %(myDataEnedis.getNbCall()))
#print(1/0)
# SORTIE OUTPUT
#writeDataJson( myDataEnedis )

Expand Down

0 comments on commit c221e66

Please sign in to comment.