Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tsbernar committed Apr 23, 2023
1 parent 2744956 commit d44c33b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom_components/openweathermaphistory/weatherhistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import HomeAssistant
from homeassistant.helpers.storage import Store

from homeassistant.helpers.typing import ConfigType

from .const import (
Expand Down Expand Up @@ -92,6 +91,8 @@ async def async_load(self):
_LOGGER.debug("No data from storage: %s", self._store.path)
return

_LOGGER.debug("Loaded data from storage")

if data["hourly_history"]:
self._hourly_history.clear()
for dt_str, wd_dict in data["hourly_history"]:
Expand All @@ -107,16 +108,15 @@ async def async_load(self):
if data["day_rolling_window"]:
for dt_str in data["day_rolling_window"]:
datetime.fromisoformat(dt_str)
self._hour_rolling_window.data.append(dt)

_LOGGER.debug("Loaded data from storage: %s", self._hourly_history)
self._day_rolling_window.data.append(dt)

async def async_save(self):
data = {
"hourly_history": self._hourly_history,
"day_rolling_window": self._day_rolling_window.data,
"hour_rolling_window": self._hour_rolling_window.data,
}
_LOGGER.debug("Saving data")
await self._store.async_save(data)

async def backfill_chunk(self, max_calls: int = 10):
Expand Down

0 comments on commit d44c33b

Please sign in to comment.