Return ISO formated datetime in forecast (#14975)

* Return ISO formated datetime in forecast

* Lint
This commit is contained in:
c727 2018-06-15 23:09:01 +02:00 committed by Paulus Schoutsen
parent 9efa31ef9f
commit d0cbbe6141

View File

@ -4,6 +4,7 @@ Support for displaying weather info from Ecobee API.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/weather.ecobee/ https://home-assistant.io/components/weather.ecobee/
""" """
from datetime import datetime
from homeassistant.components import ecobee from homeassistant.components import ecobee
from homeassistant.components.weather import ( from homeassistant.components.weather import (
WeatherEntity, ATTR_FORECAST_CONDITION, ATTR_FORECAST_TEMP, WeatherEntity, ATTR_FORECAST_CONDITION, ATTR_FORECAST_TEMP,
@ -134,8 +135,10 @@ class EcobeeWeather(WeatherEntity):
try: try:
forecasts = [] forecasts = []
for day in self.weather['forecasts']: for day in self.weather['forecasts']:
date_time = datetime.strptime(day['dateTime'],
'%Y-%m-%d %H:%M:%S').isoformat()
forecast = { forecast = {
ATTR_FORECAST_TIME: day['dateTime'], ATTR_FORECAST_TIME: date_time,
ATTR_FORECAST_CONDITION: day['condition'], ATTR_FORECAST_CONDITION: day['condition'],
ATTR_FORECAST_TEMP: float(day['tempHigh']) / 10, ATTR_FORECAST_TEMP: float(day['tempHigh']) / 10,
} }