Adjust energy price data handling for daylight saving time changes
All checks were successful
Build a dev image / build (push) Successful in 22s
All checks were successful
Build a dev image / build (push) Successful in 22s
This commit is contained in:
parent
1a7daca3be
commit
f9e50e4995
1 changed files with 5 additions and 3 deletions
|
|
@ -51,6 +51,11 @@ def get_energy_prices(d: datetime.date=datetime.date.today(), no_cache:bool=Fals
|
|||
try:
|
||||
mins_index = 0
|
||||
hour = 0
|
||||
|
||||
# Adjust for daylight saving time changes
|
||||
if len(data) == 100:
|
||||
data = data[0:8] + data[12:100]
|
||||
|
||||
for raw in data:
|
||||
hour_str = f"{hour}:00"
|
||||
if mins_index == 1:
|
||||
|
|
@ -70,9 +75,6 @@ def get_energy_prices(d: datetime.date=datetime.date.today(), no_cache:bool=Fals
|
|||
raise PriceNotFound()
|
||||
|
||||
# Only cache if all 24 hours are present
|
||||
if len(hours) == 100:
|
||||
hours = hours[0:8] + hours[12:100]
|
||||
|
||||
if len(hours) in (24, 96): # 96 for 15-min intervals
|
||||
with open(cache_file, "w") as f:
|
||||
f.write(json.dumps(hours))
|
||||
|
|
|
|||
Loading…
Reference in a new issue