Skip to content

Commit

Permalink
Fix to handle bug in Nordpool integration.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbkarlsson authored Dec 23, 2022
1 parent ba2bb5e commit 69d107c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions custom_components/ev_smart_charging/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,17 @@ async def update_sensors(
self.raw_today_local = Raw(price_state.attributes["raw_today"])
self.raw_tomorrow_local = Raw(price_state.attributes["raw_tomorrow"])
self.tomorrow_valid = self.raw_tomorrow_local.is_valid()

# Fix to take care of Nordpool bug
# https://github.com/custom-components/nordpool/issues/235
if self.tomorrow_valid:
datetime_today = self.raw_today_local.get_raw()[0]["start"]
datetime_tomorrow = self.raw_tomorrow_local.get_raw()[0]["start"]
if datetime_today == datetime_tomorrow:
_LOGGER.debug("Nordpool bug detected and avoided.")
self.raw_tomorrow_local = Raw([])
self.tomorrow_valid = False

# Change to UTC time
self.raw_two_days = self.raw_today_local.copy().to_utc()
self.raw_two_days.extend(self.raw_tomorrow_local.copy().to_utc())
Expand Down

0 comments on commit 69d107c

Please sign in to comment.