-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Added daily and hourly modes to Openweathermap #14875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Added wind speed and bearing to forecast
if self._mode == 'daily': | ||
fcd = self.owm.daily_forecast_at_coords(self.latitude, self.longitude, 15) | ||
else: | ||
fcd = self.owm.three_hours_forecast_at_coords(self.latitude, self.longitude) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (92 > 79 characters)
fcd = self.owm.three_hours_forecast_at_coords( | ||
self.latitude, self.longitude) | ||
if self._mode == 'daily': | ||
fcd = self.owm.daily_forecast_at_coords(self.latitude, self.longitude, 15) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (90 > 79 characters)
ATTR_FORECAST_PRECIPITATION: entry.get_rain().get('3h'), | ||
ATTR_FORECAST_CONDITION: | ||
[k for k, v in CONDITION_CLASSES.items() | ||
if entry.get_weather_code() in v][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line over-indented for visual indent
else: | ||
data.append({ | ||
ATTR_FORECAST_TIME: entry.get_reference_time('unix') * 1000, | ||
ATTR_FORECAST_TEMP: round(entry.get_temperature('celsius').get('temp')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (92 > 79 characters)
}) | ||
else: | ||
data.append({ | ||
ATTR_FORECAST_TIME: entry.get_reference_time('unix') * 1000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (80 > 79 characters)
data.append({ | ||
ATTR_FORECAST_TIME: entry.get_reference_time('unix') * 1000, | ||
ATTR_FORECAST_TEMP: round(entry.get_temperature('celsius').get('day')), | ||
ATTR_FORECAST_TEMP_LOW: round(entry.get_temperature('celsius').get('night')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (97 > 79 characters)
if self._mode == 'daily': | ||
data.append({ | ||
ATTR_FORECAST_TIME: entry.get_reference_time('unix') * 1000, | ||
ATTR_FORECAST_TEMP: round(entry.get_temperature('celsius').get('day')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (91 > 79 characters)
}) | ||
if self._mode == 'daily': | ||
data.append({ | ||
ATTR_FORECAST_TIME: entry.get_reference_time('unix') * 1000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (80 > 79 characters)
@@ -132,23 +140,37 @@ def wind_bearing(self): | |||
|
|||
@property | |||
def attribution(self): | |||
"""Return the attribution.""" | |||
return ATTRIBUTION | |||
"""Return the attribution. Passing different attributes to correctly display the time in the frontend weather card""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (125 > 79 characters)
from homeassistant.const import ( | ||
CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME, STATE_UNKNOWN, | ||
CONF_API_KEY, CONF_MODE, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME, STATE_UNKNOWN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (85 > 79 characters)
ATTR_FORECAST_TEMP: round(entry.get_temperature('celsius').get('day')), | ||
ATTR_FORECAST_TEMP_LOW: round(entry.get_temperature('celsius').get('night')), | ||
ATTR_FORECAST_WIND_SPEED: round(entry.get_wind().get('speed')), | ||
ATTR_FORECAST_WIND_BEARING: round(entry.get_wind().get('deg')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
ATTR_FORECAST_TIME: entry.get_reference_time('unix') * 1000, | ||
ATTR_FORECAST_TEMP: round(entry.get_temperature('celsius').get('day')), | ||
ATTR_FORECAST_TEMP_LOW: round(entry.get_temperature('celsius').get('night')), | ||
ATTR_FORECAST_WIND_SPEED: round(entry.get_wind().get('speed')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
@@ -49,6 +55,7 @@ | |||
|
|||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ | |||
vol.Required(CONF_API_KEY): cv.string, | |||
vol.Optional(CONF_MODE, default='hourly'): vol.In(FORECAST_MODE), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep it alphabetically ordered.
ATTR_FORECAST_WIND_BEARING = 'wind_bearing' | ||
|
||
ATTRIBUTION_DAILY = "Weather data provided by OpenWeatherMap" | ||
ATTRIBUTION_HOURLY = "Data provided by OpenWeatherMap" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One attribution is enough.
result = ATTRIBUTION_DAILY | ||
else: | ||
result = ATTRIBUTION_HOURLY | ||
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a hack and must be removed. It's a frontend issue and must be addressed there.
Description:
Added daily and hourly modes, wind speed and bearing to forecast
Pull request in home-assistant.github.io with documentation: home-assistant/home-assistant.io#5510
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices: