361 lines
19 KiB
YAML
Executable File
361 lines
19 KiB
YAML
Executable File
>-
|
||
{%- macro dark_outside() -%}
|
||
{{ [
|
||
'It is pretty dark outside. I will turn on the outside lights now.',
|
||
'The sun is offical down. Exterior Cameras are now motion activated.',
|
||
'The sun has been ushered off the stage. Activating the perimiter cameras.',
|
||
'It is a little past Sunset. Time to turn on the outside lights. I am on it.',
|
||
'I will switch on the outside lights. It is getting dark outside.',
|
||
'Time to turn on the front lights. I will take care of it.',
|
||
'Switching to night mode! ',
|
||
'If you have not looked outside lately the light of the day is gone.',
|
||
'The outside world has switched to dark mode.'
|
||
]|random }}
|
||
{%- endmacro -%}
|
||
|
||
{%- macro responsibilities() -%}
|
||
{% if now().strftime('%a') == 'Wed' or now().strftime('%a') == 'Sun' %}
|
||
Today is {{ now().strftime('%A') }} and {{ now().strftime('%A') }} is garbage day.
|
||
{% endif %}
|
||
{% if now().strftime('%a') == 'Wed' %}
|
||
Both Recycling and regular Garbage goes out. Please take out all of the garbage cans tonight.
|
||
{% endif %}
|
||
{% if now().strftime('%j')|int(9999)% 2 != 0 %}
|
||
Today is Justin's day to do the chores.
|
||
{% else %}
|
||
Today is Paige's day to do the chores.
|
||
{% endif %}
|
||
{%- endmacro -%}
|
||
|
||
{%- macro inside_weather() -%}
|
||
Inside the house, it is {{ states.climate.downstairs.attributes['current_temperature'] }} degrees with around {{ states('sensor.downstairs_thermostat_humidity') }} percent humidity.
|
||
{%- endmacro -%}
|
||
|
||
{%- macro outside_weather() -%}
|
||
Outside, it is going to be {{ states('sensor.dark_sky_minutely_summary') }}
|
||
{%- endmacro -%}
|
||
|
||
{%- macro lightning() -%}
|
||
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.
|
||
{%- endmacro -%}
|
||
|
||
{%- macro fridge() -%}
|
||
The internal temperature of the refrigerator is currently {{ states('sensor.blink_blink1_temperature') }} degrees.
|
||
{%- endmacro -%}
|
||
|
||
{%- 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 -%}
|
||
|
||
{%- 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 -%}
|
||
|
||
{%- macro garage_check() -%}
|
||
{% 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 -%}
|
||
{%- 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') -%}
|
||
Here is something interesting. The international space station is above us now. There are {{ states.binary_sensor.iss.attributes['number_of_people_in_space'] }} people in space right now.
|
||
{% endif -%}
|
||
{%- endmacro -%}
|
||
|
||
{%- macro moon() -%}
|
||
{%- if states.sensor.moon.state == 'Full moon' -%}
|
||
{{ [
|
||
"Check out the full moon tonight!",
|
||
"Hey look, There is the full moon. ",
|
||
"The moon is huge! And full. ",
|
||
"If you want to see the full moon tonight is the night."
|
||
] | random }}
|
||
{%- endif -%}
|
||
{%- endmacro -%}
|
||
|
||
{%- macro uv() -%}
|
||
{% if states.sensor.dark_sky_uv_index.state|int(9999)>= 6 and states.sensor.dark_sky_uv_index.state|int(9999)<= 7.9 %}
|
||
Today's UV index is {{ states.sensor.dark_sky_uv_index.state }}. You should wear sunscreen if going outside.
|
||
{% elif states.sensor.dark_sky_uv_index.state|int(9999)>= 8 and states.sensor.dark_sky_uv_index.state|int(9999)<=10.9 %}
|
||
Today's UV index is {{ states.sensor.dark_sky_uv_index.state }}. This is VERY HIGH. Be sure wear sunscreen and re-apply.
|
||
{% elif states.sensor.dark_sky_uv_index.state|int(9999)>= 11 %}
|
||
Today's UV index is {{ states.sensor.dark_sky_uv_index.state }}. This is EXTREME. You should be very cautious going outside.
|
||
{% endif %}
|
||
{%- endmacro -%}
|
||
|
||
{%- macro holiday() -%}
|
||
{% if states.sensor.holiday.state != '' %}
|
||
Today is {{ states.sensor.holiday.state }}.
|
||
{% endif %}
|
||
{%- endmacro -%}
|
||
|
||
{# YOUTUBE VIDEO ********* https://www.vcloudinfo.com/2019/11/adding-days-until-sensor-to-my-home-assistant-speech-routines.html #}
|
||
{%- macro days_until() -%}
|
||
{%- if states('sensor.mothers_countdown') | int(9999)< 20 -%}
|
||
and don't forget, there is only {{ states.sensor.mothers_countdown.state }} days until Mothers day!
|
||
{%- elif states('sensor.fathers_countdown') | int(9999)< 20 -%}
|
||
and don't forget, there are {{ states.sensor.fathers_countdown.state }} days until Fathers day!
|
||
{%- elif states('sensor.easter_countdown') | int(9999)< 15 -%}
|
||
and don't forget, there are {{ states.sensor.easter_countdown.state }} days until Easter Sunday!
|
||
{%- elif states('sensor.thanksgiving_day_countdown') | int(9999)< 10 and states('sensor.thanksgiving_day_countdown') | int(9999)> 0 -%}
|
||
and don't forget, there are {{ states.sensor.thanksgiving_day_countdown.state }} days until Thanksgiving
|
||
{%- elif states('sensor.thanksgiving_day_countdown') | int(9999)< 1 -%}
|
||
and don't forget, Thanksgiving is tomorrow!
|
||
{%- elif states('sensor.halloween_countdown') | int(9999)< 30 and states('sensor.halloween_countdown') | int(9999)> 0 -%}
|
||
and don't forget, there are {{ states.sensor.halloween_countdown.state }} Spooky days until Halloween!
|
||
{%- elif states('sensor.halloween_countdown') | int(9999)< 1 -%}
|
||
and don't forget, Tomorrow is Halloween!
|
||
{%- elif states('sensor.chanukkah_countdown') | int(9999)< 15 -%}
|
||
and don't forget, there are {{ states.sensor.chanukkah_countdown.state }} days until Chanukkah!
|
||
{%- elif states('sensor.christmas_countdown') | int(9999)< 30 and states('sensor.christmas_countdown') | int(9999)> 0 -%}
|
||
and don't forget, there are {{ states.sensor.christmas_countdown.state }} Merry days until Christmas!
|
||
{%- elif states('sensor.christmas_countdown') | int(9999)< 1 -%}
|
||
and don't forget, Santa Claus is coming tomorrow!
|
||
{% endif %}
|
||
{%- endmacro -%}
|
||
|
||
{% macro inspirational_quote() %}
|
||
{% set inspirational_quote = [
|
||
"and one more thing, Life is about making an impact, make it a positive one. ",
|
||
"and one more thing, Whatever the mind of man can conceive and believe, it can achieve. ",
|
||
"and one more thing, Strive not to be a success, but rather to be of value. ",
|
||
"and one more thing, I attribute my overall success to never giving or taking an excuse. ",
|
||
"and one more thing, You miss one hundred percent of the shots you don’t take. ",
|
||
"and one more thing, The most difficult thing is the decision to act, the rest is merely tenacity. ",
|
||
"and one more thing, The only difference between who you are and who you want to be, is what you do. ",
|
||
"and one more thing, Every strike brings me closer to the next home run. ",
|
||
"and one more thing, Defining thepurpose is the starting point of all achievement. ",
|
||
"and one more thing, Life is not about getting and having, it's about giving and being. ",
|
||
"and one more thing, We become what we think about. ",
|
||
"and one more thing, Be the change that you wish to see in the world. ",
|
||
"and one more thing, A wise man changes his mind but a fool never will. ",
|
||
"and one more thing, Change is inevitable. Growth is optional. ",
|
||
"and one more thing, dont worry, be happy. ",
|
||
"and one more thing, Trust the process. ",
|
||
"and one more thing, There are far better things ahead of us than behind us. ",
|
||
"and one more thing, If you want to go fast, go alone but if you want to go far, go with others. ",
|
||
"and one more thing, The key to success is to focus on goals not obstacles. ",
|
||
"and one more thing, Sometimes we are tested not to show our weaknesses, but to discover our strengths. ",
|
||
"and one more thing, Do something today that your future self will thank you for. ",
|
||
"and one more thing, Life is ten percent what happens to you and ninety percent of how you react to it. ",
|
||
"and one more thing, The most common way people give up their power is by thinking they do not have any. ",
|
||
"and one more thing, The mind is everything. What you think, you will become. ",
|
||
"and one more thing, Always try to Live your best life. ",
|
||
"and one more thing, When nothing goes right, go left. ",
|
||
"and one more thing, The best time to plant a tree was twenty years ago. The second best time is now. ",
|
||
"and one more thing, An unexamined life is not worth living. ",
|
||
"and one more thing, Eighty percent of success is showing up. ",
|
||
"and one more thing, Do not stop when you are tired, stop when you are done. ",
|
||
"and one more thing, Luck is being prepared and ready for the opportunities when they come. ",
|
||
"and one more thing, Do not wait for opportunity. Create it.",
|
||
"and one more thing, action is the foundation of success. ",
|
||
"and one more thing, All progress takes place outside the comfort zone. ",
|
||
"and one more thing, You can make mistakes but you should never quit. ",
|
||
"and one more thing, Do not let the fear of losing be greater than the excitement of winning. ",
|
||
"and one more thing, The way to get started is to quit talking and begin doing. ",
|
||
"and one more thing, when you feel like quitting, remember why you started. ",
|
||
"and one more thing, The harder you work, the more luck people will think you have. ",
|
||
"and one more thing, The harder you work for something, the greater you will feel when you achieve it. ",
|
||
"and one more thing, Your time is limited, so do not waste it living someone elses life. ",
|
||
"and one more thing, Winning is not everything, but wanting to win is. ",
|
||
"and one more thing, I am not a product of my circumstances. I am a product of my decisions. ",
|
||
"and one more thing, You can never cross the ocean until you have the courage to lose sight of the shore. ",
|
||
"and one more thing, Either you run the day, or the day runs you. ",
|
||
"and one more thing, Whether you think you can or you think you cannot, you will be right. ",
|
||
"and one more thing, The two most important days in your life are the day you are born and the day you find out why. ",
|
||
"and one more thing, Never ruin a good day by thinking about a bad yesterday. ",
|
||
"and one more thing, Whatever you can do, or dream you can, begin it. Boldness has genius, power and magic in it. ",
|
||
"and one more thing, The best revenge is massive success. ",
|
||
"and one more thing, The universe cant put good into your hands unless you let go of the bad.",
|
||
"and one more thing, People often say that motivation does not last. Well, neither does bathing. That is why we recommend it daily. ",
|
||
"and one more thing, Life shrinks or expands in proportion to ones courage. ",
|
||
"and one more thing, If you hear a voice within you say you cannot paint, then by all means paint and that voice will be silenced. ",
|
||
"and one more thing, Do not raise your voice, instead improve your argument. ",
|
||
"and one more thing, There is only one way to avoid criticism: do nothing, say nothing, and be nothing. ",
|
||
"and one more thing, Ask and it will be given to you; search, and you will find; knock and the door will be opened for you. ",
|
||
"and one more thing, The only person you are destined to become is the person you decide to be. ",
|
||
"and one more thing, Go confidently in the direction of your dreams. Live the life you have imagined. ",
|
||
"and one more thing, Certain things catch your eye, but pursue only those that capture the heart. ",
|
||
"and one more thing, Believe you can and you are halfway there. ",
|
||
"and one more thing, Good things take time. ",
|
||
"and one more thing, If you cant beat the Fear... just do it scared! ",
|
||
"and one more thing, There is no place like home. ",
|
||
"and one more thing, Life can be tough but so are you. ",
|
||
"and one more thing, Everything you have ever wanted is on the other side of fear. ",
|
||
"and one more thing, Start where you are. Use what you have. Do what you can. ",
|
||
"and one more thing, Fall seven times and stand up eight. ",
|
||
"and one more thing, Everything has beauty, but not everyone can see. ",
|
||
"and one more thing, Life is like riding a bicycle. To keep your balance, you must keep moving. ",
|
||
"and one more thing, Life is not measured by the number of breaths we take, but by the moments that take our breath away. ",
|
||
"and one more thing, in any given moment, we can choose to move forward and grow or retreat.",
|
||
"and one more thing, Happiness is not something readymade. It comes from your own actions. ",
|
||
"and one more thing, If you are offered a seat on a rocket ship, do not ask what seat! Just get on. ",
|
||
"and one more thing, If the wind will not move you forward, take to the oars. ",
|
||
"and one more thing, If you can dream it, you can do it. ",
|
||
"and one more thing, You can not fall if you do not climb. But there’s no joy in living your whole life on the ground. ",
|
||
"and one more thing, Too many of us are not living our dreams because we are living our fears. ",
|
||
"and one more thing, Live your dreams or live your fears. You can only choose one… ",
|
||
"and one more thing, Challenges are what make life interesting and overcoming them is what makes life meaningful. ",
|
||
"and one more thing, If you want to lift yourself up, lift up someone else. ",
|
||
"and one more thing, Be nice to others and nice things will happen to you.",
|
||
"and one more thing, Everyone has a plan until they get punched in the face. Be ready to pivot and adapt to the situation. ",
|
||
"and one more thing, You are the Artist of your OWN life. Dont hand the paint brush to anyone else. ",
|
||
"and one more thing, Try to be a rainbow for someone elses cloud. ",
|
||
"and one more thing, It is nice to be important, but more important to be nice."
|
||
] %}
|
||
{{inspirational_quote|random}}
|
||
{% endmacro %}
|
||
|
||
{# 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 -%}
|
||
|
||
{# ********************************************* #}
|
||
{# ******** Start the Speech routines ******** #}
|
||
{# ********************************************* #}
|
||
|
||
{# a macro to call all macros :) #}
|
||
{%- macro mother_of_all_macros() -%}
|
||
|
||
{% if call_no_announcement != 1 %}
|
||
{% if now().strftime('%H')|int(9999)< 12 and now().strftime('%H')|int(9999)> 6 %}
|
||
Good morning.
|
||
{% elif now().strftime('%H')|int(9999)>= 12 and now().strftime('%H')|int(9999)< 17 %}
|
||
Good afternoon.
|
||
{% else %}
|
||
Good evening.
|
||
{% endif %}
|
||
{% endif %}
|
||
|
||
{# Called from Annoucenments #}
|
||
{{ personarriving | default }}
|
||
|
||
{# Called from Nest when thermostats turn on #}
|
||
{{ NestStatus | default }}
|
||
|
||
{% if call_inside_weather == 1 %}
|
||
{{ inside_weather() }}
|
||
{% endif %}
|
||
|
||
{% if call_outside_weather == 1 and is_state('sun.sun', 'above_horizon') %}
|
||
{{ outside_weather() }}
|
||
{% endif %}
|
||
|
||
{% if (states('sensor.blitzortung_lightning_counter')|int(0)) > 0 %}
|
||
{{ lightning() }}
|
||
{% endif %}
|
||
|
||
{% if (states('sensor.blink_blink1_temperature')|int(0)) > 50 and no_fridge != 1 %}
|
||
{{ fridge() }}
|
||
{% endif %}
|
||
|
||
{{ DoorOpened | default }}
|
||
{{ DoorClosed | default }}
|
||
|
||
{{ lock_check() }}
|
||
{# These two lock statements are sent directly from automations. #}
|
||
{{ DoorLocked | default }}
|
||
{{ DoorUnLocked | default }}
|
||
|
||
{% if call_dark_outside == 1 %}
|
||
{{ dark_outside() }}
|
||
{% endif %}
|
||
|
||
{% if call_garage_check == 999 or is_state('sun.sun', '9999') %}
|
||
{{ garage_check() }}
|
||
{% endif %}
|
||
|
||
{% if (call_window_check == 1 or is_state('sun.sun', 'below_horizon')) or is_state('group.entry_points', 'on') %}
|
||
{{ window_check() }}
|
||
{% endif %}
|
||
|
||
{{ NewDevice | default }}
|
||
|
||
{% if call_light_check == 1 %}
|
||
{{ light_check() }}
|
||
{% endif %}
|
||
|
||
{% if call_responsibilities == 1 %}
|
||
{{ responsibilities() }}
|
||
{% endif %}
|
||
|
||
{% if now().strftime('%H')|int(0) > 21 %}
|
||
{{ medicine() }}
|
||
{% endif %}
|
||
|
||
{% if value1 is not none %}
|
||
{{ value1 | default }}
|
||
{% endif %}
|
||
|
||
{# call a Random fact about the house or inspiration quote #}
|
||
{{ ([iss, moon, uv, holiday, days_until, outside_weather, outside_weather, inspirational_quote]|random)() }}
|
||
|
||
{%- endmacro -%}
|
||
{{- cleanup(mother_of_all_macros()) -}}
|