diff --git a/custom_templates/status.jinja b/custom_templates/status.jinja index 2c69f39..e155789 100644 --- a/custom_templates/status.jinja +++ b/custom_templates/status.jinja @@ -1,11 +1,11 @@ -{% from 'time.jinja' import input_datetime_12hr, input_datetime_12hr_with_date, ct, next_twitch_stream, calendar_event_today, read_time_from_calendar %} +{% from 'time.jinja' import input_datetime_read, ct, next_twitch_stream, calendar_event_today, read_time_from_calendar %} {% from 'easy_time.jinja' import count_the_days, custom_time, custom_time_between, clock %} {% set ct = ct() | int %} {% macro tony_morning_meds(method) %} {% if is_state('binary_sensor.overnight','off') %} {% if is_state('input_boolean.tony_morning_meds_taken','on') %} - Tony took his morning meds at {{ input_datetime_12hr_with_date('input_datetime.tony_morning_meds_taken') }} today. + Tony took his morning meds at {{ input_datetime_read('input_datetime.tony_morning_meds_taken','withdate') }} today. {% elif is_state('input_boolean.tony_morning_meds_taken','off') and ct >= 21600 %} Tony has not taken his morning meds. {% if ct < state_attr('input_datetime.tony_morning_meds_notify','timestamp') | int %} @@ -14,9 +14,9 @@ 'Rest assured that I will pester him mercilessly about this, starting at', 'This is absolutely essential, and I will remind him to do it at', 'Since nobody including Tony himself likes him without his meds, I will remind him at', - ] | random }} {{ input_datetime_12hr('input_datetime.tony_morning_meds_notify') }} today. + ] | random }} {{ input_datetime_read('input_datetime.tony_morning_meds_notify') }} today. {% else %} - He will be reminded at {{ input_datetime_12hr('input_datetime.tony_morning_meds_notify') }} today. + He will be reminded at {{ input_datetime_read('input_datetime.tony_morning_meds_notify') }} today. {% endif %} {% endif %} {% endif %} @@ -25,7 +25,7 @@ {% macro tony_night_meds(method) %} {% if is_state('input_boolean.tony_night_meds_taken','on') and ct < 43200 %} - Tony took his night meds at {{ input_datetime_12hr_with_date('input_datetime.tony_night_meds_taken') }} today. + Tony took his night meds at {{ input_datetime_read('input_datetime.tony_night_meds_taken','withdate') }} today. {% elif is_state('input_boolean.tony_night_meds_taken','off') and (ct >= 82800 or ct <= 21600) %} Tony has not taken his night meds. {% if method == 'tts' %} @@ -101,7 +101,7 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr "Tina has not yet been released from work, ", "Tina is still at the thankless idiot scape known as work, ", "Tina is still consumed by the gods of capitalism, ", - ] | random }} she will be done at approximately {{ input_datetime_12hr('input_datetime.tina_workday_end') }}. + ] | random }} she will be done at approximately {{ input_datetime_read('input_datetime.tina_workday_end') }}. {% elif is_state('binary_sensor.evening','on') %} {% if is_state('binary_sensor.tina_work_tomorrow','on') %} {{ [ @@ -126,7 +126,7 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr "Today, Tina must go and entertain the gremlins known as her customers and coworkers ", "Today, Tina will be owned and operated by our lovely lord and savior capitalism starting ", "Tina will attempt to satiate the patron saint of capitalism today " - ] | random }} at {{ input_datetime_12hr('input_datetime.tina_workday_start') }}. + ] | random }} at {{ input_datetime_read('input_datetime.tina_workday_start') }}. {% else %} {{ [ "Tina seems to have been granted a reprieve from her endless torture today. ", @@ -140,9 +140,9 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr {% endif %} {% elif method == 'text' %} {% if tina in ['Bob Evans','BobEvans'] and is_state('input_boolean.work_today','on') %} - Tina is at work right now. She will be done at approximately {{ input_datetime_12hr('input_datetime.tina_workday_end') }} today. + Tina is at work right now. She will be done at approximately {{ input_datetime_read('input_datetime.tina_workday_end') }} today. {% elif is_state('input_boolean.work_today','on') %} - Tina has work at {{ input_datetime_12hr('input_datetime.tina_workday_start') }} today. + Tina has work at {{ input_datetime_read('input_datetime.tina_workday_start') }} today. {% elif is_state('input_boolean.work_today_extended','on') and is_state('input_boolean.work_today','off') %} Tina has finished work for the day. {% if is_state('binary_sensor.tina_work_tomorrow','on') %} @@ -157,7 +157,7 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr {% macro tina_morning_meds(method) %} {% if is_state('binary_sensor.overnight','off') %} {% if is_state('input_boolean.tina_morning_meds_taken','on') %} - Tina took her morning meds at {{ input_datetime_12hr_with_date('input_datetime.tina_morning_meds_taken') }} today. + Tina took her morning meds at {{ input_datetime_read('input_datetime.tina_morning_meds_taken','withdate') }} today. {% elif is_state('input_boolean.tina_morning_meds_taken','off') and is_state('binary_sensor.after_midnight','off') %} Tina has not taken her morning meds. {% if ct < state_attr('input_datetime.tina_morning_meds_notify','timestamp') | int %} @@ -166,9 +166,9 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr 'Rest assured that I will pester her mercilessly about this, starting at', 'This is absolutely essential, and I will remind her to do it at', 'Her blood pressure is very important, so I will remind her at', - ] | random }} {{ input_datetime_12hr('input_datetime.tina_morning_meds_notify') }} today. + ] | random }} {{ input_datetime_read('input_datetime.tina_morning_meds_notify') }} today. {% else %} - She will be reminded at {{ input_datetime_12hr('input_datetime.tina_morning_meds_notify') }} today. + She will be reminded at {{ input_datetime_read('input_datetime.tina_morning_meds_notify') }} today. {% endif %} {% endif %} {% endif %} @@ -199,14 +199,14 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr {% endif %} {% if wakeup <= ct <= bedtime %} {% if is_state('input_boolean.kallen_morning_meds_taken','on') %} - Kallen took his morning meds at {{ input_datetime_12hr_with_date('input_datetime.kallen_morning_meds_taken') }} today. + Kallen took his morning meds at {{ input_datetime_read('input_datetime.kallen_morning_meds_taken','withdate') }} today. {% else %} Kallen has not taken his morning meds. {% if ct < state_attr('input_datetime.kallen_morning_meds_notify','timestamp') | int %} {{ ['He has a reminder scheduled for', 'Rest assured that I will pester him mercilessly about this, starting at', 'This is absolutely essential, and I will remind him to do it at', - ] | random }} {{ input_datetime_12hr('input_datetime.kallen_morning_meds_notify') }} today. + ] | random }} {{ input_datetime_read('input_datetime.kallen_morning_meds_notify') }} today. {% endif %} {% endif %} {% endif %} @@ -222,7 +222,7 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr {% set diff = bedtime - ct %} {% if is_state('input_boolean.kallen_night_meds_taken','on') %} {% if (ct >= bedtime) or (ct < wakeup) %} - Kallen took his night meds at {{ input_datetime_12hr_with_date('input_datetime.kallen_night_meds_taken') }} tonight. + Kallen took his night meds at {{ input_datetime_read('input_datetime.kallen_night_meds_taken','withdate') }} tonight. {% endif %} {% else %} {% if diff <= 3600 %} @@ -263,7 +263,7 @@ Kallen is staying elsewhere overnight. {% if is_state('input_boolean.kallen_alternate_pickup','on') %} {{ states('input_text.kallen_pickup') }} will be picking Collin up from school today. {% else %} - Pickup today will be at {{ input_datetime_12hr('input_datetime.kallen_school_day_end') }}. + Pickup today will be at {{ input_datetime_read('input_datetime.kallen_school_day_end') }}. {% if is_state('input_boolean.kallen_school_early_release','on') %} And It is early release! {% endif %} @@ -323,12 +323,12 @@ Kallen is staying elsewhere overnight. {% if is_state('input_boolean.kallen_alternate_pickup','on') %} {{ states('input_text.kallen_pickup') }} will be picking him up from school today. {% elif is_state('input_boolean.kallen_school_early_release','on') %} - The school is on an early release schedule, pickup is at {{ input_datetime_12hr('input_datetime.kallen_school_day_end') }} today. + The school is on an early release schedule, pickup is at {{ input_datetime_read('input_datetime.kallen_school_day_end') }} today. {% else %} - His pickup time is {{ input_datetime_12hr('input_datetime.kallen_school_day_end') }} today. + His pickup time is {{ input_datetime_read('input_datetime.kallen_school_day_end') }} today. {% endif %} {% else %} - Kallen has school at {{ input_datetime_12hr('input_datetime.kallen_school_day_start') }} today. + Kallen has school at {{ input_datetime_read('input_datetime.kallen_school_day_start') }} today. {% endif %} {% elif is_state('input_boolean.school_cancelled','on') %} School is cancelled today for Kallen. @@ -346,14 +346,14 @@ Kallen is staying elsewhere overnight. {% macro kallenSleep(method) %} {% set bedtimestamp = state_attr('input_datetime.kallen_bedtime','timestamp') | int %} {% if is_state('input_boolean.kallen_sleeping','on') %} - Kallen went to bed at {{ input_datetime_12hr('input_datetime.kallen_bedtime') }} tonight. + Kallen went to bed at {{ input_datetime_read('input_datetime.kallen_bedtime') }} tonight. {% if 14400 < ct < bedtimestamp %} - His scheduled wakeup time is {{ input_datetime_12hr('input_datetime.kallen_wakeup_time') }} today. + His scheduled wakeup time is {{ input_datetime_read('input_datetime.kallen_wakeup_time') }} today. {% endif %} {% else %} - Kallen woke up at {{ input_datetime_12hr('input_datetime.kallen_wakeup_time') }} today. + Kallen woke up at {{ input_datetime_read('input_datetime.kallen_wakeup_time') }} today. {% if ct > 57600 %} - His scheduled bedtime is {{ input_datetime_12hr('input_datetime.kallen_bedtime') }} tonight. + His scheduled bedtime is {{ input_datetime_read('input_datetime.kallen_bedtime') }} tonight. {% endif %} {% endif %} {% endmacro %} @@ -379,9 +379,9 @@ Kallen is staying elsewhere overnight. {% set asleep_day = asleep | timestamp_custom("%-d") %} {% set wakeup_day = wakeup | timestamp_custom("%-d") %} {% if is_state('input_boolean.emma_sleeping','off') and is_state('input_boolean.emma_has_napped','on') or ((asleep_day == day) and (wakeup_day == day)) %} - Emma napped today for {{ custom_time_between('input_datetime.emma_down_for_nap','input_datetime.emma_up_from_nap','hour,minute') }}. She was retrieved from her room at {{ input_datetime_12hr_with_date('input_datetime.emma_up_from_nap') }} approximately. + Emma napped today for {{ custom_time_between('input_datetime.emma_down_for_nap','input_datetime.emma_up_from_nap','hour,minute') }}. She was retrieved from her room at {{ input_datetime_read('input_datetime.emma_up_from_nap') }} approximately. {% elif is_state('input_boolean.emma_has_napped','off') and ((asleep_day == day) and (wakeup_day != day)) and is_state('input_boolean.emma_sleeping','on') %} - Emma is down for nap. She was put down at {{ input_datetime_12hr_with_date('input_datetime.emma_down_for_nap') }} approximately. She has been asleep for {{ custom_time('input_datetime.emma_down_for_nap','hour,minute') }}. + Emma is down for nap. She was put down at {{ input_datetime_read('input_datetime.emma_down_for_nap','withdate') }} approximately. She has been asleep for {{ custom_time('input_datetime.emma_down_for_nap','hour,minute') }}. {% elif is_state('input_boolean.emma_sleeping','on') %} {% if is_state('binary_sensor.early_night_mode','on') %} Emma is asleep for the night. @@ -389,7 +389,7 @@ Kallen is staying elsewhere overnight. Emma has not yet awoken for the day. {% endif %} {% else %} - Emma is awake, and does not appear to have napped yet. She woke up at {{ input_datetime_12hr('input_datetime.emma_wakeup') }} today. + Emma is awake, and does not appear to have napped yet. She woke up at {{ input_datetime_read('input_datetime.emma_wakeup') }} today. {% endif %} {% endmacro %} diff --git a/custom_templates/time.jinja b/custom_templates/time.jinja index dcc7965..ccd2d22 100644 --- a/custom_templates/time.jinja +++ b/custom_templates/time.jinja @@ -16,12 +16,16 @@ {{ now().strftime('%Y-%m-%d') }} {% endmacro %} -{% macro input_datetime_12hr(entity) %} +{% macro input_datetime_read(entity,type) %} +{% if type is defined %} + {% if type == 'withdate' %} + {{ state_attr(entity,'timestamp') | int | timestamp_custom('%-I:%M %p') }} + {% elif type == 'nodate' %} + {{ state_attr(entity,'timestamp') | int | timestamp_custom('%-I:%M %p', False) }} + {% endif %} +{% else %} {{ state_attr(entity,'timestamp') | int | timestamp_custom('%-I:%M %p', False) }} -{% endmacro %} - -{% macro input_datetime_12hr_with_date(entity) %} -{{ state_attr(entity,'timestamp') | int | timestamp_custom('%-I:%M %p') }} +{% endif %} {% endmacro %} {% macro current_date_readout() %} diff --git a/templates/speech/daily_briefing.yaml b/templates/speech/daily_briefing.yaml index ac473b1..270c354 100644 --- a/templates/speech/daily_briefing.yaml +++ b/templates/speech/daily_briefing.yaml @@ -2,7 +2,6 @@ {# Daily Briefing #} {%- macro getReport() -%} {% from 'speech.jinja' import greeting, dadjoke, inspirational_quote %} - {% from 'time.jinja' import input_datetime_12hr %} {% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %} {% from 'easy_time.jinja' import count_the_days %} {% from 'weather.jinja' import weatherReport %} diff --git a/templates/speech/kallen_morning_briefing.yaml b/templates/speech/kallen_morning_briefing.yaml index 1227a9d..479ef10 100644 --- a/templates/speech/kallen_morning_briefing.yaml +++ b/templates/speech/kallen_morning_briefing.yaml @@ -1,7 +1,7 @@ > {# Kallen Morning Briefing #} {%- macro getReport() -%} - {% from 'time.jinja' import current_time, current_date_readout, input_datetime_12hr %} + {% from 'time.jinja' import current_time, current_date_readout, input_datetime_read %} {% from 'speech.jinja' import dadjoke, inspirational_quote %} {% from 'easy_time.jinja' import count_the_days, custom_time %}
@@ -81,7 +81,7 @@
"And you even get to come home a little earlier today!",
] | random }}
{% endif %}
- School today starts at {{ input_datetime_12hr('input_datetime.kallen_school_day_start') }}
+ School today starts at {{ input_datetime_read('input_datetime.kallen_school_day_start') }}
{% if is_state('input_boolean.kallen_alternate_pickup','on') %}
Today, you will be picked up from school by {{ states('input_text.kallen_pickup') }}.
{% elif is_state('input_boolean.work_today','off') %}
@@ -89,7 +89,7 @@
{% else %}
Today, you will be picked up from school by your dad.
{% endif %}
- Pickup today will be at {{ input_datetime_12hr('input_datetime.kallen_school_day_end') }}
+ Pickup today will be at {{ input_datetime_read('input_datetime.kallen_school_day_end') }}
{% if count_the_days('input_datetime.school_last_day') | int == 0 -%}
But today is the last day of School!
{%- endif %}
diff --git a/templates/speech/kallen_school_status.yaml b/templates/speech/kallen_school_status.yaml
index 51d4eb9..1a26102 100644
--- a/templates/speech/kallen_school_status.yaml
+++ b/templates/speech/kallen_school_status.yaml
@@ -1,7 +1,7 @@
>
{# Kallen School Status #}
{%- macro getReport() -%}
- {% from 'time.jinja' import input_datetime_12hr %}
+ {% from 'time.jinja' import input_datetime_read %}
"Hello Collin, " @@ -18,11 +18,11 @@ {% endif %} {% if is_state('input_boolean.kallen_school_today','on') %} - "Your school day will start at {{ input_datetime_12hr('input_datetime.kallen_school_day_start') }}. " + "Your school day will start at {{ input_datetime_read('input_datetime.kallen_school_day_start') }}. " {% if is_state('input_boolean.kallen_school_early_release','on') %} "There will be early dismissal today. " {% endif %} - "Your school day will end at {{ input_datetime_12hr('input_datetime.kallen_school_day_end') }}. " + "Your school day will end at {{ input_datetime_read('input_datetime.kallen_school_day_end') }}. " {% endif %}
diff --git a/templates/speech/morning_briefing.yaml b/templates/speech/morning_briefing.yaml index 667a3ab..9bd01fc 100644 --- a/templates/speech/morning_briefing.yaml +++ b/templates/speech/morning_briefing.yaml @@ -2,7 +2,6 @@ {# Morning Briefing #} {%- macro getReport() -%} {% from 'speech.jinja' import greeting_nodate, dadjoke, inspirational_quote %} - {% from 'time.jinja' import input_datetime_12hr %} {% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %} {% from 'easy_time.jinja' import count_the_days %} {% from 'weather.jinja' import weatherReport %} diff --git a/templates/speech/nightly_briefing.yaml b/templates/speech/nightly_briefing.yaml index 62a45dd..a174e49 100644 --- a/templates/speech/nightly_briefing.yaml +++ b/templates/speech/nightly_briefing.yaml @@ -2,7 +2,7 @@ {# Nightly Briefing #} {%- macro getReport() -%} {% from 'speech.jinja' import greeting, dadjoke, inspirational_quote %} - {% from 'time.jinja' import input_datetime_12hr, read_time_from_calendar, next_twitch_stream %} + {% from 'time.jinja' import input_datetime_read, read_time_from_calendar, next_twitch_stream %} {% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %} {% from 'easy_time.jinja' import count_the_days %} {% from 'weather.jinja' import weatherReport %} @@ -105,18 +105,18 @@ {% elif states('climate.master_bedroom_aircon') not in ['off','unknown','unavailable'] %} "The master bedroom air conditioner is already running in {{ states('climate.master_bedroom_aircon') }} mode. " {% elif is_state('input_select.scheduled_climate_mode_master_bedroom_aircon','AC') and is_state('input_boolean.hot_day','on') %} - "Today was a hot day, so the master bedroom air conditioner will activate cooling mode a bit earlier tonight at {{ input_datetime_12hr('input_datetime.master_bedroom_cooling') }}. " + "Today was a hot day, so the master bedroom air conditioner will activate cooling mode a bit earlier tonight at {{ input_datetime_read('input_datetime.master_bedroom_cooling') }}. " {% elif is_state('input_select.scheduled_climate_mode_master_bedroom_aircon','AC') %} - "The master bedroom air conditioner will activate cooling mode at {{ input_datetime_12hr('input_datetime.master_bedroom_cooling') }}. " + "The master bedroom air conditioner will activate cooling mode at {{ input_datetime_read('input_datetime.master_bedroom_cooling') }}. " {% elif is_state('input_select.scheduled_climate_mode_master_bedroom_aircon','Fan') %} - "The master bedroom air conditioner will activate fan only mode at {{ input_datetime_12hr('input_datetime.master_bedroom_cooling') }}. " + "The master bedroom air conditioner will activate fan only mode at {{ input_datetime_read('input_datetime.master_bedroom_cooling') }}. " {% endif %} {% endif %} {% if states('input_select.scheduled_climate_mode_master_bedroom_fan') != 'N/A' %} {% if is_state('fan.master_bedroom_fan','on') %} "The master bedroom fan is already running. " {% else %} - "The master bedroom fan will activate at {{ input_datetime_12hr('input_datetime.master_bedroom_fan') }}. " + "The master bedroom fan will activate at {{ input_datetime_read('input_datetime.master_bedroom_fan') }}. " {% endif %} {% endif %} {% endif %} @@ -131,9 +131,9 @@ {% elif is_state('input_boolean.white_noise_kallen_bedroom','on') %} "Collin's white noise generator is already running. " {% elif is_state('input_select.scheduled_climate_mode_kallen_fan','Fan') %} - "Collin's fan will activate at {{ input_datetime_12hr('input_datetime.kallen_fan') }}. " + "Collin's fan will activate at {{ input_datetime_read('input_datetime.kallen_fan') }}. " {% elif is_state('input_select.scheduled_climate_mode_kallen_fan','White Noise') %} - "Collin's white noise generator will activate at {{ input_datetime_12hr('input_datetime.kallen_bedtime') }}. " + "Collin's white noise generator will activate at {{ input_datetime_read('input_datetime.kallen_bedtime') }}. " {% endif %} {% endif %} {% else %} @@ -149,9 +149,9 @@ {% elif is_state('input_boolean.white_noise_emma_bedroom','on') and is_state('input_select.scheduled_climate_mode_emma_aircon','White Noise') %} "Emma's white noise generator is already running. " {% elif is_state('input_select.scheduled_climate_mode_emma_aircon','AC') %} - "Emma's air conditioner will be activated at {{ input_datetime_12hr('input_datetime.emma_bedtime') }}. " + "Emma's air conditioner will be activated at {{ input_datetime_read('input_datetime.emma_bedtime') }}. " {% elif is_state('input_select.scheduled_climate_mode_emma_aircon','White Noise') %} - "Emma's white noise generator will activate at {{ input_datetime_12hr('input_datetime.emma_bedtime') }}. " + "Emma's white noise generator will activate at {{ input_datetime_read('input_datetime.emma_bedtime') }}. " {% endif %} {% endif %} diff --git a/templates/speech/welcome_home.yaml b/templates/speech/welcome_home.yaml index 1692d8a..b7b10bc 100644 --- a/templates/speech/welcome_home.yaml +++ b/templates/speech/welcome_home.yaml @@ -2,7 +2,7 @@ {# Welcome Home #} {%- macro getReport() -%} {% from 'speech.jinja' import dadjoke %} - {% from 'time.jinja' import input_datetime_12hr %} + {% from 'time.jinja' import input_datetime_read %} {% from 'status.jinja' import emma_sleep %} {% from 'easy_time.jinja' import count_the_days %}@@ -134,12 +134,12 @@
{% set tina = states.person.christina_stork.state %} {% if tina in ['Bob Evans','BobEvans'] and is_state('input_boolean.work_today','on') %} - "Tina is at work right now. She will be done at approximately {{ input_datetime_12hr('input_datetime.tina_workday_end') }}. " + "Tina is at work right now. She will be done at approximately {{ input_datetime_read('input_datetime.tina_workday_end') }}. " {% elif is_state('input_boolean.work_today','on') %} "Tina has work today. " {% endif %} {% if is_state('input_boolean.kallen_at_school','on') %} - "Kallen is at school right now. His pickup time will be at {{ input_datetime_12hr('input_datetime.kallen_school_day_end') }}. " + "Kallen is at school right now. His pickup time will be at {{ input_datetime_read('input_datetime.kallen_school_day_end') }}. " {% elif is_state('input_boolean.kallen_school_today','on') %} "Kallen has school today. " {% endif %}