From c221e6698b970176d98d00ccb938da3b769a5e91 Mon Sep 17 00:00:00 2001 From: saniho <52693545+saniho@users.noreply.github.com> Date: Tue, 27 Jul 2021 22:21:40 +0200 Subject: [PATCH] =?UTF-8?q?gestion=20probleme=20reboot=20apr=C3=A8s=20minu?= =?UTF-8?q?it=20et=20avant=20horaire=20possible=20correction=20comparaison?= =?UTF-8?q?=20version=20git?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/apiEnedis/const.py | 2 +- custom_components/apiEnedis/manifest.json | 2 +- custom_components/apiEnedis/myClientEnedis.py | 22 +++++++++++++------ testEnedis.py | 11 ++-------- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/custom_components/apiEnedis/const.py b/custom_components/apiEnedis/const.py index 5f08a6b..750f8bb 100644 --- a/custom_components/apiEnedis/const.py +++ b/custom_components/apiEnedis/const.py @@ -1,6 +1,6 @@ """ Constants """ # attention updater aussi manifest.json -__VERSION__ = "1.3.1.10" +__VERSION__ = "1.3.1.11" __name__ = "myEnedis" try: diff --git a/custom_components/apiEnedis/manifest.json b/custom_components/apiEnedis/manifest.json index a39b615..b1c75a6 100644 --- a/custom_components/apiEnedis/manifest.json +++ b/custom_components/apiEnedis/manifest.json @@ -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": [], diff --git a/custom_components/apiEnedis/myClientEnedis.py b/custom_components/apiEnedis/myClientEnedis.py index 8a596a9..7f86605 100644 --- a/custom_components/apiEnedis/myClientEnedis.py +++ b/custom_components/apiEnedis/myClientEnedis.py @@ -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 @@ -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 ): @@ -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("") diff --git a/testEnedis.py b/testEnedis.py index 6ebee18..1ff04b6 100644 --- a/testEnedis.py +++ b/testEnedis.py @@ -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() @@ -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 )