From 9ffc8376e0dced82aadebb8a95dbab9418cbca81 Mon Sep 17 00:00:00 2001 From: "Penney, Emory J" Date: Wed, 8 Feb 2023 21:18:58 +0000 Subject: [PATCH] Merge local fixes --- .../portland_general_electric/pge_api.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/custom_components/portland_general_electric/pge_api.py b/custom_components/portland_general_electric/pge_api.py index 69c9997..285e699 100644 --- a/custom_components/portland_general_electric/pge_api.py +++ b/custom_components/portland_general_electric/pge_api.py @@ -166,7 +166,7 @@ def update(self): if not self.billing_day: self.get_billing_day() - start_date = date.today() - relativedelta(days=self.billing_day) + start_date = date.today() - relativedelta(days=31) LOGGER.debug("Query Period start_date=%s", start_date) try: @@ -186,7 +186,7 @@ def update(self): ) except Exception as exc: LOGGER.warning("Caught exception: %s", exc.args) - self._state = None + self.state = None return False return True @@ -232,7 +232,13 @@ def _update_meter(self, query: callable) -> None: LOGGER.debug("Query Period start_date=%s", start_date) meter = query(self.uuid, start_date) - + # for _ in range(5): + # try: + # meter = query(self.uuid, start_date) + # break + # except Exception as exc: + # LOGGER.debug("Caught exception querying, attempting to refresh login...") + # self._login() # "Flatten" read time. # PGE read times run 17:00-17:00, but we reset at midnight curr_read_time = dt.start_of_local_day( @@ -317,7 +323,7 @@ def update(self) -> None: """Get latest data for the sensor""" try: - self._login() + # self._login() self._update_meter(self.opower_client.utility_usage_hourly) except Exception: self.state = None