Skip to content

Commit

Permalink
first pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellowlol committed Mar 26, 2023
1 parent 2b4ed5c commit 809924e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions custom_components/nordpool/aio_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from dateutil import tz
from dateutil.parser import parse as parse_dt
import backoff
import aiohttp
from nordpool.elspot import Prices

from .misc import add_junk
Expand Down Expand Up @@ -177,6 +179,7 @@ async def _fetch_json(self, data_type, end_date=None):
endDate=end_date.strftime("%d-%m-%Y"),
)

@backoff.on_exception(backoff.expo, (aiohttp.ClientError, KeyError), logger=_LOGGER)
async def fetch(self, data_type, end_date=None, areas=None):
"""
Fetch data from API.
Expand All @@ -201,6 +204,8 @@ async def fetch(self, data_type, end_date=None, areas=None):
if areas is None:
areas = []

raise KeyError

# now = datetime.utcnow()
# timezone_for_data = now.astimezone(tz.gettz(ts))
# stock = datetime.utcnow().astimezone(tz.gettz("Europe/Stockholm"))
Expand Down
5 changes: 3 additions & 2 deletions custom_components/nordpool/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/custom-components/nordpool/issues",
"requirements": [
"nordpool>=0.2"
"nordpool>=0.2",
"backoff"
],
"version": "0.0.11"
}
}

0 comments on commit 809924e

Please sign in to comment.