From 1a706153a8ef09b42ab0bf4dc70fba3e2ce015a1 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Thu, 26 Jun 2025 17:27:26 -0400 Subject: [PATCH] Fix handling of MLB rain delays, close #252 --- custom_templates/sports.jinja | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/custom_templates/sports.jinja b/custom_templates/sports.jinja index a43e32e..3464d87 100644 --- a/custom_templates/sports.jinja +++ b/custom_templates/sports.jinja @@ -27,8 +27,15 @@ {% set period_str = period_str(team) %} {% set game_clock = state_attr(team,'clock') | lower %} {% if state_attr(team,'league') == 'MLB' %} - {% set inning_parts = game_clock.split(' ') %} - in the {{ inning_parts[0] ~ ' of the ' ~ inning_parts[1] ~ ' ' ~ period_str }} + {% if 'rain delay' in game_clock %} + {# Handle cases like "Rain Delay, Top 1st" #} + {% set status, inning = game_clock.split(',', 1) %} + {% set inning_parts = inning.split(' ') %} + in a {{ status | trim }} in the {{ inning_parts[1] ~ ' of the ' ~ inning_parts[2] }} {{ period_str }} + {% else %} + {% set inning_parts = game_clock.split(' ') %} + in the {{ inning_parts[0] ~ ' of the ' ~ inning_parts[1] ~ ' ' ~ period_str }} + {% endif %} {% else %} {% if ' - ' in game_clock %} {% set clock_time, quarter = game_clock.split(' - ') %}