From 1126693b383cba555027afa931491ab58bf00663 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Thu, 11 Aug 2022 16:35:37 +0200 Subject: [PATCH] Fix display of alerts when no alert --- modules/weather.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/weather.py b/modules/weather.py index 628b27a..f241fe8 100644 --- a/modules/weather.py +++ b/modules/weather.py @@ -274,6 +274,7 @@ class WeatherAlertsModule: def draw_module(self, config, width, height): image = Image.new('RGBA', (width, height), "#000") draw = ImageDraw.Draw(image) + align = 0 if WeatherAPI().has_alerts(): alerts = WeatherAPI().get_alerts() @@ -281,9 +282,9 @@ class WeatherAlertsModule: fnt_R = ImageFont.truetype(config.fnt_R_path, 16) fnt_B = ImageFont.truetype(config.fnt_RB_path, 16) - align = 7 + align = 10 for alert in alerts: - if alert["severity"] == "watch": + if alert["severity"] == "watch" or alert["title"].startswith("Moderate"): icon = "wi-small-craft-advisory.png" elif alert["severity"] == "warning": icon = "wi-gale-warning.png" @@ -328,6 +329,6 @@ class WeatherAlertsModule: font=fnt_R )[1] - image = image.crop((0,0,width, align)) + image = image.crop((0,0,width, align)) return image