diff --git a/custom_templates/time.jinja b/custom_templates/time.jinja index f64e853..f4822c7 100644 --- a/custom_templates/time.jinja +++ b/custom_templates/time.jinja @@ -6,6 +6,10 @@ {{ now().strftime("%I:%M %p") }} {% endmacro %} +{% macro input_datetime_12hr(entity) %} +{{ state_attr(entity,'timestamp') | int | timestamp_custom('%I:%M %p', False) }} +{% endmacro %} + {% macro current_date_readout() %} {{ states('sensor.today_is') }}, {{ as_timestamp(now()) | timestamp_custom('%B %d %Y') }} {% endmacro %} @@ -16,4 +20,8 @@ {% macro set_time_from_calendar(calendar,start_or_end) %} {{ as_timestamp(strptime(state_attr(calendar,start_or_end), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }} +{% endmacro %} + +{% macro read_time_from_calendar(calendar,start_or_end) %} +{{ as_timestamp(strptime(state_attr(calendar,start_or_end), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%I:%M %p") }} {% endmacro %} \ No newline at end of file diff --git a/templates/speech/daily_briefing.yaml b/templates/speech/daily_briefing.yaml index f33e338..42329c4 100644 --- a/templates/speech/daily_briefing.yaml +++ b/templates/speech/daily_briefing.yaml @@ -2,6 +2,7 @@ {# Daily Briefing #} {%- macro getReport() -%} {% from 'speech.jinja' import greeting, dadjoke %} + {% from 'time.jinja' import input_datetime_12hr %}
{{ greeting() }}
@@ -147,7 +148,7 @@ {% set tina = states.person.christina_stork.state %} {% if tina in ['Bob Evans','BobEvans'] and is_state('input_boolean.work_today','on') %} -
Good morning, Collin.
@@ -87,11 +87,15 @@
"And you even get to come home a little earlier today!",
] | random }}
{% endif %}
- School today starts at {{ (state_attr('input_datetime.kallen_school_day_start','timestamp') | int | timestamp_custom('%I:%M %p' , False)) }}
- Pickup today will be at {{(state_attr('input_datetime.kallen_school_day_end', 'timestamp') | int | timestamp_custom('%I:%M %p', False)) }}
+ School today starts at {{ input_datetime_12hr('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') %}
+ Today, you will be picked up from school by your parents.
+ {% 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') }}
{% if states.sensor.school_end_days2go.state | 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 e902f12..ba18d90 100644
--- a/templates/speech/kallen_school_status.yaml
+++ b/templates/speech/kallen_school_status.yaml
@@ -1,6 +1,7 @@
>
{# Kallen School Status #}
{%- macro getReport() -%}
+ {% from 'time.jinja' import input_datetime_12hr %}
"Hello Collin, " @@ -20,11 +21,11 @@ {% if is_state('input_boolean.kallen_band_practice','on') %} "You have band practice this morning before school. " {% endif %} - "Your school day will start at {{ (state_attr('input_datetime.kallen_school_day_start','timestamp') | int | timestamp_custom('%I:%M %p' , False)) }}. " + "Your school day will start at {{ input_datetime_12hr('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 {{(state_attr('input_datetime.kallen_school_day_end', 'timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + "Your school day will end at {{ input_datetime_12hr('input_datetime.kallen_school_day_end') }}. " {% endif %}
diff --git a/templates/speech/morning_briefing.yaml b/templates/speech/morning_briefing.yaml index 990f497..4e0af50 100644 --- a/templates/speech/morning_briefing.yaml +++ b/templates/speech/morning_briefing.yaml @@ -2,6 +2,7 @@ {# Morning Briefing #} {%- macro getReport() -%} {% from 'speech.jinja' import greeting_nodate, dadjoke %} + {% from 'time.jinja' import input_datetime_12hr %}{{ greeting_nodate() }}
@@ -103,7 +104,7 @@ "Today, Tina must go and entertain the gremlins known as her customers and coworkers ", "Today, Tina will be owned by our lovely lord and savior, capitalism, starting ", "Tina will attempt to satiate the patron saint of capitalism today " - ] | random }} at {{ (state_attr('input_datetime.tina_workday_start','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. + ] | random }} at {{ input_datetime_12hr('input_datetime.tina_workday_start') }}. {% endif %}@@ -150,7 +151,7 @@ "Tony will be playing video games and yelling into a microphone tonight. ", "Tony will be scraping out the nickels and dimes tonight for the sake of entertainment. ", "Tony is not really all that funny, but tonight he will present himself to a crowd of questionable individuals who seem to think that he is. " - ] | random }} The studio is scheduled to go online at {{ (state_attr('input_datetime.tony_streaming_start_time','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + ] | random }} The studio is scheduled to go online at {{ input_datetime_12hr('input_datetime.tony_streaming_start_time') }}. " {% endif %}
diff --git a/templates/speech/nightly_briefing.yaml b/templates/speech/nightly_briefing.yaml index 40aee86..71c1c2c 100644 --- a/templates/speech/nightly_briefing.yaml +++ b/templates/speech/nightly_briefing.yaml @@ -2,6 +2,7 @@ {# Nightly Briefing #} {%- macro getReport() -%} {% from 'speech.jinja' import greeting, dadjoke %} + {% from 'time.jinja' import input_datetime_12hr, read_time_from_calendar %}{{ greeting() }}
@@ -57,13 +58,13 @@ "Tony will be playing video games and yelling into a microphone tonight. ", "Tony will be scraping out the nickels and dimes tonight for the sake of entertainment. ", "Tony is not really all that funny, but tonight he will present himself to a crowd of questionable individuals who seem to think that he is. " - ] | random }} The studio is scheduled to go online at {{ (state_attr('input_datetime.tony_streaming_start_time','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + ] | random }} The studio is scheduled to go online at {{ input_datetime_12hr('input_datetime.tony_streaming_start_time') }}. " {% endif %} {% if is_state('binary_sensor.kallen_school_tomorrow','on') %} {% if is_state('binary_sensor.kallen_band_tomorrow','on') %} - "Collin has school tomorrow, and there will be band practice in the morning at {{ as_timestamp(strptime(state_attr('calendar.kallen_school_days','start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%I:%M %p") }}. " + "Collin has school tomorrow, and there will be band practice in the morning at {{ read_time_from_calendar('calendar.kallen_school_days','start_time') }}. " {% else %} - "Collin has school tomorrow at {{ as_timestamp(strptime(state_attr('calendar.kallen_school_days','start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%I:%M %p") }}. " + "Collin has school tomorrow at {{ read_time_from_calendar('calendar.kallen_school_days','start_time') }}. " {% endif %} {% else %} "Collin does not have school tomorrow. " @@ -77,7 +78,7 @@ "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 {{ (state_attr('input_datetime.tina_workday_end','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. + ] | random }} she will be done at approximately {{ input_datetime_12hr('input_datetime.tina_workday_end') }}. {% elif is_state('binary_sensor.tina_work_tomorrow','on') %} {{ [ "Tina must go and please the food gods tomorrow ", @@ -169,18 +170,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 {{ (state_attr('input_datetime.master_bedroom_cooling','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + "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') }}. " {% elif is_state('input_select.scheduled_climate_mode_master_bedroom_aircon','AC') %} - "The master bedroom air conditioner will activate cooling mode at {{ (state_attr('input_datetime.master_bedroom_cooling','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + "The master bedroom air conditioner will activate cooling mode at {{ input_datetime_12hr('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 {{ (state_attr('input_datetime.master_bedroom_cooling','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + "The master bedroom air conditioner will activate fan only mode at {{ input_datetime_12hr('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 {{ (state_attr('input_datetime.master_bedroom_fan','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + "The master bedroom fan will activate at {{ input_datetime_12hr('input_datetime.master_bedroom_fan') }}. " {% endif %} {% endif %} {% endif %} @@ -195,9 +196,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 {{ (state_attr('input_datetime.kallen_bedtime','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + "Collin's fan will activate at {{ input_datetime_12hr('input_datetime.kallen_fan') }}. " {% elif is_state('input_select.scheduled_climate_mode_kallen_fan','White Noise') %} - "Collin's white noise generator will activate at {{ (state_attr('input_datetime.kallen_bedtime','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + "Collin's white noise generator will activate at {{ input_datetime_12hr('input_datetime.kallen_bedtime') }}. " {% endif %} {% endif %} {% else %} @@ -208,14 +209,14 @@ "In Emma's bedroom, ", "For Emma's climate scheduling, " ] | random }} - {% if is_state('fan.emma_air_conditioner','on') %} + {% if is_state('fan.emma_air_conditioner','on') and is_state('input_datetime.scheduled_climate_mode_emma_aircon','AC') %} "Emma's air conditioner is already running. " - {% elif is_state('input_boolean.white_noise_emma_bedroom','on') %} + {% elif is_state('input_boolean.white_noise_emma_bedroom','on') and is_state('input_datetime.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 {{ (state_attr('input_datetime.emma_bedtime','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + "Emma's air conditioner will be activated at {{ input_datetime_12hr('input_datetime.emma_bedtime') }}. " {% elif is_state('input_select.scheduled_climate_mode_emma_aircon','White Noise') %} - "Emma's white noise generator will activate at {{ (state_attr('input_datetime.emma_bedtime','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + "Emma's white noise generator will activate at {{ input_datetime_12hr('input_datetime.emma_bedtime') }}. " {% endif %} {% endif %} diff --git a/templates/speech/welcome_home.yaml b/templates/speech/welcome_home.yaml index 481e8eb..6f3a91a 100644 --- a/templates/speech/welcome_home.yaml +++ b/templates/speech/welcome_home.yaml @@ -2,6 +2,7 @@ {# Welcome Home #} {%- macro getReport() -%} {% from 'speech.jinja' import dadjoke %} + {% from 'time.jinja' import input_datetime_12hr %}"Welcome home, " {% if is_state('person.tony_stork','home') and is_state('person.christina_stork','home') %} @@ -136,12 +137,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 {{ (state_attr('input_datetime.tina_workday_end','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + "Tina is at work right now. She will be done at approximately {{ input_datetime_12hr('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 {{ (state_attr('input_datetime.kallen_school_day_end','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + "Kallen is at school right now. His pickup time will be at {{ input_datetime_12hr('input_datetime.kallen_school_day_end') }}. " {% elif is_state('input_boolean.kallen_school_today','on') %} "Kallen has school today. " {% endif %}