Fix energy price retrieval to handle empty responses

This commit is contained in:
Adam Štrauch 2025-10-03 08:46:46 +02:00
parent 4bd28614cc
commit 3a2b78fcce
Signed by: cx
GPG key ID: 7262DAFE292BCE20

View file

@ -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: