From 3976efe5ccad910e1e4ac30e032e5f26dd8d5aab Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sat, 10 Apr 2021 12:56:05 -0500 Subject: [PATCH] Weather.com backend: Fix high/low forecasted temps (#811) * Weather.com backend: Fix high/low forecasted temps The values previously being used were the highest/lowest temps within the last 24 hours, not the forecasted high/low for the current day. * Interpret null forecasts as empty strings --- i3pystatus/weather/weathercom.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/i3pystatus/weather/weathercom.py b/i3pystatus/weather/weathercom.py index 566983e..d8c7fa9 100644 --- a/i3pystatus/weather/weathercom.py +++ b/i3pystatus/weather/weathercom.py @@ -187,6 +187,7 @@ class Weathercom(WeatherBackend): self.data['update_error'] = self.update_error return + self.logger.debug('Parsed weather data: %s', self.parser.weather_data) try: observed = self.parser.weather_data['getSunV3CurrentObservationsUrlConfig'] # Observation data stored under a sub-key containing the @@ -206,7 +207,7 @@ class Weathercom(WeatherBackend): return try: - forecast = self.parser.weather_data['getSunV3CurrentObservationsUrlConfig'] + forecast = self.parser.weather_data['getSunV3DailyForecastWithHeadersUrlConfig'] # Same as above, use next(iter(forecast)) to drill down to the # correct nested dict level. forecast = forecast[next(iter(forecast))]['data'] @@ -251,12 +252,12 @@ class Weathercom(WeatherBackend): pressure_trend = '' try: - high_temp = forecast.get('temperatureMax24Hour', '') + high_temp = forecast.get('temperatureMax', [])[0] or '' except (AttributeError, IndexError): high_temp = '' try: - low_temp = forecast.get('temperatureMin24Hour', '') + low_temp = forecast.get('temperatureMin', [])[0] or '' except (AttributeError, IndexError): low_temp = ''