2020-06-15 21:52:36 +00:00
>-
2019-09-10 13:00:33 +00:00
{%- macro dark_outside() -%}
2024-05-25 00:23:12 +00:00
The sun has set. I will turn on the outside lights.
2019-09-10 13:00:33 +00:00
{%- endmacro -%}
{%- macro responsibilities() -%}
2023-11-14 20:53:13 +00:00
{% set day_of_week = now().strftime('%a') %}
{% if day_of_week in ['Wed', 'Sun'] %}
Today is {{ now().strftime('%A') }} and {{ now().strftime('%A') }} is garbage day.
{% if day_of_week == 'Wed' %}
2024-05-25 00:23:12 +00:00
Both Recycling and regular Garbage goes out.
2023-11-14 20:53:13 +00:00
{% endif %}
{% endif %}
{% set day_of_year = now().strftime('%j')|int(9999) %}
{% if day_of_year % 2 != 0 %}
Today is Justin's day to do the chores.
{% else %}
Today is Paige's day to do the chores.
{% endif %}
2019-09-10 13:00:33 +00:00
{%- endmacro -%}
{%- macro inside_weather() -%}
2024-06-21 21:56:01 +00:00
Inside the house, it is {{ states.climate.downstairs.attributes['current_temperature'] }} degrees with {{ states('sensor.downstairs_thermostat_humidity') }} percent humidity. [Only mention humidity if it seems unusually high]
2019-09-10 13:00:33 +00:00
{%- endmacro -%}
2024-06-21 21:56:01 +00:00
{%- macro outside_weather2() -%}
2024-05-25 00:23:12 +00:00
Outside, it is going to be {{ states('sensor.pirateweather_temperature') }} degrees and {{ states('sensor.pirateweather_summary') }} with {{ states('sensor.pirateweather_humidity') }} % humidity. [Only mention humidity if it seems unusually high]
2019-09-10 13:00:33 +00:00
{%- endmacro -%}
2024-06-21 21:56:01 +00:00
{% macro outside_weather() %}
[ Here is the current weather outside]
{%- for entity in states.sensor if 'pirateweather' in entity.entity_id %}
{%- set state = entity.state %}
{%- set unit = entity.attributes.unit_of_measurement if 'unit_of_measurement' in entity.attributes else '' %}
{%- set friendly_name = ' '.join(entity.attributes.friendly_name.split(' ')[1:]) %}
{%- if state not in ['0', '0.0', 'none'] and 'UV Index' not in friendly_name %}
{%- if 'Temperature' in friendly_name -%}
{{ friendly_name }} : {{ state }} {{ unit }}
{%- elif 'Minutely' in friendly_name -%}
{{ friendly_name }} : {{ state }} {{ unit }}
{%- elif 'Precip' in friendly_name -%}
{{ friendly_name }} : {{ state }} {{ unit }}
{%- elif 'Wind Speed' in friendly_name and state | float > 15 -%}
{{ friendly_name }} : {{ state }} {{ unit }}
{%- elif 'Cloud Coverage' in friendly_name and state | float > 75 -%}
{{ friendly_name }} : {{ state }} {{ unit }}
{%- elif 'Humidity' in friendly_name and (state | float < 50 or state | float > 85) -%}
{{ friendly_name }} : {{ state }} {{ unit }}
{%- elif 'Nearest Storm Distance' in friendly_name and state | float <= 10 -%}
{{ friendly_name }} : {{ state }} {{ unit }}
{%- endif -%}
{%- endif %}
{% endfor -%}
{%- endmacro -%}
2020-07-28 20:21:08 +00:00
{%- macro lightning() -%}
2024-06-21 21:56:01 +00:00
There have been {{ states('sensor.blitzortung_lightning_counter') }} lightning strikes detected within {{(states('sensor.blitzortung_lightning_distance') | int(9999)/ 1.69) | round (1, 'floor')}} Miles of our House. Please make sure everyone is inside the house.
2020-07-28 20:21:08 +00:00
{%- endmacro -%}
2020-09-07 16:13:46 +00:00
{%- macro fridge() -%}
2024-06-21 21:56:01 +00:00
The internal temperature of the refrigerator is currently {{ states('sensor.blink_blink1_temperature') }} degrees.
2020-09-07 16:13:46 +00:00
{%- endmacro -%}
2019-09-10 13:00:33 +00:00
{%- macro light_check() -%}
{% if states.group.all_lights.state != 'off' -%}
There are
{% for state in states.light if state.state == 'on' -%}
{%- if loop.last -%}
{{ loop.index }}
{%- endif -%}
{%- endfor %}
lights on right now.
{% set comma = joiner(', ') %}
The
{% for group in states.group|groupby('state') -%}
{%- for entity in group.list if entity.state == 'on'
and entity.name.split(' ')[1]|lower == 'lights'
and entity.name.split(' ')[0]|lower != 'all'
and entity.name.split(' ')[0]|lower != 'interior'
-%}
{{ 'and' if loop.last and not loop.first else comma() }}
{{ entity.name|replace('Lights','')}}
{%- endfor -%}
{%- endfor -%}
lights are on.
{%- endif -%}
{%- endmacro -%}
{%- macro window_check() -%}
{% if states.group.entry_points.state != 'off' -%}
{% set comma = joiner(', ') %}
The
{% for state in states.binary_sensor if state.state == 'on' and state.attributes.device_class == 'opening' -%}
{%- endfor %}
{% for group in states.binary_sensor|groupby('state') -%}
{%- for entity in group.list if entity.state == 'on' and entity.attributes.device_class == 'opening' -%}
{{ ' and' if loop.last and not loop.first else comma() }}
{{ entity.attributes.friendly_name }}
{%- endfor -%}
{% endfor %}
need to be closed.
{%- endif -%}
{%- endmacro -%}
2020-02-14 04:21:11 +00:00
{%- macro lock_check() -%}
{% if states.group.locks.state !='locked' -%}
The
{%- for state in states.lock -%}
{%- endfor %}
{% for group in states.lock|groupby('state') -%}
{%- for entity in group.list if entity.state == 'unlocked' -%}
{{ ' and' if loop.last and not loop.first }}
{{ entity.attributes.friendly_name }}
{%- endfor -%}
{%- endfor %}
needs to be locked.
{%- endif -%}
{%- endmacro -%}
2019-09-10 13:00:33 +00:00
{%- macro garage_check() -%}
2022-06-27 17:11:34 +00:00
{% if states.group.garage_doors.state !='closed' -%}
The
{%- for state in states.cover -%}
{%- endfor %}
{% for group in states.cover|groupby('state') -%}
{%- for entity in group.list if entity.state == 'open' and entity.attributes.device_class == 'garage' -%}
{{ ' and' if loop.last and not loop.first }}
{{ entity.attributes.friendly_name }}
{%- endfor -%}
{%- endfor %}
need to be closed.
{%- endif -%}
2019-09-10 13:00:33 +00:00
{%- endmacro -%}
{%- macro medicine() -%}
{% if is_state('input_boolean.medicine', 'off') -%}
It looks like Carlo has not taken his medicine yet. Please make sure Carlo takes his medicine now.
{% endif -%}
{%- endmacro -%}
{%- macro iss() -%}
{% if is_state('binary_sensor.iss', 'on') -%}
2024-06-03 19:15:01 +00:00
The international space station is above us now and there are {{ states.binary_sensor.iss.attributes['number_of_people_in_space'] }} people in space right now. [include an ISS fact at the end]
2019-09-10 13:00:33 +00:00
{% endif -%}
{%- endmacro -%}
{%- macro moon() -%}
2024-06-19 14:42:25 +00:00
{% if (now().hour == 17) %}
2024-05-25 00:23:12 +00:00
Current Moon phase : {{ states('sensor.moon') }} [Give a fact and mention today's phase]
2024-06-19 14:42:25 +00:00
{% endif %}
2019-09-10 13:00:33 +00:00
{%- endmacro -%}
{%- macro uv() -%}
2023-04-09 18:06:11 +00:00
{% if states.sensor.pirateweather_uv_index.state|int(9999)>= 6 and states.sensor.pirateweather_uv_index.state|int(9999)<= 7.9 %}
Today's UV index is {{ states.sensor.pirateweather_uv_index.state }}. You should wear sunscreen if going outside.
{% elif states.sensor.pirateweather_uv_index.state|int(9999)>= 8 and states.sensor.pirateweather_uv_index.state|int(9999)<=10.9 %}
Today's UV index is {{ states.sensor.pirateweather_uv_index.state }}. This is VERY HIGH. Be sure wear sunscreen and re-apply.
{% elif states.sensor.pirateweather_uv_index.state|int(9999)>= 11 %}
Today's UV index is {{ states.sensor.pirateweather_uv_index.state }}. This is EXTREME. You should be very cautious going outside.
2019-09-10 13:00:33 +00:00
{% endif %}
{%- endmacro -%}
{%- macro holiday() -%}
{% if states.sensor.holiday.state != '' %}
2024-05-25 00:23:12 +00:00
Today is {{ states.sensor.holiday.state }}. [Give an interesting fact or quote related to today]
2019-09-10 13:00:33 +00:00
{% endif %}
{%- endmacro -%}
2019-11-16 00:16:23 +00:00
{# YOUTUBE VIDEO ********* https://www.vcloudinfo.com/2019/11/adding-days-until-sensor-to-my-home-assistant-speech-routines.html #}
2019-10-06 18:18:00 +00:00
{%- macro days_until() -%}
2021-11-11 14:29:24 +00:00
{%- if states('sensor.mothers_countdown') | int(9999)< 20 -%}
2020-10-09 18:34:31 +00:00
and don't forget, there is only {{ states.sensor.mothers_countdown.state }} days until Mothers day!
2021-11-11 14:29:24 +00:00
{%- elif states('sensor.fathers_countdown') | int(9999)< 20 -%}
2020-04-07 18:12:13 +00:00
and don't forget, there are {{ states.sensor.fathers_countdown.state }} days until Fathers day!
2021-11-11 14:29:24 +00:00
{%- elif states('sensor.easter_countdown') | int(9999)< 15 -%}
2020-05-25 21:44:25 +00:00
and don't forget, there are {{ states.sensor.easter_countdown.state }} days until Easter Sunday!
2021-11-11 14:29:24 +00:00
{%- elif states('sensor.thanksgiving_day_countdown') | int(9999)< 10 and states('sensor.thanksgiving_day_countdown') | int(9999)> 0 -%}
2020-11-25 18:20:11 +00:00
and don't forget, there are {{ states.sensor.thanksgiving_day_countdown.state }} days until Thanksgiving
2021-11-11 14:29:24 +00:00
{%- elif states('sensor.thanksgiving_day_countdown') | int(9999)< 1 -%}
2020-11-25 18:20:11 +00:00
and don't forget, Thanksgiving is tomorrow!
2021-11-11 14:29:24 +00:00
{%- elif states('sensor.halloween_countdown') | int(9999)< 30 and states('sensor.halloween_countdown') | int(9999)> 0 -%}
2020-10-09 18:34:31 +00:00
and don't forget, there are {{ states.sensor.halloween_countdown.state }} Spooky days until Halloween!
2021-11-11 14:29:24 +00:00
{%- elif states('sensor.halloween_countdown') | int(9999)< 1 -%}
2020-11-25 18:20:11 +00:00
and don't forget, Tomorrow is Halloween!
2021-11-11 14:29:24 +00:00
{%- elif states('sensor.chanukkah_countdown') | int(9999)< 15 -%}
2020-05-23 18:09:48 +00:00
and don't forget, there are {{ states.sensor.chanukkah_countdown.state }} days until Chanukkah!
2021-11-11 14:29:24 +00:00
{%- elif states('sensor.christmas_countdown') | int(9999)< 30 and states('sensor.christmas_countdown') | int(9999)> 0 -%}
2020-10-09 18:34:31 +00:00
and don't forget, there are {{ states.sensor.christmas_countdown.state }} Merry days until Christmas!
2021-11-11 14:29:24 +00:00
{%- elif states('sensor.christmas_countdown') | int(9999)< 1 -%}
2020-11-25 18:20:11 +00:00
and don't forget, Santa Claus is coming tomorrow!
2019-10-06 18:18:00 +00:00
{% endif %}
{%- endmacro -%}
2019-09-10 13:00:33 +00:00
{% macro inspirational_quote() %}
2024-06-03 19:15:01 +00:00
[ Include an inspirational quote relevant to the day or situation at the end of the message. "]
{% endmacro %}
{% macro fact_of_the_day() %}
[ Include a fact about something that happened in the past on this day at the end of the message]
2019-09-10 13:00:33 +00:00
{% endmacro %}
2024-06-14 17:52:05 +00:00
{%- macro traffic_time() -%}
2024-06-21 21:56:01 +00:00
Travel Time to Spectrum : {{ states.sensor.waze_travel_time.state }} minutes.
2024-06-14 17:52:05 +00:00
{%- endmacro -%}
2020-06-08 19:27:38 +00:00
{# a macro that removes all newline characters, empty spaces, and returns formatted text and replaces underscores with spaces #}
{%- macro cleanup(data) -%}
{%- for item in data.split("\n") if item | trim != "" -%}
{{ item | trim | replace("_", " ") }} {% endfor -%}
{%- endmacro -%}
2019-09-10 13:00:33 +00:00
{# ********************************************* #}
{# ******** Start the Speech routines ******** #}
{# ********************************************* #}
2020-06-08 19:27:38 +00:00
{# a macro to call all macros :) #}
{%- macro mother_of_all_macros() -%}
2024-06-14 17:52:05 +00:00
{% set day_of_week = now().strftime('%a') %}
{% set hour = now().hour %}
{% set minute = now().minute %}
2020-06-08 19:27:38 +00:00
{% if call_no_announcement != 1 %}
2021-11-11 14:29:24 +00:00
{% if now().strftime('%H')|int(9999)< 12 and now().strftime('%H')|int(9999)> 6 %}
2020-06-08 19:27:38 +00:00
Good morning.
2021-11-11 14:29:24 +00:00
{% elif now().strftime('%H')|int(9999)>= 12 and now().strftime('%H')|int(9999)< 17 %}
2020-06-08 19:27:38 +00:00
Good afternoon.
{% else %}
Good evening.
{% endif %}
2020-05-25 21:44:25 +00:00
{% endif %}
2019-09-10 13:00:33 +00:00
2020-06-08 19:27:38 +00:00
{# Called from Annoucenments #}
2021-04-30 18:39:08 +00:00
{{ personarriving | default }}
2019-09-10 13:00:33 +00:00
2020-06-08 19:27:38 +00:00
{# Called from Nest when thermostats turn on #}
2021-04-30 18:39:08 +00:00
{{ NestStatus | default }}
2019-09-10 13:00:33 +00:00
2020-06-08 19:27:38 +00:00
{% if call_inside_weather == 1 %}
{{ inside_weather() }}
{% endif %}
2019-09-10 13:00:33 +00:00
2020-06-08 19:27:38 +00:00
{% if call_outside_weather == 1 and is_state('sun.sun', 'above_horizon') %}
{{ outside_weather() }}
{% endif %}
2019-09-10 13:00:33 +00:00
2021-11-11 14:50:24 +00:00
{% if (states('sensor.blitzortung_lightning_counter')|int(0)) > 0 %}
2020-07-28 20:21:08 +00:00
{{ lightning() }}
{% endif %}
2021-11-11 14:50:24 +00:00
{% if (states('sensor.blink_blink1_temperature')|int(0)) > 50 and no_fridge != 1 %}
2020-09-07 16:13:46 +00:00
{{ fridge() }}
{% endif %}
2021-04-30 18:39:08 +00:00
{{ DoorOpened | default }}
{{ DoorClosed | default }}
2019-09-10 13:00:33 +00:00
2020-06-08 19:27:38 +00:00
{{ lock_check() }}
{# These two lock statements are sent directly from automations. #}
2021-04-30 18:39:08 +00:00
{{ DoorLocked | default }}
{{ DoorUnLocked | default }}
2020-02-14 04:21:11 +00:00
2020-06-08 19:27:38 +00:00
{% if call_dark_outside == 1 %}
{{ dark_outside() }}
{% endif %}
2019-09-10 13:00:33 +00:00
2022-06-27 17:11:34 +00:00
{% if call_garage_check == 999 or is_state('sun.sun', '9999') %}
2020-06-08 19:27:38 +00:00
{{ garage_check() }}
{% endif %}
2019-09-10 13:00:33 +00:00
2020-06-08 19:27:38 +00:00
{% if (call_window_check == 1 or is_state('sun.sun', 'below_horizon')) or is_state('group.entry_points', 'on') %}
{{ window_check() }}
{% endif %}
2019-09-10 13:00:33 +00:00
2021-04-30 18:39:08 +00:00
{{ NewDevice | default }}
2019-09-10 13:00:33 +00:00
2020-06-08 19:27:38 +00:00
{% if call_light_check == 1 %}
{{ light_check() }}
{% endif %}
2019-09-10 13:00:33 +00:00
2020-06-08 19:27:38 +00:00
{% if call_responsibilities == 1 %}
{{ responsibilities() }}
{% endif %}
2019-09-10 13:00:33 +00:00
2021-11-11 14:50:24 +00:00
{% if now().strftime('%H')|int(0) > 21 %}
2020-06-08 19:27:38 +00:00
{{ medicine() }}
{% endif %}
2024-06-14 17:52:05 +00:00
{% if day_of_week in ['Tue', 'Wed', 'Thu', 'Fri', 'Sat'] %}
{% if (hour == 8 and minute >= 30) or (hour == 9 and minute <= 20) or (hour == 17 and minute >= 0) or (hour == 18 and minute <= 20) %}
{{ traffic_time() }}
{% endif %}
{% endif %}
2019-09-10 13:00:33 +00:00
2020-06-08 19:27:38 +00:00
{% if value1 is not none %}
2021-04-30 18:39:08 +00:00
{{ value1 | default }}
2020-06-08 19:27:38 +00:00
{% endif %}
{# call a Random fact about the house or inspiration quote #}
2024-06-06 01:53:27 +00:00
{{ ([iss, moon, uv, holiday, days_until, outside_weather, outside_weather, inspirational_quote, fact_of_the_day]|random)() }}
2019-09-10 13:00:33 +00:00
2020-06-08 19:27:38 +00:00
{%- endmacro -%}
{{- cleanup(mother_of_all_macros()) -}}