2017-02-03 18:51:50 +00:00
######################################################################################################
2017-02-03 20:12:21 +00:00
###Script to send notifications to the ChromeCast Audios during normal hours and only when we are home! Call like this:
2017-02-03 18:51:50 +00:00
# action:
2017-02-03 20:12:21 +00:00
# service: script.Voice_notify
2017-02-03 18:51:50 +00:00
# data_template:
# value1: 'Startup: Home Assistant is Up and Running!'
2017-02-03 20:12:21 +00:00
# OR
# value1: "{{ trigger.to_state.state }}"
2017-05-03 20:05:55 +00:00
# # @CCOSTAN
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
2017-02-03 18:51:50 +00:00
######################################################################################################
2017-02-03 20:12:21 +00:00
voice_notify :
2017-02-03 18:51:50 +00:00
sequence :
2017-02-03 20:12:21 +00:00
- condition : and
conditions :
- condition : or
conditions :
- condition : state
entity_id : group.family
state : 'home'
- condition : state
entity_id : input_boolean.guest_mode
state : 'on'
2017-02-04 02:16:34 +00:00
- condition : or
conditions :
- condition : time
2017-02-04 16:25:58 +00:00
after : '09:00:00'
2017-05-04 14:00:40 +00:00
before : '21:30:00'
2017-02-04 02:16:34 +00:00
- condition : state
entity_id : input_boolean.alert_mode
2017-02-23 01:14:00 +00:00
state : 'on'
2017-02-25 03:13:18 +00:00
- condition : or
conditions :
- condition : template
value_template : >
{% if is_state('media_player.livingroomCC', 'playing') %}
false
2017-04-21 19:43:10 +00:00
{% elif is_state('media_player.whole_house', 'playing') %}
false
2017-02-25 03:13:18 +00:00
{% else %}
true
{% endif %}
- condition : state
entity_id : input_boolean.alert_mode
state : 'on'
2017-02-03 22:11:33 +00:00
- condition : state
entity_id : input_boolean.speech_notifications
state : 'on'
2017-02-03 20:12:21 +00:00
- service : switch.turn_on
2017-02-23 01:14:00 +00:00
entity_id : switch.living_room_amp
2017-02-06 18:21:31 +00:00
- service : media_player.turn_on
2017-02-23 01:14:00 +00:00
entity_id : media_player.livingroomCC
2017-02-04 23:17:45 +00:00
- service : media_player.volume_set
entity_id :
2017-02-06 18:21:31 +00:00
- media_player.livingroomCC
2017-02-23 01:14:00 +00:00
data_template :
2017-02-04 23:17:45 +00:00
volume_level : >
2017-02-27 17:31:06 +00:00
{% if now().strftime("%H")|int < 12 and now().strftime("%H")|int > 6%}
2017-04-27 19:19:19 +00:00
0.3
2017-03-13 22:03:59 +00:00
{% elif now().strftime("%H")|int > 12 and now().strftime("%H")|int < 20%}
2017-04-14 20:38:57 +00:00
0.55
2017-02-04 23:17:45 +00:00
{% else %}
2017-04-13 21:16:07 +00:00
0.3
2017-02-04 23:17:45 +00:00
{% endif %}
2017-02-10 01:48:24 +00:00
2017-02-08 21:57:11 +00:00
- service : tts.amazon_polly_say
2017-02-06 18:21:31 +00:00
entity_id : media_player.livingroomCC
2017-02-03 20:12:21 +00:00
data_template :
2017-02-04 21:47:28 +00:00
message : >
2017-04-21 17:31:08 +00:00
<speak>
2017-05-04 14:00:40 +00:00
{% if call_no_announcement != 1 %}
{% if now().strftime("%H")|int < 12 and now().strftime("%H")|int > 6%}
Good morning.
{% elif now().strftime("%H")|int > 12 and now().strftime("%H")|int < 17%}
Good afternoon.
{% else %}
Good evening.
{% endif %}
2017-02-04 21:47:28 +00:00
{% endif %}
2017-04-13 21:16:07 +00:00
2017-04-13 15:32:24 +00:00
{%- 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 % 2 != 0 %}
Today is Justin's day to do the chores.
{% else %}
Today is Paige's day to do the chores.
{%endif%}
{%- endmacro -%}
2017-04-13 17:10:05 +00:00
{%- 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 -%}
2017-04-27 19:43:14 +00:00
{# *********** This macro looks for High UV rays and lets us know if it is before 2pm #}
2017-04-27 19:19:19 +00:00
{%- macro uv_rays() -%}
2017-04-29 20:01:21 +00:00
{% if now().strftime("%H")|int > 8 and now().strftime("%H")|int < 16%}
2017-04-27 19:43:14 +00:00
{% if state.sensor.uv_index.states|int <= 4 %}
2017-04-29 20:01:21 +00:00
The U V index today will be very mild today.
2017-04-27 19:43:14 +00:00
{% elif states.sensor.uv_index.state|int > 4 and states.sensor.uv_index.state|int <=7 %}
The U V index will be {{states('sensor.uv_index')}} today. This is considered high.
Be sure to drink lots of water and put on suntan lotion if you will be in the sun.
{% elif states.sensor.uv_index.state|int > 7 and states.sensor.uv_index.state|int <=10 %}
The U V index will be {{states(sensor.uv_index)}} today. This is considered very high.
Be sure to drink lots of water and put on suntan lotion often today.
2017-04-28 20:13:04 +00:00
You could get a sunburn in about {{states('sensor.uv_burn_time')}} minutes.
2017-04-27 19:43:14 +00:00
{% endif %}
2017-04-29 20:01:21 +00:00
{{states('sensor.uv_sun_advice')}}
2017-04-27 19:19:19 +00:00
{% endif %}
{%- endmacro -%}
2017-04-13 17:10:05 +00:00
{%- macro lights_status() -%}
. 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 }}
{%- endfor -%}
{%- endfor %}
{%- endmacro -%}
{% macro garage_check() %}
{% if is_state('cover.large_garage', 'open') -%}
The Large Garage Door is still open
{% endif -%}
{% if is_state('cover.small_garage', 'open') -%}
{% if is_state('cover.large_garage', 'open') -%}and
{%- endif %} The small Garage Door is still open.
{% endif %}
{%- endmacro -%}
2017-04-13 21:16:07 +00:00
{% 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 -%}
2017-04-13 17:10:05 +00:00
2017-04-21 16:52:58 +00:00
{% 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.
{{outside_weather()}}
{% endif -%}
{%- endmacro -%}
2017-04-26 02:05:04 +00:00
{% macro pihole() %}
2017-04-27 19:19:19 +00:00
{% if states.sensor.pihole_ads_blocked_today.state|int > 1000 -%}
2017-04-26 02:05:04 +00:00
Our internet blocking system has blocked {{states.sensor.pihole_ads_blocked_today.state}} ads today!
2017-04-27 19:19:19 +00:00
Happy Internet surfing!
2017-04-26 02:05:04 +00:00
{% endif -%}
{%- endmacro -%}
2017-05-03 20:05:55 +00:00
{# ********************************************* #}
{# ******** Start the Speech routines ******* #}
{# #}
{# ********************************************* #}
2017-04-27 19:43:14 +00:00
2017-05-03 20:05:55 +00:00
{{ personarriving }} {# Called from Annoucenments #}
2017-04-13 17:10:05 +00:00
2017-05-03 20:05:55 +00:00
{{ NestStatus}} {# Called from Nest when thermostats turn on #}
2017-05-03 20:54:25 +00:00
{% if call_inside_weather == 1 %}
2017-04-13 17:10:05 +00:00
{{inside_weather()}}
{%endif%}
2017-05-03 20:54:25 +00:00
{% if call_outside_weather == 1 %}
2017-04-13 17:10:05 +00:00
{{outside_weather()}}
{%endif%}
2017-04-27 19:43:14 +00:00
{{uv_rays()}}
2017-04-13 16:03:32 +00:00
{{ DoorOpened }}
2017-04-13 17:10:05 +00:00
{{ DoorClosed }}
2017-05-03 21:01:34 +00:00
{% if call_garage_check == 1 or is_state('sun.sun', 'below_horizon') %}
2017-04-13 17:10:05 +00:00
{{garage_check()}}
{%endif%}
{{ NewDevice}}
{% if is_state('input_boolean.lights_status', 'on') %}
{{lights_status()}}
{%endif%}
2017-05-03 20:54:25 +00:00
{% if call_responsibilities == 1%}
2017-04-13 21:16:07 +00:00
{{responsibilities()}}
{%endif%}
{% if now().strftime("%H")|int > 22 %}
{{Medicine()}}
{%endif%}
2017-04-21 16:52:58 +00:00
{{ value1 }}
2017-04-28 20:13:04 +00:00
{{ iss() }}
{{ pihole() }}
2017-04-21 17:31:08 +00:00
</speak>
2017-02-03 20:12:21 +00:00
cache : true
2017-02-23 01:14:00 +00:00
- service : input_boolean.turn_off
2017-02-25 03:13:18 +00:00
entity_id :
2017-02-23 01:14:00 +00:00
- input_boolean.alert_mode
2017-04-13 17:10:05 +00:00
- input_boolean.home_stats
2017-04-13 15:32:24 +00:00
- input_boolean.responsibilities
2017-04-13 17:10:05 +00:00
- input_boolean.lights_status