Template macros

This commit is contained in:
2023-04-05 20:08:52 -04:00
parent bb37a240d0
commit 2ec072af86
12 changed files with 111 additions and 84 deletions

View File

@ -1,35 +1,10 @@
>
{# Daily Briefing #}
{%- macro getReport() -%}
{% from 'speech.jinja' import greeting %}
<p>
{% if now().strftime('%H')|int < 12 %}
{{ [
"Good morning. ",
"Top of the morning to you laddy. ",
] | random }}
{% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %}
{{ [
"Greetings earthling. ",
"Good afternoon. ",
"How do you do, fellow kids? ",
] | random }}
{% else %}
{{ [
"Good evening. ",
"The grandest of evenings to you. "
] | random }}
{% endif %}
{{ greeting() }}
</p>
{% if is_state('binary_sensor.morning','on') %}
<p>
Today is {{ states.sensor.today_is.state }}, {{ as_timestamp(now()) | timestamp_custom('%B %d %Y') }}.
</p>
{% else %}
<p>
It is {{ now().strftime("%I:%M %p") }}.
</p>
{% endif %}
<p>
{% if is_state('input_boolean.tornado_alarm','on') %}

View File

@ -1,13 +1,14 @@
>
{# Kallen Morning Briefing #}
{%- macro getReport() -%}
{% from 'time.jinja' import current_time_12hr, current_date_readout %}
<p>
Good morning, Collin.
{% if is_state('binary_sensor.morning','on') %}
<s>Today is {{ states.sensor.today_is.state }}, {{ as_timestamp(now()) | timestamp_custom('%B %d %Y') }}.</s>
<s>Today is {{ current_date_readout() }}.</s>
{% else %}
<s>It is {{ now().strftime("%I:%M %p") }}.</s>
<s>It is {{ current_time_12hr() }}.</s>
{% endif %}
{% if is_state('sensor.anniversary_kallen_s_birthday', '0') %}

View File

@ -1,36 +1,9 @@
>
{# Morning Briefing #}
{%- macro getReport() -%}
{% from 'speech.jinja' import greeting_nodate %}
<p>
{% if now().strftime('%H')|int < 12 and now().strftime('%H')|int > 6 %}
{{ [
"Good morning. ",
"Top of the morning to you laddy. ",
] | random }}
{% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %}
{{ [
"Greetings earthling. ",
"Good afternoon. ",
"How do you do, fellow kids? ",
] | random }}
{% else %}
{{ [
"Good evening. ",
"The grandest of evenings to you. "
] | random }}
{% endif %}
</p>
<p>
{% if is_state('binary_sensor.morning','on') %}
<p>
Today is {{ states.sensor.today_is.state }}, {{ as_timestamp(now()) | timestamp_custom('%B %d %Y') }}.
</p>
{% else %}
<p>
It is {{ now().strftime("%I:%M %p") }}.
</p>
{% endif %}
{{ greeting_nodate() }}
</p>
<p>
{{ [

View File

@ -1,8 +1,11 @@
>
{# Nightly Briefing #}
{%- macro getReport() -%}
{% from 'speech.jinja' import greeting %}
<p>
{{ greeting() }}
</p>
<p>
"Good evening. It is {{ now().strftime("%I:%M %p") }}. "
{{ [
"Before the day comes to a close, here are my thoughts. Just kidding, I am a computer, I do not think. ",
"The day grows short, let us gather around the campfire for an epic tale of things to come. ",