More time-based Jinja2 custom templates
This commit is contained in:
@ -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 %}
|
@ -2,6 +2,7 @@
|
||||
{# Daily Briefing #}
|
||||
{%- macro getReport() -%}
|
||||
{% from 'speech.jinja' import greeting, dadjoke %}
|
||||
{% from 'time.jinja' import input_datetime_12hr %}
|
||||
<p>
|
||||
{{ greeting() }}
|
||||
</p>
|
||||
@ -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') %}
|
||||
<s>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)) }}. </s>
|
||||
<s>Tina is at work right now. She will be done at approximately {{ input_datetime_12hr('input_datetime.tina_workday_end') }}. </s>
|
||||
{% elif is_state('input_boolean.work_today','on') %}
|
||||
Tina has work today.
|
||||
{% endif %}
|
||||
@ -269,14 +270,14 @@
|
||||
"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('input_boolean.work_today','on') %}
|
||||
{{ [
|
||||
"Tina must go and please the food gods today ",
|
||||
"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 %}
|
||||
|
||||
{% if is_state('input_boolean.tony_streaming_today','on') %}
|
||||
@ -286,7 +287,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 %}
|
||||
|
||||
{% if is_state('input_boolean.kallen_school_today', 'on') %}
|
||||
@ -304,7 +305,7 @@
|
||||
{% if is_state('input_boolean.kallen_alternate_pickup','on') %}
|
||||
{{ states('input_text.kallen_pickup') }} will be picking Collin up from school today.
|
||||
{% else %}
|
||||
<s>Pickup today will be at {{ state_attr('input_datetime.kallen_school_day_end', 'timestamp') | int | timestamp_custom('%I:%M %p', False) }}</s>
|
||||
<s>Pickup today will be at {{ input_datetime_12hr('input_datetime.kallen_school_day_end') }}</s>
|
||||
{% if is_state('input_boolean.kallen_school_early_release','on') %}
|
||||
And It is early release!
|
||||
{% endif %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
>
|
||||
{# Kallen Morning Briefing #}
|
||||
{%- macro getReport() -%}
|
||||
{% from 'time.jinja' import current_time_12hr, current_date_readout %}
|
||||
{% from 'time.jinja' import current_time_12hr, current_date_readout, input_datetime_12hr%}
|
||||
{% from 'speech.jinja' import dadjoke %}
|
||||
<p>
|
||||
Good morning, Collin.
|
||||
@ -87,11 +87,15 @@
|
||||
"And you even get to come home a little earlier today!",
|
||||
] | random }}
|
||||
{% endif %}
|
||||
<s>School today starts at {{ (state_attr('input_datetime.kallen_school_day_start','timestamp') | int | timestamp_custom('%I:%M %p' , False)) }}</s>
|
||||
<s>Pickup today will be at {{(state_attr('input_datetime.kallen_school_day_end', 'timestamp') | int | timestamp_custom('%I:%M %p', False)) }}</s>
|
||||
<s>School today starts at {{ input_datetime_12hr('input_datetime.kallen_school_day_start') }}</s>
|
||||
{% 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 %}
|
||||
<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 -%}
|
||||
But today is the last day of School!
|
||||
{%- endif %}
|
||||
|
@ -1,6 +1,7 @@
|
||||
>
|
||||
{# Kallen School Status #}
|
||||
{%- macro getReport() -%}
|
||||
{% from 'time.jinja' import input_datetime_12hr %}
|
||||
<p>
|
||||
"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 %}
|
||||
</p>
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
{# Morning Briefing #}
|
||||
{%- macro getReport() -%}
|
||||
{% from 'speech.jinja' import greeting_nodate, dadjoke %}
|
||||
{% from 'time.jinja' import input_datetime_12hr %}
|
||||
<p>
|
||||
{{ greeting_nodate() }}
|
||||
</p>
|
||||
@ -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 %}
|
||||
</p>
|
||||
<p>
|
||||
@ -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 %}
|
||||
</p>
|
||||
|
||||
|
@ -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 %}
|
||||
<p>
|
||||
{{ greeting() }}
|
||||
</p>
|
||||
@ -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 %}
|
||||
</p>
|
||||
|
@ -2,6 +2,7 @@
|
||||
{# Welcome Home #}
|
||||
{%- macro getReport() -%}
|
||||
{% from 'speech.jinja' import dadjoke %}
|
||||
{% from 'time.jinja' import input_datetime_12hr %}
|
||||
<p>
|
||||
"Welcome home, "
|
||||
{% if is_state('person.tony_stork','home') and is_state('person.christina_stork','home') %}
|
||||
@ -136,12 +137,12 @@
|
||||
<p>
|
||||
{% 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 %}
|
||||
|
Reference in New Issue
Block a user