From cb2aea41139daaabc24b2e060492e2aa46569aff Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sat, 13 Aug 2022 23:41:00 +0200 Subject: [PATCH] On evening, if rain is expected next day, display it --- modules/weather.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/weather.py b/modules/weather.py index 943cea6..76667b9 100644 --- a/modules/weather.py +++ b/modules/weather.py @@ -182,7 +182,11 @@ class WeatherSunMoonModule: class WeatherRainModule: def draw_module(self, config, width, height): - thisdayweather = WeatherAPI().get_daily()["data"][0] + if datetime.now().hour >= 21: + thisdayweather = WeatherAPI().get_daily()["data"][1] + else: + thisdayweather = WeatherAPI().get_daily()["data"][0] + gauge = pygal.SolidGauge(half_pie=True, inner_radius=0.70, width=width, height=height*1.55, style=config.pygal_custom_style, show_legend=False, margin_top=-height*0.58, margin_left=1, margin_right=1) percent_formatter = lambda x: '{:.10g}%'.format(x) @@ -212,7 +216,11 @@ class WeatherTemperatureModule: self.limit_futur = 30 def draw_module(self, config, width, height): - thisdayweather = WeatherAPI().get_daily()["data"][0] + thisdayweather = WeatherAPI().get_daily()["data"] + if datetime.now().hour >= 19 and thisdayweather[1]["precipProbability"] > thisdayweather[0]["precipProbability"]: + thisdayweather = thisdayweather[1] + else: + thisdayweather = thisdayweather[0] line_chart = pygal.Line(interpolate='cubic', width=width, height=height, inverse_y_axis=False, x_label_rotation=45, secondary_range=(0,100) if thisdayweather["precipProbability"] > 0 else (0,10), **config.charts_opts) line_chart.value_formatter = lambda x: "%d" % x