home-assistant-configuration/templates/morning_report.yaml

76 lines
3.2 KiB
YAML
Raw Normal View History

2019-02-21 17:49:55 +00:00
>
{% macro getTodaysEvent() %}
{% if is_state("sensor.holiday_halloween","0") %}
This is Hallowen, this is halloween. Happy Halloween!
{% endif %}
{% if is_state("sensor.holiday_christmas","0") %}
Merry Christmas Everyone!
{% endif %}
{% if is_state("sensor.anniversary_our_wedding","0") %}
Happy Anniversary! It has been an amazing {{ states.sensor.anniversary_our_wedding.attributes.years }} years!
{% endif %}
{% if is_state("calendar.holidays_in_united_states", "on") %}
Today is {{states.calendar.holidays_in_united_states.attributes.message}}
{% endif %}
{% endmacro %}
{% macro getForecast() %}
It's currently {{states.sensor.dark_sky_summary.state}} and {{states.sensor.dark_sky_temperature.state|round}} degrees. The high will be {{states.sensor.dark_sky_daytime_high_temperature_0.state|round}} degrees. There is a {{states.sensor.dark_sky_precip_probability_0.state|round}} percent chance of rain.
{% endmacro %}
{% macro getTraffic() %}
Under current traffic conditions it would take you {{states.sensor.home_to_zoo.state|round}} mins to get to Zoo Atlanta, and {{states.sensor.home_to_summit.state|round}} mins to get to Cox Automotive.
{% endmacro %}
{% macro getBirthdays() %}
{% if states.calendar.birthdays.state == "on" %}
Today is {{ states.calendar.birthdays.attributes.message }} birthday!
{% else %}
{% if states.sensor.birthday_skylar.state | int == 1 %}
Tomorrow is Skylar's Birthday.
{% endif %}
{% if states.sensor.birthday_jeff.state | int == 1 %}
Tomorrow is Jeff's Birthday.
{% endif %}
{% if states.sensor.birthday_kat.state | int == 1 %}
Tomorrow is Katherine's Birthday.
{% endif %}
{% if states.sensor.anniversary_our_wedding.state | int == 1 %}
Tomorrow is Jeff and Katherine's Wedding Anniversary.
{% endif %}
{% endif %}
{% endmacro %}
{% macro getAnniversary() %}
{% if states.sensor.anniversary_our_wedding.state | int == 1 %}
Tomorrow is Jeff and Katherine's Wedding Anniversary.
{% endif %}
{% endmacro %}
{% macro getHolidays() %}
{% if states.sensor.holiday_halloween.state | int == 1 %}
Tomorrow is Halloween. Hope you have picked out a costume.
{% endif %}
{% if states.sensor.holiday_christmas.state | int == 1 %}
Tomorrow is Christmas. It's practically here! Santa is coming tonight! Don't forget the cookies!
{% elif states.sensor.holiday_christmas.state | int < 25 %}
There are only {{states.sensor.holiday_christmas.state}} days until christmas.
{% 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() -%}
It is {{ now().strftime("%I:%M %p") }}.
{{ getTodaysEvent() }}
{{ getForecast() }}
{{ getTraffic() }}
{{ getBirthdays() }}
{{ getAnniversary() }}
{{ getHolidays() }}
{%- endmacro -%}
{# Call the macro #}
{{- cleanup(mother_of_all_macros()) -}}