homeassistant_cz_energy_spot_prices
homeassistant_cz_energy_spot_prices copied to clipboard
Timezone issues
There are some problems if the current timezone is different than Europe/Prague
.
For example with London timezone, this error occurs:
2023-07-12 13:52:06.736 ERROR (MainThread) [custom_components.cz_energy_spot_prices.coordinator] Unexpected error fetching Czech Energy Spot Prices - 1 data: datetime.datetime(2023, 7, 11, 23, 0, tzinfo=datetime.timezone.utc)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 213, in _async_update_data
gas=DailySpotRateData(gas_rates, zoneinfo=zoneinfo),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 144, in __init__
self._today = rates[midnight_today]
~~~~~^^^^^^^^^^^^^^^^
KeyError: datetime.datetime(2023, 7, 11, 23, 0, tzinfo=datetime.timezone.utc)
Workaround is to set the timezone to Europe/Prague
.