rnovacek / homeassistant_cz_energy_spot_prices

Home Assistant integration that provides current Czech electricity spot prices based on OTE.
Apache License 2.0
75 stars 17 forks source link

Cache spot prices and handle ote-cr.cz being down. #2

Closed rnovacek closed 1 year ago

rnovacek commented 1 year ago

The integration currently loads the data whenever HomeAssistant "wakes" it (note: need to investigate how often is it exactly). Given that the data should only need to be loaded once a day, it would make more sense to cache it and maybe just update it once in a while (once every hour maybe? Or is there no chance that the data will change during the day?)

Another problem is that the integration doesn't report anything when ote-cr.cz is down. It should be easy to fix it so it returns cached value. The cached value should also survive HA restart.

rnovacek commented 1 year ago

I've rewritten the data fetching to use data coordinator, so it should only update once every hour and should be cached when next update fails for some reason.