From 7be4e7b7857311ea38a60488a9151eaed4136efc Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Sat, 17 Dec 2022 14:04:08 -0500 Subject: [PATCH] Don't announce traffic from school to work when not needed --- templates/speech/morning_briefing.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/templates/speech/morning_briefing.yaml b/templates/speech/morning_briefing.yaml index ad52b6f..3da63b8 100644 --- a/templates/speech/morning_briefing.yaml +++ b/templates/speech/morning_briefing.yaml @@ -105,18 +105,21 @@

{% if is_state('input_boolean.school_today','on') and is_state('input_boolean.work_today','on') %} + {% set diff = (state_attr('input_datetime.tina_workday_start','timestamp') - state_attr('input_datetime.school_day_start','timestamp')) %} {%- if states.sensor.home_to_school.state|round > 12 %} Traffic to the school appears heavier than normal. {% else %} Traffic to the school is normal. {% endif %} Currently it will take {{states.sensor.home_to_school.state|round}} minutes to get to the school. - {%- if states.sensor.school_to_bob_evans.state|round > 15 %} - Traffic from the school to Bob Evans appears heavier than normal. - {% else %} - Traffic from the school to Bob Evans is normal. + {%- if diff <= 3600 %} + {%- if states.sensor.school_to_bob_evans.state|round > 15 %} + Traffic from the school to Bob Evans appears heavier than normal. + {% else %} + Traffic from the school to Bob Evans is normal. + {% endif %} + Currently it will take {{states.sensor.school_to_bob_evans.state|round}} minutes to get to Bob Evans from the school. {% endif %} - Currently it will take {{states.sensor.school_to_bob_evans.state|round}} minutes to get to Bob Evans from the school. {% elif is_state('input_boolean.work_today','on') %} {%- if states.sensor.home_to_bob_evans.state|round > 8 %} Traffic to Bob Evans appears heavier than normal.