From 1b6afde31264c21540b2a8d8de3be459ab740796 Mon Sep 17 00:00:00 2001 From: JuliusFreudenberger Date: Thu, 24 Sep 2020 11:03:16 +0200 Subject: [PATCH] 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. --- weather_openweathermap.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weather_openweathermap.py b/weather_openweathermap.py index a4bcf9e..702281d 100644 --- a/weather_openweathermap.py +++ b/weather_openweathermap.py @@ -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()