home-assistant-configuration/config/templates/speech/sundown_briefing.yaml

126 lines
4.8 KiB
YAML
Executable File

>
{# Nightky Report #}
{%- macro getReport() -%}
<p>
Good evening.
</p>
<p>
It is {{ now().strftime("%I:%M %p") }}
</p>
<p>
{% if is_state('sun.sun', 'below_horizon') %}
You have
{% set seconds = as_timestamp(states.sun.sun.attributes.next_rising)-now().timestamp() %}
{% set hours = seconds / 60 %}
{% if seconds / ( 60 * 60 ) > 1 %}
{{ (seconds // ( 60 * 60 )) | int }} hours
{% else %}
{{ (seconds // 60) | int }} minutes
{% endif %}
{{ [
'until the sun rises.',
'until the sun is up.',
'before the sun officially rises. '
]|random }}
{% else %}
You have
{% set seconds = as_timestamp(states.sun.sun.attributes.next_setting)-now().timestamp() %}
{% set hours = seconds / 60 %}
{% if seconds / ( 60 * 60 ) > 1 %}
{{ (seconds // ( 60 * 60 )) | int }} hours
{% else %}
{{ (seconds // 60) | int }} minutes
{% endif %}
{{ [
'until the sun sets for the day.',
'until the sun slips below the horizon.',
'before the sun officially sets. ',
'before The sun has been ushered off the stage.'
]|random }}
{% endif %}
</p>
<p>
{{ [
'Exterior Cameras are now motion activated, and the front porch light is on.',
'I have turned on the front porch light and armed the perimiter cameras.',
'You are running out of daylight. Time to wrap up any outside chores. The ouside lights have been turned on.',
'Switching Anchorage House to night mode! Front porch lights are on and the ouside cameras are recording when motion has been detected.',
'Anchorage House has been configured for night.',
'Switching on Anchorage Houses exterior lighting, and armed the cameras.',
'It is getting dark outside, so I am turning on the outside lights.',
'The sun is setting so it is ime to turn on the front lights.',
'If you have not looked outside lately, the light of the day is almost gone. I am turning on the outside lights.'
]|random }}
</p>
{% if is_state('binary_sensor.garage_door', 'on') %}
<p>
{{ [ 'The garage door is open. ',
'Someone forgot to close the garage.'
] | random }}
Someone should close it.
</p>
{% elif is_state('binary_sensor.side_door', 'on') %}
<p>
{{ [ 'The side door is ajar. ',
'The side door is open. ',
'Someone forgot to close the side door.'
] | random }}
Someone might want to check it.
</p>
{% else %}
{% endif %}
{% if is_state('input_boolean.freeze_warning','on') %}
<p>
{{ [ 'The temperature is expected to be near or below freezing. Someone might want to bring the lemon tree in. ',
'It appears that it will be cold tonight. Like, the turn water solid kind of cold. Think of the poor plants.',
'I suggest bringing in the plants other wise, the temperature might kill them. And that will be on you.',
'I would say winter is coming. But, based on the weather forecast it appears to be here.',
'It will be freezing cold tonight. I would bring in the plants but I lack legs. And Arms. So I am forced to rely on you. Do not let me down.'
] | random }}
</p>
{% endif %}
{% if is_state('sensor.today_is', 'Monday') %}
{% if now().strftime('%H')|int > 17 %}
{{ [ 'Do not forget tomorrow is Trash Day. ',
'I advise you move the trash cans to the curb for the weekly pickup. ',
' The trash and recycle should go out'
] | random }}
{% endif %}
{% endif %}
{% if is_state('sensor.today_is', 'Tuesday') %}
{% if now().strftime('%H')|int > 17 %}
<p>
{{ [ 'Do not forget to bring in the trash cans. ',
'The trash cans will feel lonely if you leave them out all night. ',
'The <say-as interpret-as="characters">HOA</say-as> will get mad if you leave those trash cans out on the street.'
] | random }}
</p>
{% endif %}
{% endif %}
{%- endmacro -%}
{# a macro that removes all newline characters, empty spaces, and returns formatted text #}
{%- macro cleanup(data) -%}
{%- for item in data.split("\n") if item | trim != "" -%}
{{ item | trim }} {% endfor -%}
{%- endmacro -%}
{# a macro to call all macros :) #}
{%- macro mother_of_all_macros() -%}
{{ getReport() }}
{%- endmacro -%}
{# Call the macro #}
{{- cleanup(mother_of_all_macros()) -}}