Skip to content

Commit

Permalink
erreur month
Browse files Browse the repository at this point in the history
integration de sonarQube( quality code )
modification valeur du yesterday
manage multi linky
  • Loading branch information
saniho committed Jan 10, 2021
1 parent 9a941a2 commit a7fbfcc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 30 deletions.
6 changes: 6 additions & 0 deletions .scannerwork/report-task.txt
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions custom_components/apiEnedis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
3 changes: 1 addition & 2 deletions custom_components/apiEnedis/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
30 changes: 6 additions & 24 deletions custom_components/apiEnedis/myEnedis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion custom_components/apiEnedis/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit a7fbfcc

Please sign in to comment.