Skip to content

Commit

Permalink
Merge local fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ejpenney committed Feb 8, 2023
1 parent d9cd0a7 commit 9ffc837
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions custom_components/portland_general_electric/pge_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9ffc837

Please sign in to comment.