Rain in hourly weather now displayed correctly
Was a dict conntaining '1h' as key. The value for this key is now used. Also renamed get_weather() to query_weather() as it is not a getter but querying the api.
This commit is contained in:
parent
f6d0db3f41
commit
1b6afde312
1 changed files with 3 additions and 3 deletions
|
@ -31,7 +31,7 @@ class HourlyWeather:
|
|||
self.wind_speed = json_data['wind_speed']
|
||||
self.probability_of_precipitation = json_data['pop']
|
||||
if 'rain' in json_data:
|
||||
self.rain = json_data['rain']
|
||||
self.rain = json_data['rain']['1h']
|
||||
else:
|
||||
self.rain = 0
|
||||
self.main = json_data['weather'][0]['main']
|
||||
|
@ -131,7 +131,7 @@ class City:
|
|||
self.lat = lat
|
||||
self.lon = lon
|
||||
|
||||
def get_weather(self):
|
||||
def query_weather(self):
|
||||
request = requests.get(
|
||||
"http://api.openweathermap.org/data/2.5/onecall?\
|
||||
lang=de&units=metric&exclude=minutely&lat={lat}&lon={lon}&appid={token}".format(
|
||||
|
@ -193,7 +193,7 @@ def handle_weather(update, context):
|
|||
requested_city = get_city_by_name(' '.join(context.args))
|
||||
if requested_city.name == "none":
|
||||
raise WeatherStationNotFoundError
|
||||
requested_city.get_weather()
|
||||
requested_city.query_weather()
|
||||
update.message.reply_text(str(requested_city.weather), disable_notification=True, parse_mode="Markdown")
|
||||
|
||||
requested_city.weather.clear()
|
||||
|
|
Loading…
Reference in a new issue