From eef79e291218702a6b74a25fe9eac5c250d711e0 Mon Sep 17 00:00:00 2001 From: lymanepp <4195527+lymanepp@users.noreply.github.com> Date: Mon, 6 Jun 2022 00:10:33 -0400 Subject: [PATCH] Tomorrowio utc fix (#73102) * Discard past data using local time instead of UTC * Tweak changes to fix tests * Cleanup --- homeassistant/components/tomorrowio/weather.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/tomorrowio/weather.py b/homeassistant/components/tomorrowio/weather.py index bf687f8bdca..52eedff49b1 100644 --- a/homeassistant/components/tomorrowio/weather.py +++ b/homeassistant/components/tomorrowio/weather.py @@ -198,13 +198,16 @@ class TomorrowioWeatherEntity(TomorrowioEntity, WeatherEntity): max_forecasts = MAX_FORECASTS[self.forecast_type] forecast_count = 0 + # Convert utcnow to local to be compatible with tests + today = dt_util.as_local(dt_util.utcnow()).date() + # Set default values (in cases where keys don't exist), None will be # returned. Override properties per forecast type as needed for forecast in raw_forecasts: forecast_dt = dt_util.parse_datetime(forecast[TMRW_ATTR_TIMESTAMP]) # Throw out past data - if forecast_dt.date() < dt_util.utcnow().date(): + if dt_util.as_local(forecast_dt).date() < today: continue values = forecast["values"]