home-assistant-configuration/templates/skylar_morning.yaml

72 lines
2.6 KiB
YAML

>
{% macro getIntro() %}
Skylar.
{{ [ "This is your friendly neighborhood smart home ",
"This is your digital life mate ",
"This is your cruise director ",
] | random }} with your morning announcements.
{% endmacro %}
{% macro getDressed() %}
{% if is_state("sensor.birthday_skylar", "0") %}
First, Happy Birthday Skylar! Second, even birthday boys have to get dressed. So get to it.
{% else %}
It is time to get dressed.
{% endif %}
{% endmacro %}
{% macro getSchoolDay() %}
{% if is_state("calendar.skylar_school", "on") %}
Because you have school today!
{% if states.calendar.skylar_school.attributes.description == "early-release" %}
And guess what? It is early release!
{% endif %}
# {% if is_state("sensor.weekday", "fri") %}
# Plus, it is fun Friday!
# {% endif %}
{% endif %}
{% endmacro %}
{% macro getEvents() %}
{% if is_state("calendar.skylar_events", "on") %}
You have {{ states.calendar.skylar_events.attributes.message }} today!
# {% if is_state("sensor.weekday", "fri") %}
# Plus, it is fun Friday!
# {% endif %}
{% endif %}
{% endmacro %}
{% macro getClothesSuggestion() %}
{% if is_state("sensor.clothing_forecast", "Freezing") %}
It is going to be freezing today so I suggest wearing long pants, and a heavy coat.
{% elif is_state("sensor.clothing_forecast","Cold") %}
It is going to be cold today so I suggest wearing long pants and a light jacket.
{% elif is_state("sensor.clothing_forecast", "Chilly") %}
It is going to be chilly today so I suggest wearing at least long pants.
{% elif is_state("sensor.clothing_forecast", "Nice") %}
It is going to be nice today so I suggest wearing shorts.
{% elif is_state("sensor.clothing_forecast", "Toasty") %}
It is going to be a bit warm today so I suggest wearing shorts.
{% elif is_state("sensor.clothing_forecast", "Hot") %}
It is going to be hot today so I suggest wearing shorts.
{% else %}
{% 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() -%}
{{ getIntro() }}
{{ getDressed() }}
{{ getSchoolDay() }}
{{ getEvents() }}
{{ getClothesSuggestion() }}
{%- endmacro -%}
{# Call the macro #}
{{- cleanup(mother_of_all_macros()) -}}