Don't announce traffic from school to work when not needed

This commit is contained in:
2022-12-17 14:04:08 -05:00
parent 3baf4ded3f
commit 7be4e7b785

View File

@ -105,18 +105,21 @@
<p> <p>
{% if is_state('input_boolean.school_today','on') and is_state('input_boolean.work_today','on') %} {% 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 %} {%- if states.sensor.home_to_school.state|round > 12 %}
Traffic to the school appears heavier than normal. Traffic to the school appears heavier than normal.
{% else %} {% else %}
Traffic to the school is normal. Traffic to the school is normal.
{% endif %} {% endif %}
Currently it will take {{states.sensor.home_to_school.state|round}} minutes to get to the school. 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 %} {%- if diff <= 3600 %}
Traffic from the school to Bob Evans appears heavier than normal. {%- if states.sensor.school_to_bob_evans.state|round > 15 %}
{% else %} Traffic from the school to Bob Evans appears heavier than normal.
Traffic from the school to Bob Evans is 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 %} {% 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') %} {% elif is_state('input_boolean.work_today','on') %}
{%- if states.sensor.home_to_bob_evans.state|round > 8 %} {%- if states.sensor.home_to_bob_evans.state|round > 8 %}
Traffic to Bob Evans appears heavier than normal. Traffic to Bob Evans appears heavier than normal.