Add easy time macros to relevant TTS briefings

This commit is contained in:
2023-05-03 12:45:41 -04:00
parent e7415c709e
commit a7d9d6ee63
4 changed files with 50 additions and 33 deletions

View File

@ -5,6 +5,7 @@
{% from 'time.jinja' import input_datetime_12hr %} {% from 'time.jinja' import input_datetime_12hr %}
{% from 'status.jinja' import emma_sleep %} {% from 'status.jinja' import emma_sleep %}
{% from 'formatting.jinja' import cleanup %} {% from 'formatting.jinja' import cleanup %}
{% from 'easy_time.jinja' import count_the_days, speak_the_days %}
<p> <p>
{{ greeting() }} {{ greeting() }}
</p> </p>
@ -294,7 +295,7 @@
{% if is_state('input_boolean.kallen_school_today', 'on') %} {% if is_state('input_boolean.kallen_school_today', 'on') %}
{% if is_state('sensor.school_start_days2go', '0') %} {% if is_state('sensor.school_start_days2go', '0') %}
Today is the first day of school! There are {{ states('sensor.school_end_days2go') }} to go until the last day. Today is the first day of school! The last day is {{ speak_the_days('input_datetime.school_last_day') }}.
{% else %} {% else %}
{{ [ 'Today is a school day.', {{ [ 'Today is a school day.',
'Collin has school today.', 'Collin has school today.',
@ -319,42 +320,42 @@
{% if is_state('input_boolean.school_cancelled','on') %} {% if is_state('input_boolean.school_cancelled','on') %}
'School has been cancelled for today. ' 'School has been cancelled for today. '
{% endif %} {% endif %}
{% if states.sensor.thanksgiving_break_days2go.state | int <= 14 and states.sensor.thanksgiving_break_days2go.state | int > 0 %} {% if (count_the_days('input_datetime.thanksgiving_break_start') | int <= 14) and (count_the_days('input_datetime.thanksgiving_break_start') | int > 0) %}
{{ [ 'Oh, and look at that.', {{ [ 'Oh, and look at that.',
'For those trying to keep count. ', 'For those trying to keep count. ',
'In case you were wondering.', 'In case you were wondering.',
'Also, did you know.' 'Also, did you know.'
] | random }} ] | random }}
There are only {{ states.sensor.thanksgiving_break_days2go.state }} days until Thanksgiving Break! 'Thanksgiving break starts {{ speak_the_days('input_datetime.thanksgiving_break_start') }}!'
{% endif %} {% endif %}
{% if states.sensor.christmas_break_days2go.state | int <= 14 and states.sensor.christmas_break_days2go.state | int > 0 %} {% if (count_the_days('input_datetime.christmas_break_start') | int <= 14) and (count_the_days('input_datetime.christmas_break_start') | int > 0) %}
{{ [ 'Oh, and look at that.', {{ [ 'Oh, and look at that.',
'For those trying to keep count. ', 'For those trying to keep count. ',
'In case you were wondering.', 'In case you were wondering.',
'Also, did you know.' 'Also, did you know.'
] | random }} ] | random }}
There are only {{ states.sensor.christmas_break_days2go.state }} days until Christmas Break! 'Christmas break starts {{ speak_the_days('input_datetime.christmas_break_start') }}!'
{% endif %} {% endif %}
{% if states.sensor.spring_break_days2go.state | int <= 14 and states.sensor.spring_break_days2go.state | int > 0 %} {% if (count_the_days('input_datetime.spring_break_start') | int <= 14) and (count_the_days('input_datetime.spring_break_start') | int > 0) %}
{{ [ 'Oh, and look at that.', {{ [ 'Oh, and look at that.',
'For those trying to keep count. ', 'For those trying to keep count. ',
'In case you were wondering.', 'In case you were wondering.',
'Also, did you know.' 'Also, did you know.'
] | random }} ] | random }}
There are only {{ states.sensor.spring_break_days2go.state }} days until Spring Break! 'Spring break starts {{ speak_the_days('input_datetime.spring_break_start') }}!'
{% endif %} {% endif %}
{% if states.sensor.school_end_days2go.state | int <= 35 and states.sensor.school_end_days2go.state | int > 0 %} {% if (count_the_days('input_datetime.school_last_day') | int <= 35) and (count_the_days('input_datetime.school_last_day') | int > 0) %}
{{ [ 'Oh, and look at that.', {{ [ 'Oh, and look at that.',
'For those trying to keep count. ', 'For those trying to keep count. ',
'In case you were wondering.', 'In case you were wondering.',
'Also, did you know.' 'Also, did you know.'
] | random }} ] | random }}
There are only {{ states.sensor.school_end_days2go.state }} days left in the school year! The school year ends {{ speak_the_days('input_datetime.school_last_day') }}.
{% endif %} {% endif %}
{% if now().strftime('%Y-%m-%d') == states.input_datetime.school_last_day.state %} {% if count_the_days('input_datetime.school_last_day') | int == 0 %}
Congratulations, today is the last day of school! Have an awesome day! Congratulations, today is the last day of school! Have an awesome day!
{% endif %} {% endif %}
{% if states.sensor.school_end_days2go.state | int == -1 -%} {% if count_the_days('input_datetime.school_last_day') | int == -1 -%}
Today is the first day of Summer Break! Today is the first day of Summer Break!
{%- endif %} {%- endif %}
{% endif %} {% endif %}

View File

@ -3,6 +3,7 @@
{%- macro getReport() -%} {%- macro getReport() -%}
{% from 'time.jinja' import current_time_12hr, current_date_readout, input_datetime_12hr %} {% from 'time.jinja' import current_time_12hr, current_date_readout, input_datetime_12hr %}
{% from 'speech.jinja' import dadjoke, inspirational_quote %} {% from 'speech.jinja' import dadjoke, inspirational_quote %}
{% from 'easy_time.jinja' import count_the_days, speak_the_days %}
<p> <p>
Good morning, Collin. Good morning, Collin.
@ -47,7 +48,7 @@
<p> <p>
{% if is_state('input_boolean.kallen_school_today', 'on') %} {% if is_state('input_boolean.kallen_school_today', 'on') %}
{% if is_state('sensor.school_start_days2go', '0') %} {% if count_the_days('input_datetime.school_first_day') | int == 0 %}
Today is the first day of school! Today is the first day of school!
{% else %} {% else %}
{{ [ 'Today is a school day.', {{ [ 'Today is a school day.',
@ -96,7 +97,7 @@
Today, you will be picked up from school by your dad. Today, you will be picked up from school by your dad.
{% endif %} {% endif %}
<s>Pickup today will be at {{ input_datetime_12hr('input_datetime.kallen_school_day_end') }}</s> <s>Pickup today will be at {{ input_datetime_12hr('input_datetime.kallen_school_day_end') }}</s>
{% if states.sensor.school_end_days2go.state | int == 0 -%} {% if count_the_days('input_datetime.school_last_day') | int == 0 -%}
But today is the last day of School! But today is the last day of School!
{%- endif %} {%- endif %}
{{ [ {{ [
@ -131,36 +132,49 @@
'Do not let your sister eat you for breakfast.', 'Do not let your sister eat you for breakfast.',
] | random }} ] | random }}
{% endif %} {% endif %}
{% if states.sensor.thanksgiving_break_days2go.state | int <= 14 and states.sensor.thanksgiving_break_days2go.state | int > 0 %} {% if (count_the_days('input_datetime.thanksgiving_break_start') | int <= 14) and (count_the_days('input_datetime.thanksgiving_break_start') | int > 0) %}
{{ [ 'Oh, and look at that.', {{ [ 'Oh, and look at that.',
'For those trying to keep count. ', 'For those trying to keep count. ',
'In case you were wondering.', 'In case you were wondering.',
'Also, did you know.' 'Also, did you know.'
] | random }} ] | random }}
There are only {{ states.sensor.thanksgiving_break_days2go.state }} days until Thanksgiving Break! 'Thanksgiving break starts {{ speak_the_days('input_datetime.thanksgiving_break_start') }}!'
{% endif %} {% endif %}
{% if states.sensor.christmas_break_days2go.state | int <= 14 and states.sensor.christmas_break_days2go.state | int > 0 %} {% if (count_the_days('input_datetime.christmas_break_start') | int <= 14) and (count_the_days('input_datetime.christmas_break_start') | int > 0) %}
{{ [ 'Oh, and look at that.', {{ [ 'Oh, and look at that.',
'For those trying to keep count. ', 'For those trying to keep count. ',
'In case you were wondering.', 'In case you were wondering.',
'Also, did you know.' 'Also, did you know.'
] | random }} ] | random }}
There are only {{ states.sensor.christmas_break_days2go.state }} days until Christmas Break! 'Christmas break starts {{ speak_the_days('input_datetime.christmas_break_start') }}!'
{% endif %} {% endif %}
{% if states.sensor.spring_break_days2go.state | int <= 14 and states.sensor.spring_break_days2go.state | int > 0 %} {% if (count_the_days('input_datetime.spring_break_start') | int <= 14) and (count_the_days('input_datetime.spring_break_start') | int > 0) %}
{{ [ 'Oh, and look at that.', {{ [ 'Oh, and look at that.',
'For those trying to keep count. ', 'For those trying to keep count. ',
'In case you were wondering.', 'In case you were wondering.',
'Also, did you know.' 'Also, did you know.'
] | random }} ] | random }}
There are only {{ states.sensor.spring_break_days2go.state }} days until Spring Break! 'Spring break starts in {{ speak_the_days('input_datetime.spring_break_start') }}!'
{% endif %} {% endif %}
{% if (count_the_days('input_datetime.school_last_day') | int < 35) and (count_the_days('input_datetime.school_last_day') | int > 0) -%}
{{ [ 'School is almost over for the year.',
'You have made it to the end of the school year.',
'You are almost done with school.'
] | random }}
There are only {{ count_the_days('input_datetime.school_last_day') }} days
{{ [ 'left in the school year ',
' left of school.',
'Until the last day of school.'
] | random }}
{%- endif %}
{% if is_state ('input_boolean.kallen_school_today', 'off') and is_state('sensor.pirateweather_icon', 'snow') %} {% if is_state ('input_boolean.kallen_school_today', 'off') and is_state('sensor.pirateweather_icon', 'snow') %}
Do you wanna build a snowman? It is snowing! Do you wanna build a snowman? It is snowing!
{% endif %} {% endif %}
{% if states.sensor.school_end_days2go.state | int == -1 -%}
{% if count_the_days('input_datetime.school_last_day') | int == -1 -%}
Today is the first day of Summer Break! Today is the first day of Summer Break!
{%- endif %} {%- endif %}

View File

@ -2,6 +2,7 @@
{# Kallen Nightly Briefing #} {# Kallen Nightly Briefing #}
{%- macro getReport() -%} {%- macro getReport() -%}
{% from 'speech.jinja' import dadjoke %} {% from 'speech.jinja' import dadjoke %}
{% from 'easy_time.jinja' import count_the_days, speak_the_days %}
<p> <p>
Good Evening, Collin, it is currently {{ now().strftime("%I:%M %p") }}. Good Evening, Collin, it is currently {{ now().strftime("%I:%M %p") }}.
{{ [ 'My sensors are detecting a strange smell. I am running diagnostics. But in the mean time, you should start a shower.', {{ [ 'My sensors are detecting a strange smell. I am running diagnostics. But in the mean time, you should start a shower.',
@ -41,54 +42,54 @@
'so we can sleep in. ' 'so we can sleep in. '
] | random }} ] | random }}
{% endif %} {% endif %}
{% if states.sensor.school_start_days2go.state | int < 10 and states.sensor.school_start_days2go.state | int > 1 -%} {% if (count_the_days('input_datetime.school_first_day') | int < 10) and (count_the_days('input_datetime.school_first_day') | int > 1) -%}
{{ [ 'I hate to say it, but ', {{ [ 'I hate to say it, but ',
'Unfortunately,', 'Unfortunately,',
'All good things must come to an end.' 'All good things must come to an end.'
] | random }} ] | random }}
There are only {{ states.sensor.school_start_days2go.state }} days There are only {{ count_the_days('input_datetime.school_first_day') }} days
{{ [ 'left of summer vacation. ', {{ [ 'left of summer vacation. ',
' left of summer break.', ' left of summer break.',
'Until School starts again.' 'Until School starts again.'
] | random }} ] | random }}
{% elif states.sensor.school_start_days2go.state | int == 0 -%} {% elif count_the_days('input_datetime.school_first_day') | int == 1 -%}
Tomorrow is the first day of school. Are you ready? Tomorrow is the first day of school. Are you ready?
{%- endif %} {%- endif %}
{% if states.sensor.thanksgiving_break_days2go.state | int <= 14 and states.sensor.thanksgiving_break_days2go.state | int > 0 %} {% if (count_the_days('input_datetime.thanksgiving_break_start') | int <= 14) and (count_the_days('input_datetime.thanksgiving_break_start') | int > 0) %}
{{ [ 'Oh, and look at that.', {{ [ 'Oh, and look at that.',
'For those trying to keep count. ', 'For those trying to keep count. ',
'In case you were wondering.', 'In case you were wondering.',
'Also, did you know.' 'Also, did you know.'
] | random }} ] | random }}
There are only {{ states.sensor.thanksgiving_break_days2go.state }} days until Thanksgiving Break! 'Thanksgiving break starts {{ speak_the_days('input_datetime.thanksgiving_break_start') }}!'
{% endif %} {% endif %}
{% if states.sensor.christmas_break_days2go.state | int <= 14 and states.sensor.christmas_break_days2go.state | int > 0 %} {% if (count_the_days('input_datetime.christmas_break_start') | int <= 14) and (count_the_days('input_datetime.christmas_break_start') | int > 0) %}
{{ [ 'Oh, and look at that.', {{ [ 'Oh, and look at that.',
'For those trying to keep count. ', 'For those trying to keep count. ',
'In case you were wondering.', 'In case you were wondering.',
'Also, did you know.' 'Also, did you know.'
] | random }} ] | random }}
There are only {{ states.sensor.christmas_break_days2go.state }} days until Christmas Break! 'Christmas break starts {{ speak_the_days('input_boolean.christmas_break_start') }}!'
{% endif %} {% endif %}
{% if states.sensor.spring_break_days2go.state | int <= 14 and states.sensor.spring_break_days2go.state | int > 0 %} {% if (count_the_days('input_datetime.spring_break_start') | int <= 14) and (count_the_days('input_datetime.spring_break_start') | int > 0) %}
{{ [ 'Oh, and look at that.', {{ [ 'Oh, and look at that.',
'For those trying to keep count. ', 'For those trying to keep count. ',
'In case you were wondering.', 'In case you were wondering.',
'Also, did you know.' 'Also, did you know.'
] | random }} ] | random }}
There are only {{ states.sensor.spring_break_days2go.state }} days until Spring Break! 'Spring break starts {{ speak_the_days('input_datetime.spring_break_start') }}!'
{% endif %} {% endif %}
{% if states.sensor.school_end_days2go.state | int < 15 and states.sensor.school_end_days2go.state | int > 0 -%} {% if (count_the_days('input_datetime.school_last_day') | int < 35) and (count_the_days('input_datetime.school_last_day') | int > 0) -%}
{{ [ 'School is almost over for the year.', {{ [ 'School is almost over for the year.',
'You have made it to the end of the school year.', 'You have made it to the end of the school year.',
'You are almost done with school.' 'You are almost done with school.'
] | random }} ] | random }}
There are only {{ states.sensor.school_end_days2go.state }} days There are only {{ count_the_days('input_datetime.school_last_day') }} days
{{ [ 'left in the school year ', {{ [ 'left in the school year ',
' left of school.', ' left of school.',
'Until the last day of school.' 'Until the last day of school.'
] | random }} ] | random }}
{% elif states.sensor.school_end_days2go.state | int == 0 -%} {% elif count_the_days('input_datetime.school_last_day') | int == 0 -%}
Tomorrow is the first day of summer. Are you ready? Tomorrow is the first day of summer. Are you ready?
{%- endif %} {%- endif %}
{{ [ 'I will turn on your bedroom lights and appropriate white noise device at bedtime.', {{ [ 'I will turn on your bedroom lights and appropriate white noise device at bedtime.',

View File

@ -3,6 +3,7 @@
{%- macro getReport() -%} {%- macro getReport() -%}
{% from 'speech.jinja' import greeting_nodate, dadjoke, inspirational_quote %} {% from 'speech.jinja' import greeting_nodate, dadjoke, inspirational_quote %}
{% from 'time.jinja' import input_datetime_12hr %} {% from 'time.jinja' import input_datetime_12hr %}
{% from 'easy_time.jinja' import count_the_days %}
<p> <p>
{{ greeting_nodate() }} {{ greeting_nodate() }}
</p> </p>
@ -93,7 +94,7 @@
{%- endif -%} {%- endif -%}
</p> </p>
<p> <p>
{% if now().strftime('%Y-%m-%d') == states.input_datetime.school_last_day.state %} {% if count_the_days('input_datetime.school_last_day') | int == 0 %}
Congratulations, today is the last day of school! Have an awesome day! Congratulations, today is the last day of school! Have an awesome day!
{% endif %} {% endif %}
</p> </p>