mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix ecobee weather forcast off by 1 bug (#40048)
This commit is contained in:
parent
1a76a953c7
commit
7a7cad39eb
@ -1,5 +1,5 @@
|
|||||||
"""Support for displaying weather info from Ecobee API."""
|
"""Support for displaying weather info from Ecobee API."""
|
||||||
from datetime import datetime
|
from datetime import timedelta
|
||||||
|
|
||||||
from pyecobee.const import ECOBEE_STATE_UNKNOWN
|
from pyecobee.const import ECOBEE_STATE_UNKNOWN
|
||||||
|
|
||||||
@ -13,6 +13,7 @@ from homeassistant.components.weather import (
|
|||||||
WeatherEntity,
|
WeatherEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import TEMP_FAHRENHEIT
|
from homeassistant.const import TEMP_FAHRENHEIT
|
||||||
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
@ -165,10 +166,13 @@ class EcobeeWeather(WeatherEntity):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
forecasts = []
|
forecasts = []
|
||||||
for day in range(1, 5):
|
date = dt_util.utcnow()
|
||||||
|
for day in range(0, 5):
|
||||||
forecast = _process_forecast(self.weather["forecasts"][day])
|
forecast = _process_forecast(self.weather["forecasts"][day])
|
||||||
if forecast is None:
|
if forecast is None:
|
||||||
continue
|
continue
|
||||||
|
forecast[ATTR_FORECAST_TIME] = date.isoformat()
|
||||||
|
date += timedelta(days=1)
|
||||||
forecasts.append(forecast)
|
forecasts.append(forecast)
|
||||||
|
|
||||||
if forecasts:
|
if forecasts:
|
||||||
@ -186,9 +190,6 @@ def _process_forecast(json):
|
|||||||
"""Process a single ecobee API forecast to return expected values."""
|
"""Process a single ecobee API forecast to return expected values."""
|
||||||
forecast = {}
|
forecast = {}
|
||||||
try:
|
try:
|
||||||
forecast[ATTR_FORECAST_TIME] = datetime.strptime(
|
|
||||||
json["dateTime"], "%Y-%m-%d %H:%M:%S"
|
|
||||||
).isoformat()
|
|
||||||
forecast[ATTR_FORECAST_CONDITION] = ECOBEE_WEATHER_SYMBOL_TO_HASS[
|
forecast[ATTR_FORECAST_CONDITION] = ECOBEE_WEATHER_SYMBOL_TO_HASS[
|
||||||
json["weatherSymbol"]
|
json["weatherSymbol"]
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user