mirror of
https://github.com/home-assistant/core
synced 2024-09-03 08:14:07 +02:00
Tomorrowio utc fix (#73102)
* Discard past data using local time instead of UTC * Tweak changes to fix tests * Cleanup
This commit is contained in:
parent
db53ab5fd0
commit
3744edc512
@ -203,13 +203,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"]
|
||||
|
Loading…
Reference in New Issue
Block a user