Fix energy price retrieval to handle empty responses
This commit is contained in:
parent
4bd28614cc
commit
3a2b78fcce
1 changed files with 6 additions and 1 deletions
|
@ -33,8 +33,13 @@ def get_energy_prices(d: datetime.date=datetime.date.today(), no_cache:bool=Fals
|
|||
|
||||
if not hours or no_cache:
|
||||
r = requests.get(url_energy.format(date_str))
|
||||
data = r.json()["data"]["dataLine"][1]["point"]
|
||||
resp = r.json()["data"]["dataLine"]
|
||||
|
||||
if len(resp) == 0:
|
||||
raise PriceNotFound()
|
||||
|
||||
data = resp[1]["point"]
|
||||
|
||||
if len(data) == 24:
|
||||
try:
|
||||
for raw in data:
|
||||
|
|
Loading…
Reference in a new issue