diff --git a/.scannerwork/report-task.txt b/.scannerwork/report-task.txt new file mode 100644 index 0000000..65c84c9 --- /dev/null +++ b/.scannerwork/report-task.txt @@ -0,0 +1,6 @@ +projectKey=saniho:apienedi +serverUrl=http://192.168.1.93:9000 +serverVersion=8.6.0.39681 +dashboardUrl=http://192.168.1.93:9000/dashboard?id=saniho%3Aapienedi +ceTaskId=AXbuMh9TTRDQjAtxtmrJ +ceTaskUrl=http://192.168.1.93:9000/api/ce/task?id=AXbuMh9TTRDQjAtxtmrJ diff --git a/custom_components/apiEnedis/__init__.py b/custom_components/apiEnedis/__init__.py index 710e9dd..1959b63 100644 --- a/custom_components/apiEnedis/__init__.py +++ b/custom_components/apiEnedis/__init__.py @@ -213,9 +213,6 @@ async def request_update(call): await self.async_request_refresh() await self.async_set_options() await self.hass.async_add_executor_job(self.update_MyEnedis) - #_LOGGER.exception("async_add_executor_job - ") - #self.hass.services.async_register(DOMAIN, myENEDIS_SERVICE, request_update) - #_LOGGER.exception("async_add_executor_job - done -- ") self._unsub_update_listener = self.config_entry.add_update_listener( options_updated_listener ) diff --git a/custom_components/apiEnedis/const.py b/custom_components/apiEnedis/const.py index a5c50fb..5042fa4 100644 --- a/custom_components/apiEnedis/const.py +++ b/custom_components/apiEnedis/const.py @@ -19,10 +19,9 @@ HC_COST = "hc_cout" CONF_DELAY = 60 * 60 * 6 # verification enedis toutes les 6 heures -#CONF_DELAY = 60 * 2 # verification enedis toutes les 2 minutes DEFAULT_SCAN_INTERVAL = 60*5 # verification enedis toutes les 5 minutes, si dernier ok, alors verif selon conf_delay DEFAULT_SENSOR_INTERVAL = 60 # 60 secondes verifications du coordinator -__VERSION__ = "1.1.2.0alpha" +__VERSION__ = "1.1.2.0alpha2" __name__ = "myEnedis" \ No newline at end of file diff --git a/custom_components/apiEnedis/myEnedis.py b/custom_components/apiEnedis/myEnedis.py index 206dc7d..3a8c045 100644 --- a/custom_components/apiEnedis/myEnedis.py +++ b/custom_components/apiEnedis/myEnedis.py @@ -77,7 +77,6 @@ def post_and_get_json(self, url, params=None, data=None, headers=None): import logging import json session = requests.Session() - #response = session.post(url, params=params, data=json.dumps(data), headers=headers) response = session.post(url, params=params, data=json.dumps(data), headers=headers, timeout=30) response.raise_for_status() return response.json() @@ -438,14 +437,7 @@ def createMultiDaysHCHP(self, data): joursHP[date] += int(x["value"]) * self.getCoeffIntervalLength() # car c'est en heure else: joursHC[date] +=int(x["value"]) * self.getCoeffIntervalLength() # car c'est pas en heure - - # if ( date == "2020-12-06" ): - # print("ici", x["date"], heure, " ", heurePleine, ", ", x[ "value" ], \ - # self._joursHP[date], self._joursHC[date], self._joursHP[date] + self._joursHC[date]) - return joursHC, joursHP - #print(self._joursHC) - #print(self._joursHP) def getIntervalLength(self): return self._interval_length @@ -468,12 +460,8 @@ def createHCHP(self, data): heurePleine = self._getHCHPfromHour( heure ) if ( heurePleine): self._HP += int(x["value"]) * self.getCoeffIntervalLength()# car par transhce de 30 minutes - #print( heure, heurePleine, x[ "value" ], self._HP) else: self._HC += int(x["value"]) * self.getCoeffIntervalLength()# car par transhce de 30 minutes - #print( heure, " ", heurePleine, ", ", x[ "value" ], self._HC, self._HP, self._HC + self._HP) - #print(self._HC) - #print(self._HP) def updateDataYesterdayHCHP(self, data=None): self.updateLastMethodCall("updateDataYesterdayHCHP") @@ -488,11 +476,9 @@ def updateDataYesterdayHCHP(self, data=None): def checkDataPeriod(self, dataAnswer ): if ("enedis_return" in dataAnswer.keys()): - if ( dataAnswer['enedis_return']["error"] == "ADAM-ERR0123" ) : - return False - elif ( dataAnswer['enedis_return']["error"] == "no_data_found" ) : - return False - elif ( dataAnswer['enedis_return']["error"] == "UNKERROR_002" ) : + if ( dataAnswer['enedis_return']["error"] == "ADAM-ERR0123" ) or\ + ( dataAnswer['enedis_return']["error"] == "no_data_found" ) or\ + ( dataAnswer['enedis_return']["error"] == "UNKERROR_002" ) : return False if ( dataAnswer['enedis_return']["error"] == "Internal Server error" ): #erreur interne enedis @@ -509,12 +495,9 @@ def checkDataPeriod(self, dataAnswer ): def checkData(self, dataAnswer ): if ("enedis_return" in dataAnswer.keys()): - #if ( isinstance(dataAnswer['enedis_return'], str)): - # dataAnswer['enedis_return'] = json.loads(dataAnswer['enedis_return']) - if ( dataAnswer['enedis_return']["error"] == "ADAM-DC-0008" ): - #No consent can be found for this customer and this usage point - return False - elif ( dataAnswer['enedis_return']["error"] == "UNKERROR_002" ) : + #No consent can be found for this customer and this usage point + if ( dataAnswer['enedis_return']["error"] == "ADAM-DC-0008" ) or\ + ( dataAnswer['enedis_return']["error"] == "UNKERROR_002" ) : return False if ( dataAnswer['enedis_return']["error"] == "Internal Server error" ): #erreur interne enedis @@ -532,7 +515,6 @@ def checkData(self, dataAnswer ): def checkDataContract(self, dataAnswer ): if ("error" in dataAnswer.keys()): - #self.myLogWarning( "** %s" %(dataAnswer["error"])) raise Exception( 'call' , "error", dataAnswer["error"] ) return True diff --git a/custom_components/apiEnedis/sensor.py b/custom_components/apiEnedis/sensor.py index 8f88e96..f7c41d3 100644 --- a/custom_components/apiEnedis/sensor.py +++ b/custom_components/apiEnedis/sensor.py @@ -62,7 +62,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None): name = config.get(CONF_NAME) token = config.get(CONF_TOKEN) code = config.get(CONF_CODE) - #[['00:30', '07:00'], ['10:00', "11:30"]] heuresCreusesCh = config.get(HEURES_CREUSES) heuresCreuses = eval(heuresCreusesCh) HCCost = float(config.get(HC_COST))