Ensure metoffice daily are returned once daily (#72440)

* ensure metoffice daily are returned once daily

* Fixes metoffice tests for MODE_DAILY
This commit is contained in:
Gordon Allott 2022-06-20 19:27:39 +01:00 committed by GitHub
parent f43cc18aa3
commit 66b02ecff0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 21 deletions

View file

@ -7,6 +7,7 @@ import datapoint
from homeassistant.helpers.update_coordinator import UpdateFailed
from homeassistant.util.dt import utcnow
from .const import MODE_3HOURLY
from .data import MetOfficeData
_LOGGER = logging.getLogger(__name__)
@ -39,6 +40,9 @@ def fetch_data(connection: datapoint.Manager, site, mode) -> MetOfficeData:
for day in forecast.days
for timestep in day.timesteps
if timestep.date > time_now
and (
mode == MODE_3HOURLY or timestep.date.hour > 6
) # ensures only one result per day in MODE_DAILY
],
site,
)