Fix display of alerts when no alert

This commit is contained in:
nemunaire 2022-08-11 16:35:37 +02:00
parent 9c3a3ff3c4
commit 1126693b38

View File

@ -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