Skip to content

Commit

Permalink
Merge pull request #208 from saniho/AddYearComparison
Browse files Browse the repository at this point in the history
Add year comparison
  • Loading branch information
saniho authored Dec 18, 2022
2 parents 18b56a7 + 4657b4a commit 7046870
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 deletions custom_components/apiEnedis/sensorEnedis.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,20 @@ def getStatus(self, typeSensor=_consommation): # noqa C901
status["errorLastCall"] = data.getCardErrorLastCall()
status["errorLastCallInterne"] = data.getErrorLastCall()

if (
(lastYear is not None)
and (lastYear != 0)
and (currYear is not None)
):
valeur = (
100
* (currYear - lastYear)
/ lastYear
)
status["year_evolution"] = f"{valeur:.3f}"
else:
status["year_evolution"] = 0

if (
(lastMonthLastYear is not None)
and (lastMonthLastYear != 0)
Expand Down
4 changes: 2 additions & 2 deletions testEnedis.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ def testMulti():

mon_conteneur = configparser.ConfigParser()
mon_conteneur.read("../myCredential/security.txt")
for qui in ["ENEDIS100"]:
for qui in ["ENEDIS102"]:
LOGGER.info(f"*** traitement de {qui} ")
token = mon_conteneur[qui]["TOKEN"]
PDL_ID = mon_conteneur[qui]["CODE"]
serviceEnedis = "enedisGateway"
if "SERVICE" in mon_conteneur[qui].keys():
serviceEnedis = mon_conteneur[qui]["SERVICE"]

print(mon_conteneur[qui]["QUI"])
print(mon_conteneur[qui]["QUI"], serviceEnedis)
heureCreusesCh = ast.literal_eval("[['00:00','05:00'], ['22:00', '24:00']]")
heuresCreusesON = True

Expand Down
1 change: 1 addition & 0 deletions tests/test_myEnedis.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ def test_update_data(caplog, tmpdir):
"errorLastCall": "",
"errorLastCallInterne": "",
"monthly_evolution": "-3.990",
"year_evolution": "-78.023",
"current_week_evolution": "-11.906",
"current_month_evolution": "-7.119",
"yesterday_evolution": "-20.122",
Expand Down

0 comments on commit 7046870

Please sign in to comment.