Yahoo Weather update, supports forecast for more days#8626
Yahoo Weather update, supports forecast for more days#8626pvizeli merged 19 commits intohome-assistant:devfrom
Conversation
| ATTR_FORECAST_TEMP: | ||
| self._data.yahoo.Forecast[self._forecast]['high'], | ||
| }] | ||
| return [{'datetime':v['date'], ATTR_FORECAST_TEMP:int(v['high']), 'templow': int(v['low']), |
There was a problem hiding this comment.
missing whitespace after ':'
line too long (99 > 79 characters)
|
|
||
| add_devices([YahooWeatherWeather(yahoo_api, name, forecast)], True) | ||
|
|
||
| def _windtostring(degree): |
| ATTRIBUTION = "Weather details provided by Yahoo! Inc." | ||
|
|
||
| ATTR_FORECAST_DATE = 'datetime' | ||
| ATTR_FORECAST_TEMP = 'temperature' |
There was a problem hiding this comment.
redefinition of unused 'ATTR_FORECAST_TEMP' from line 13
| self._data.yahoo.Forecast[self._forecast]['high'], | ||
| }] | ||
| return [{ATTR_FORECAST_TIME: v['date'], ATTR_FORECAST_TEMP:int(v['high']), ATTR_FORECAST_TEMP_LOW: int(v['low']), | ||
| ATTR_FORECAST_CONDITION: CONDITION_CLASSES_LIST[int(v['code'])]} |
There was a problem hiding this comment.
line too long (81 > 79 characters)
| ATTR_FORECAST_TEMP: | ||
| self._data.yahoo.Forecast[self._forecast]['high'], | ||
| }] | ||
| return [{ATTR_FORECAST_TIME: v['date'], ATTR_FORECAST_TEMP:int(v['high']), ATTR_FORECAST_TEMP_LOW: int(v['low']), |
There was a problem hiding this comment.
line too long (121 > 79 characters)
| ATTRIBUTION = "Weather details provided by Yahoo! Inc." | ||
|
|
||
| CONF_FORECAST = 'forecast' | ||
| ATTR_FORECAST_TIME = 'datetime' |
There was a problem hiding this comment.
redefinition of unused 'ATTR_FORECAST_TIME' from line 13
| from homeassistant.components.weather import ( | ||
| WeatherEntity, PLATFORM_SCHEMA, ATTR_FORECAST_TEMP) | ||
| from homeassistant.const import (TEMP_CELSIUS, CONF_NAME, STATE_UNKNOWN) | ||
| WeatherEntity, PLATFORM_SCHEMA, ATTR_FORECAST, ATTR_FORECAST_TEMP, ATTR_FORECAST_TIME) |
There was a problem hiding this comment.
line too long (90 > 79 characters)
| vol.Optional(CONF_FORECAST, default=0): | ||
| vol.All(vol.Coerce(int), vol.Range(min=0, max=5)), | ||
| vol.Optional(CONF_FORECAST, default=5): | ||
| vol.All(vol.Coerce(int), vol.Range(min=0, max=5)), |
| int(self._data.yahoo.Now['code']) in v][0] | ||
| except IndexError: | ||
| return STATE_UNKNOWN | ||
| return CONDITION_CLASSES_LIST[int(self._data.yahoo.Now['code'])] |
There was a problem hiding this comment.
You should catch ValueError and IndexError
|
|
||
| for cond, condlst in CONDITION_CLASSES.items(): | ||
| for condi in condlst: | ||
| CONDITION_CLASSES_LIST[condi] = cond |
There was a problem hiding this comment.
We do not allow to use globals. You need do that inside data with a membervariable
There was a problem hiding this comment.
CONDITION_CLASSES_LIST should be a const, so I think I forget to move the init code into globle scope.
CONDITION_CLASSES_LIST = [str(x) for x in range(0, 50)]
for cond, condlst in CONDITION_CLASSES.items():
for condi in condlst:
CONDITION_CLASSES_LIST[condi] = cond| ATTR_FORECAST_TEMP: | ||
| self._data.yahoo.Forecast[self._forecast]['high'], | ||
| }] | ||
| if self._forecast == None: |
There was a problem hiding this comment.
comparison to None should be 'if cond is None:'
This reverts commit 28b4972. revert unintentional submodule change
|
@pvizeli |
| def forecast(self): | ||
| """Return the forecast array.""" | ||
| if not self._forecast: | ||
| return [] |
There was a problem hiding this comment.
Not needed...CONF_FORECAST will never be None as it defaults to 5 if not provided.
| return self._data.yahoo.Wind['speed'] | ||
|
|
||
| @property | ||
| def wind_bearing(self): |
| return STATE_UNKNOWN | ||
| return CONDITION_CLASSES_LIST[int(self._data.yahoo.Now['code'])] | ||
| except (ValueError, IndexError): | ||
| return '' |
There was a problem hiding this comment.
Wouldn't it be better to return STATE_UNKNOWN instead of an empty string?
|
Done |
| vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, | ||
| vol.Optional(CONF_FORECAST, default=0): | ||
| vol.All(vol.Coerce(int), vol.Range(min=0, max=5)), | ||
| vol.Optional(CONF_FORECAST, default=5): |
There was a problem hiding this comment.
Don't make a breaking change. I see no reason to change this now.
There was a problem hiding this comment.
The forecast in yaml works different from the old one, so I think maybe its better to change forecast to something like forecast_days.
| 'exceptional': [0, 1, 2, 3, 4, 25, 36], | ||
| } | ||
|
|
||
| _CONDITION_CLASSES_MAX = 50 |
| return [k for k, v in CONDITION_CLASSES.items() if | ||
| int(self._data.yahoo.Now['code']) in v][0] | ||
| except IndexError: | ||
| return hass.data[DATA_CONDITION][int(self._data.yahoo.Now['code'])] |
| _LOGGER.error("Yahoo! only support %d days forecast", | ||
| len(yahoo_api.yahoo.Forecast)) | ||
| return False | ||
|
|
|
Thanks for the push. |
|
Anyway. We had the data present, so we can show the data to UI :) It cost not more if we don't use it. |
|
I think some text like weather condiction, and some other common fields should goes to |
|
👍 |
|
Since the update, I am seeing some unusually high temperatures in my area. All the other data are correct, but I'm pretty sure it's not 185 degrees out, despite feeling like it. Issue opened: #8758 |
…#8626) * work on weather panel * update yahooweather with more forecast details * Update yweather to allow user input forecast date * fix for houndci * fix long line * fix1 * Revert "work on weather panel" This reverts commit 28b4972. revert unintentional submodule change * fix2 fix typo, add try catch to another int() * fix pylint * fix3 * fix4 * Update yweather.py * Update yweather.py * Remove global data construct * Yahoo API support only 5 days forecast * remove forecast * fix lint * fix lint p2 * Update yweather.py

Description:
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#3047
Works perfectly with home-assistant/frontend#352 updated weather panel.
Example entry for
configuration.yaml(if applicable):Breaking change
forecastis now every time present and the options was removed.Checklist:
toxrun successfully. Your PR cannot be merged unless tests passTested on my device with
hass --debug.