On evening, if rain is expected next day, display it

This commit is contained in:
nemunaire 2022-08-13 23:41:00 +02:00
parent af4730a964
commit cb2aea4113

View File

@ -182,8 +182,12 @@ class WeatherSunMoonModule:
class WeatherRainModule:
def draw_module(self, config, width, height):
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)
gauge.value_formatter = percent_formatter
@ -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