mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-10-29 17:21:57 +00:00
fix(elecprice): handle mixed UTC offsets in Tibber prices around DST (#1448)
Once Tibber publishes prices across a DST change, the series holds timestamps with two UTC offsets and pd.to_datetime() raises "Mixed timezones detected", so every optimization run is canceled. Parse via UTC and convert back to the configured timezone. Fixes #1446
This commit is contained in:
@@ -317,7 +317,11 @@ class ElecPriceTibber(ElecPriceProvider):
|
||||
if series.empty:
|
||||
return series
|
||||
series = series.sort_index()
|
||||
series.index = pd.to_datetime([to_datetime(index).isoformat() for index in series.index])
|
||||
# Parse via UTC: around a DST change the series mixes UTC offsets
|
||||
# (e.g. +02:00 and +01:00), which pd.to_datetime() refuses to combine.
|
||||
index = pd.to_datetime([to_datetime(index).isoformat() for index in series.index], utc=True)
|
||||
timezone = self.config.general.timezone
|
||||
series.index = index.tz_convert(timezone) if timezone else index
|
||||
series = series.groupby(level=0).mean().sort_index()
|
||||
return series.dropna()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user