JaccoR / hass-entso-e

Integration for Home Assistant to fetch day ahead energy prices from European countries via ENTSO-e Transparency Platform
159 stars 25 forks source link

Question: update interval #51

Closed sfstar closed 1 year ago

sfstar commented 1 year ago

Currently the update interval for the integration is set to 15 minutes. However, entsoe only publishes new data on 13:00 after which the next days hour prices are static. Wouldn't it be better if the integration were to update less frequently (thereby creating less load on the entsoe API if usage of this integration takes of). Or are there any (currently not seen by me) reasons why a more frequent update interval is desirable?

JaccoR commented 1 year ago

This is basically a remnant of when I used this integration differently in a very early state. The following code in sensor.py overrides this update interval to do this only every hour.

        # Schedule the next update at exactly the next whole hour sharp
        self._unsub_update = event.async_track_point_in_utc_time(
            self.hass,
            self._update_job,
            utcnow().replace(minute=0, second=0) + timedelta(hours=1),
        )

However, now this is indeed redundant and could be done once a day. Some restructuring of coordinator.py is necessary to do it once a day. Another problem is that not all prices of all countries are available at exactly 13:00, some are available later and some earlier.

sfstar commented 1 year ago

Once a hour is a great improvement over once every 15 minutes. Did not know that not every country has their prices published at 13:00. In that case once a hour seems only fair (you could possibly restrict the updates to hourly around the hours when new prices come available).

The code you qouted indicates that all integrations will update on the hour exactly. Perhaps this might be shifted around a bit so that requests get spread over the first x minutes of the hour