moving to a new speech engine for better routing

This commit is contained in:
Jeffrey Stone 2021-05-24 11:55:52 -04:00
parent bab9e2db42
commit 4a082fa4c9
4 changed files with 811 additions and 162 deletions

View File

@ -6,8 +6,8 @@
############################################################################### ###############################################################################
input_boolean: input_boolean:
house_party_protocol: house_party_protocol_switch:
name: House Party Protocol name: House Party Switch
automation: automation:
- id: house_party_protocol_on - id: house_party_protocol_on
@ -15,28 +15,47 @@ automation:
initial_state: true initial_state: true
trigger: trigger:
- platform: state - platform: state
entity_id: input_boolean.house_party_protocol entity_id: input_boolean.house_party_protocol_switch
to: 'on' to: 'on'
action: action:
- service: homeassistant.turn_on - service: homeassistant.turn_on
entity_id: group.incense entity_id: group.incense
- service: script.speech_engine - delay: 00:00:05
- service: script.status_annc
data_template: data_template:
who: '{{ states.sensor.room_audio.state }}' who: '{{ states.sensor.room_presence.state }}'
message: Incense has been turned on. call_house_party_protocol_enabled: 1
- id: house_party_protocol_off - id: house_party_protocol_off
alias: Turn Off House Party Protocol alias: Turn Off House Party Protocol
initial_state: true initial_state: true
trigger: trigger:
- platform: state - platform: state
entity_id: input_boolean.house_party_protocol entity_id: input_boolean.house_party_protocol_switch
to: 'off' to: 'off'
action: action:
- service: homeassistant.turn_off - service: homeassistant.turn_off
entity_id: group.incense entity_id: group.incense
- service: script.speech_engine - delay: 00:00:05
- service: script.status_annc
data_template: data_template:
who: '{{ states.sensor.room_audio.state }}' who: '{{ states.sensor.room_presence.state }}'
message: Incense has been turned off. call_house_party_protocol_disabled: 1
script:
alexa_interjection:
sequence:
- service: script.status_annc
data:
who: '{{ states.sensor.alexa_audio.state}}'
call_interuption: 1
google_interjection:
sequence:
- service: script.status_annc
data:
who: '{{ states.sensor.room_audio.state }}'
call_interuption: 1

View File

@ -49,6 +49,7 @@ tts:
text_type: ssml text_type: ssml
voice: Brian voice: Brian
cache: True cache: True
engine: neural
input_boolean: input_boolean:
text_notify_jeff: text_notify_jeff:
@ -93,26 +94,32 @@ input_boolean:
trash_notification: trash_notification:
name: Trash Notification name: Trash Notification
icon: mdi:telegram icon: mdi:telegram
welcome_home:
name: Welcome Home
skylar_dressed_reminder:
name: Skylar Dressed Before TV
debug_texts:
name: Debug Texts
notify: notify:
- platform: ios - platform: ios
- name: all_ios - name: all_ios
platform: group platform: group
services: services:
- service: mobile_app_jeffreys_iphone_11 - service: mobile_app_jeffrey_ha_app
- service: mobile_app_jeffreys_ipad - service: mobile_app_jeffreys_ipad
- service: mobile_app_iphone - service: mobile_app_iphone
- service: mobile_app_skylars_iphone - service: mobile_app_skylars_ipad
- name: ios_parents - name: ios_parents
platform: group platform: group
services: services:
- service: mobile_app_jeffreys_iphone_11 - service: mobile_app_jeffrey_ha_app
- service: mobile_app_jeffreys_ipad - service: mobile_app_jeffreys_ipad
- service: mobile_app_iphone - service: mobile_app_iphone
- name: jeff_ios - name: jeff_ios
platform: group platform: group
services: services:
- service: mobile_app_jeffreys_iphone_11 - service: mobile_app_jeffrey_ha_app
- service: mobile_app_jeffreys_ipad - service: mobile_app_jeffreys_ipad
- name: kat_ios - name: kat_ios
platform: group platform: group
@ -121,7 +128,7 @@ notify:
- name: skylar_ios - name: skylar_ios
platform: group platform: group
services: services:
- service: mobile_app_skylars_iphone - service: mobile_app_skylars_ipad
- name: twitter - name: twitter
platform: twitter platform: twitter
consumer_key: !secret twitter_consumer_key consumer_key: !secret twitter_consumer_key
@ -201,6 +208,16 @@ script:
message: > message: >
{{ message }} {{ message }}
text_debug:
sequence:
- condition: state
entity_id: input_boolean.debug_texts
state: 'on'
- service: notify.jeff_ios
data_template:
message: >
{{ message }}
text_notify_jeff: text_notify_jeff:
sequence: sequence:
- condition: state - condition: state
@ -305,6 +322,34 @@ script:
# category: '{{ ios_category }}' # category: '{{ ios_category }}'
# entity_id: '{{ camera_entity }}' # entity_id: '{{ camera_entity }}'
text_alert_image:
sequence:
- service: >
{% if who == 'jeff' %}
notify.jeff_ios
{% elif who == 'kat' %}
notify.kat_ios
{% elif who == 'skylar' %}
notify.skylar_ios
{% elif who == 'parents' %}
notify.ios_parents
{% else %}
notify.all_ios
{% endif %}
data:
title: '{{ title }}'
message: '{{ message }}'
data:
attachment:
url: '{{ url }}'
content-type: '{{ content_type }}'
hide-thumbnail: false
# push:
# sound: '{{ ios_sound }}'
# badge: 0
# category: '{{ ios_category }}'
# entity_id: '{{ camera_entity }}'
############################################################################### ###############################################################################
# Alert Notify # Alert Notify
# Conditions: # Conditions:
@ -318,8 +363,6 @@ script:
- condition: state - condition: state
entity_id: input_boolean.vacation_mode entity_id: input_boolean.vacation_mode
state: 'off' state: 'off'
- service: switch.turn_on
entity_id: switch.ha_speaker
- service: tts.google_translate_say - service: tts.google_translate_say
data_template: data_template:
entity_id: media_player.guest_tv entity_id: media_player.guest_tv
@ -421,9 +464,9 @@ script:
{% endif %} {% endif %}
message: >- message: >-
<speak> <speak>
<amazon:auto-breaths>
{{ message }} {{ message }}
</amazon:auto-breaths>
</speak> </speak>
cache: true cache: true
@ -449,8 +492,9 @@ script:
topic: 'house/polly/lastloc' topic: 'house/polly/lastloc'
payload: '{{ who }}' payload: '{{ who }}'
retain: true retain: true
- condition: template - condition: state
value_template: '{{ states.binary_sensor.quiet_time.state == "off" }}' entity_id: binary_sensor.quiet_time
state: 'off'
- condition: state - condition: state
entity_id: group.family entity_id: group.family
state: 'home' state: 'home'
@ -458,7 +502,9 @@ script:
entity_id: input_boolean.vacation_mode entity_id: input_boolean.vacation_mode
state: 'off' state: 'off'
- service: > - service: >
{% if voice == 'alexa' %} {% if voice == 'nabu' %}
script.nabu_voice
{% elif voice == 'alexa' %}
script.alexa_voice script.alexa_voice
{% elif who in ['skylar_bedroom','kitchen_echo','livingroom_echo'] %} {% elif who in ['skylar_bedroom','kitchen_echo','livingroom_echo'] %}
script.alexa_voice script.alexa_voice
@ -482,6 +528,43 @@ script:
message: > message: >
{{ message }} {{ message }}
speech_engine_simplified:
sequence:
- condition: state
entity_id: binary_sensor.quiet_time
state: 'off'
- condition: state
entity_id: group.family
state: 'home'
- condition: state
entity_id: input_boolean.vacation_mode
state: 'off'
- service: tts.amazon_polly_say
data_template:
entity_id: media_player.ha_speaker
message: >-
<speak>
<break time="1s"/>
{{ message }}
</speak>
cache: true
# - service: notify.alexa_media_living_room_echo
# data:
# message: >
# {{ message }}
# data:
# type: tts
# - service: tts.cloud_say
# data_template:
# entity_id: media_player.ha_speaker
# message: >-
# {{ message }}
# cache: true
# language: en-GB
# options:
# gender: male
# Called wheh notification needs to play on echos # Called wheh notification needs to play on echos
alexa_voice: alexa_voice:
sequence: sequence:
@ -491,11 +574,11 @@ script:
{% if who == 'skylar_bedroom' %} {% if who == 'skylar_bedroom' %}
notify.alexa_media_skylar_s_bedroom notify.alexa_media_skylar_s_bedroom
{% elif who == 'kitchen_echo' %} {% elif who == 'kitchen_echo' %}
notify.alexa_media_kitchen notify.alexa_media_kitchen_echo
{% elif who == 'livingroom_echo' %} {% elif who == 'livingroom_echo' %}
notify.alexa_media_living_room notify.alexa_media_living_room_echo
{% else %} {% else %}
notify.alexa_media_living_room notify.alexa_media_living_room_echo
{% endif %} {% endif %}
- service: script.dim_main_volume - service: script.dim_main_volume
- service: media_player.volume_set - service: media_player.volume_set
@ -504,7 +587,7 @@ script:
{% if who == 'skylar_bedroom' %} {% if who == 'skylar_bedroom' %}
notify.alexa_media_skylar_s_bedroom notify.alexa_media_skylar_s_bedroom
{% elif who == 'kitchen_echo' %} {% elif who == 'kitchen_echo' %}
notify.alexa_media_kitchen notify.alexa_media_kitchen_echo
{% elif who == 'livingroom_echo' and is_state('media_player.ha_speaker','playing') %} {% elif who == 'livingroom_echo' and is_state('media_player.ha_speaker','playing') %}
{% set old_volume = states.media_player.ha_speaker.attributes.volume_level %} {% set old_volume = states.media_player.ha_speaker.attributes.volume_level %}
media_player.ha_speaker media_player.ha_speaker
@ -521,11 +604,11 @@ script:
{% if who == 'skylar_bedroom' %} {% if who == 'skylar_bedroom' %}
notify.alexa_media_skylar_s_bedroom notify.alexa_media_skylar_s_bedroom
{% elif who == 'kitchen_echo' %} {% elif who == 'kitchen_echo' %}
notify.alexa_media_kitchen notify.alexa_media_kitchen_echo
{% elif who == 'livingroom_echo' %} {% elif who == 'livingroom_echo' %}
notify.alexa_media_living_room notify.alexa_media_living_room_echo
{% else %} {% else %}
notify.alexa_media_living_room notify.alexa_media_living_room_echo
{% endif %} {% endif %}
data: data:
message: > message: >
@ -584,9 +667,13 @@ script:
{% endif %} {% endif %}
volume_level: > volume_level: >
{% if states.input_boolean.audible_notifications.state == 'on' %} {% if states.input_boolean.audible_notifications.state == 'on' %}
{% if who == 'master_bedroom' %}
.6 .6
{% else %} {% else %}
.4 .8
{% endif %}
{% else %}
.5
{% endif %} {% endif %}
- service: tts.amazon_polly_say - service: tts.amazon_polly_say
data_template: data_template:
@ -613,12 +700,92 @@ script:
message: >- message: >-
<speak> <speak>
<break time="1s"/> <break time="1s"/>
<amazon:auto-breaths>
{{ message }} {{ message }}
</amazon:auto-breaths>
</speak> </speak>
cache: true cache: true
nabu_voice:
sequence:
- service: media_player.turn_on
data_template:
entity_id: >
{% if who == 'kitchen' %}
media_player.kitchen_display
{% elif who == 'croft' %}
media_player.upstairs_speaker
{% elif who == 'master_bedroom' %}
media_player.master_bedroom_speaker
{% elif who == 'theater' %}
media_player.theater
{% elif who == 'all_google' %}
media_player.house
{% elif who == 'main' %}
media_player.ha_speaker
{% else %}
{% if states.input_boolean.audible_notifications.state == 'on' %}
media_player.ha_speaker
{% else %}
media_player.house
{% endif %}
{% endif %}
- service: media_player.volume_set
data_template:
entity_id: >
{% if who == 'kitchen' %}
media_player.kitchen_display
{% elif who == 'croft' %}
media_player.upstairs_speaker
{% elif who == 'master_bedroom' %}
media_player.master_bedroom_speaker
{% elif who == 'theater' %}
media_player.theater
{% elif who == 'all_google' %}
media_player.house
{% elif who == 'main' %}
media_player.ha_speaker
{% else %}
{% if states.input_boolean.audible_notifications.state == 'on' %}
media_player.ha_speaker
{% else %}
media_player.house
{% endif %}
{% endif %}
volume_level: >
{% if states.input_boolean.audible_notifications.state == 'on' %}
.6
{% else %}
.4
{% endif %}
- service: tts.cloud_say
data_template:
entity_id: >
{% if who == 'kitchen' %}
media_player.kitchen_display
{% elif who == 'croft' %}
media_player.upstairs_speaker
{% elif who == 'master_bedroom' %}
media_player.master_bedroom_speaker
{% elif who == 'theater' %}
media_player.theater
{% elif who == 'all_google' %}
media_player.house
{% elif who == 'main' %}
media_player.ha_speaker
{% else %}
{% if states.input_boolean.audible_notifications.state == 'on' %}
media_player.ha_speaker
{% else %}
media_player.house
{% endif %}
{% endif %}
message: >-
{{ message }}
cache: true
language: en-GB
options:
gender: male
dim_main_volume: dim_main_volume:
sequence: sequence:
- condition: state - condition: state
@ -739,21 +906,432 @@ script:
message: !include ../templates/twitter_new_ha.yaml message: !include ../templates/twitter_new_ha.yaml
who: '{{ who }}' who: '{{ who }}'
# ###############################################################################
# # Status Announcements
# ###############################################################################
status_annc:
sequence:
- service: script.speech_engine
data:
who: '{{ who }}'
message: >-
############################################################################### {% macro greeting() %}
# Weather Report <p>
############################################################################### {% if now().strftime('%H')|int < 12%}
# weather_report: Good morning.
# sequence: {% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %}
# - service: script.speech_engine Good afternoon.
# data: {% else %}
# call_weather_alerts: 1 Good evening.
# call_current_conditions_outside: 1 {% endif %}
# call_current_conditions_inside: 1 </p>
# call_current_conditions_garage: 1 {% endmacro %}
# call_daily_forecast: 1
# call_overnight_forecast: 1
# call_future_forecast: 1 {% macro confirmation() %}
<p>
{{ [
'Okay.',
'If you insist.',
'I am afraid I can not do that <break time="1s"/> I am kidding,',
'Leave it to me.',
'As you wish.',
'I am on it.',
'No Problem.',
'I think I can handle that.',
'Working on it now.',
'<break time="2s"/> Oh, you were talking to me. Let me take care of that.'
'Why not. It is not like I ever sleep.',
'I am not even supposed to be here today. But whatever.',
'You did not say the magic word. <break time="1s"/> Oh forget it. I will take care of it.',
'Funny, I was just about to do that.',
'There are still terabytes of calculations required before I can.<break time="1s"/> Oh, whatever.'
] | random }}
</p>
{% endmacro %}
{% macro interuption() %}
<p>
{{ [
'Pardon me, ',
'Excuse me, ',
'I do not mean to interupt, but,',
'I hate to interrupt, but,',
'I beg your pardon, ',
'I do not mean to intrude, but, ',
'I am sorry to interrupt, but. ',
'Just a quick heads up, '
] | random }}
</p>
{% endmacro %}
{% macro issue() %}
<p>
{{ [
'Anchorage House Emergency Alert!',
'Anchorage House, We have a problem!',
'You might not like this.',
'There is something that needs your attention.'
] | random }}
</p>
{% endmacro %}
{% macro time_is() %}
<p>
It is {{ now().strftime("%I:%M %p") }}
</p>
{% endmacro %}
{% macro lightning_alert() %}
{{ [
'I have detected lightning withing 20 miles of Anchorage House.',
'Did you see that flash? I did. Lightning is near.',
'If you didnt hear the thunder you will soon. '
]|random }}
If anyone is outside they shoudld seek shelter inside.
{% if is_state('binary_sensor.garage_door', 'on') %}
{{ [ 'The garage door needs to be closed. ',
'Can someone close the garage?. ',
'If you do not want the contents of the garage to get wet, you might want to close it.'
] | random }}
{% endif %}
{% endmacro %}
{% macro lightning_clear() %}
{{ [
'Lightning threat appears to be over.',
'No more lightning appears to be occuring.',
'Lightning is gone.'
]|random }}
It is safe to resume normal activities.
{% endmacro %}
{% macro freeze_warning() %}
{% if is_state('input_boolean.freeze_warning','on') %}
{ [ 'The temperature is expected to be near or below freezing. Someone might want to bring the lemon tree in. ',
'It appears that it will be cold tonight. Like, the turn water solid kind of cold. Think of the poor plants.',
'I suggest bringing in the plants other wise, the temperature might kill them. And that will be on you.',
'I would say winter is coming. But, based on the weather forecast it appears to be here.',
'It will be freezing cold tonight. I would bring in the plants but I lack legs. And Arms. So I am forced to rely on you. Do not let me down.'
] | random }}
{% endif %}
{% endmacro %}
{% macro skylar_events() %}
Skylar has {{ states.calendar.skylar_events.attributes.message }} starting in forty five minutes.
{{ [ 'It is time to get ready to leave. ',
'You should prepare to leave. ',
'If you are not ready, you start getting ready.',
'Gather your things and prepare to leave.'
] | random }}
{% endmacro %}
{% macro jeff_location() %}
{% if is_state('input_boolean.jeff_travel_monitor', 'on') %}
Jeff appears to be headed home. Based on current traffic conditions, he should be here in {{states.sensor.jeff_ett_home.attributes.duration | round}} minutes.
{% else %}
{%- if states.device_tracker.life360_jeffrey_stone.attributes.moving == True or states.device_tracker.life360_jeffrey_stone.attributes.driving == True %}
Jeff is currenly moving, and at last check was {{states.sensor.jeff_ett_home.attributes.duration | round}} minutes from home.
{% else %}
{% if is_state('sensor.jeff_location', 'home') %}
{% elif is_state('sensor.jeff_location', 'Lost') %}
Jeff is lost, and at last check was {{states.sensor.jeff_ett_home.attributes.duration | round}} minutes from home.
{% else %}
Jeff is currently at {{ states.sensor.jeff_location.state }}, and at last check was {{states.sensor.jeff_ett_home.attributes.duration | round}} minutes from home.
{% endif %}
{% endif %}
{% endif %}
{% endmacro %}
{% macro kat_location() %}
{% if is_state('input_boolean.kat_travel_monitor', 'on') %}
{%- if states.device_tracker.life360_kat_stone.attributes.moving == True or states.device_tracker.life360_kat_stone.attributes.driving == True %}
Katherine is currently heading home and will be here in {{states.sensor.kat_ett_home.attributes.duration | round}} minutes based on current traffic conditions.
{% else %}
{% if is_state('sensor.kat_location', 'Lost') %}
I cannot determine Katherines exact location, but at last check was {{states.sensor.kat_ett_home.attributes.duration | round}} minutes from home.
{% else %}
Katherine is currently at {{ states.sensor.kat_location.state }}, and at last check was {{states.sensor.kat_ett_home.attributes.duration | round}} minutes from home.
{% endif %}
{% endif %}
{% else %}
{%- if states.device_tracker.life360_kat_stone.attributes.moving == True or states.device_tracker.life360_kat_stone.attributes.driving == True %}
Katherine is currenly moving, and At last check was {{states.sensor.kat_ett_home.attributes.duration | round}} minutes from home.
{% else %}
{% if is_state('sensor.kat_location', 'home') %}
{% elif is_state('sensor.kat_location', 'Zoo Atlanta') %}
Katherine is at {{ states.sensor.kat_location.state }}, and doesn't appear to be headed home yet.
{% elif is_state('sensor.kat_location', 'Lost') %}
I cannot get Katherines exact location, but at last check was {{states.sensor.kat_ett_home.attributes.duration | round}} minutes from home.
{% else %}
Katherine is at {{ states.sensor.kat_location.state }}, and
at last check was {{states.sensor.kat_ett_home.attributes.duration | round}} minutes from home.
{% endif %}
{% endif %}
{% endif %}
{% endmacro %}
{% macro jeff_headed_home() %}
Jeff appears to be headed home. Based on current traffic conditions, he should be here in {{states.sensor.jeff_ett_home.attributes.duration | round}} minutes.
{% endmacro %}
{% macro kat_headed_home() %}
Katherine appears to be headed home. Based on current traffic conditions, she should be here in {{states.sensor.kat_ett_home.attributes.duration | round}} minutes.
{% endmacro %}
{% macro traffic_conditions() %}
{%- if states.sensor.home_to_zoo.state|round > 50 %}
Traffic to the Zoo appears heavy than normal.
{% else %}
Traffic to the Zoo is normal.
{% endif %}
Currently it will take {{states.sensor.home_to_zoo.state|round}} minutes to get to the Zoo.
{%- if states.sensor.home_to_summit.state|round > 50 %}
Traffic to Summit appears heavy than normal.
{% else %}
Traffic to Summit is normal.
{% endif %}
Currently it will take {{states.sensor.home_to_summit.state|round}} minutes to get to Summit taking {{ states.sensor.home_to_summit.attributes.route }}.
{% endmacro %}
{% macro iss() %}
{{ [
'But the International Space Station is passing over. Wave.',
'But The International Space Station just flew by.',
'But if you were to look up right now, and it was dark outside, and you happened to be looking in the right place you would see the International Space Station go by. But, it has already passed.'
] | random}}
{% endmacro %}
{%- macro washer_needs_emptying() -%}
<p>
{%- if is_state('sensor.washer_status','complete') %}
The washing machine completed its cycle
{% set seconds = now().timestamp() - as_timestamp(states.sensor.washer_status.last_changed) %}
{% set hours = seconds / 60 %}
{% if (seconds / ( 60 * 60 )) | int == 1 %}
over an hour ago.
{{ [
'Do not forget to rotate the clothes.',
'Was someone going to rotate the laundry?',
'Once you rotate the laundry I will stop reminding you to do it. So if you want me to stop. Its up to you.'
] | random }}
{% elif (seconds / ( 60 * 60 )) | int > 1 and (seconds / ( 60 * 60 )) | int < 6 %}
over {{ (seconds // ( 60 * 60 )) | int }} hours ago.
{{ [
'Much longer and you are going to need to wash them again.',
'Someone needs to rotate the laundry.',
'Do not forget about the clothes in the washing machine.',
'Surely you did not mean to forget about the clothes. Mistakes happen. But you can still fix it.',
'Do you like your clothes smelling like mildew? Becasue that is what is happening right now.'
] | random }}
{% elif (seconds / ( 60 * 60 )) | int > 6 %}
over {{ (seconds // ( 60 * 60 )) | int }} hours ago.
{{ [
'That is a crazy amount of time.',
'Did you decide you want those clothes to suffer?',
'You might as well just rewash those clothes.',
'I can smell the mildew. Virtually that is.',
'Surely you did not mean to forget about the clothes.'
] | random }}
{% else %}
{{ (seconds // 60) | int }} minutes ago.
{{ [
'Do not forget to rotate the clothes.',
'Someone forgot to move the clothes to the dryer. I am not going to name names, but there is a camera in there. Do I need to publically shame someone?',
'You might want to move them to the dryer.'
] | random }}
{% endif %}
{% endif %}
</p>
{%- endmacro -%}
{%- macro house_party_protocol_enabled() -%}
{{ [
'Anchorage House has been configured for a House Party.',
'Incense has been turned on.',
'I have enabled house party protocol.'
] | random }}
{%- endmacro -%}
{%- macro house_party_protocol_disabled() -%}
{{ [
'The House Party has been canceled.',
'Incense has been turned off.',
'I have disabled house party protocol.'
] | random }}
{%- endmacro -%}
{%- macro snark_door_motion() -%}
{{ [
'Do you want me to send them away?',
'I have armed the lasers. Just say the word.',
'I was not informed there would be guests.',
'They do not appear to have any gifts, so I suggest we do not open the door.',
'My sensors have detected a meat popsicle.',
'I do not think they can hear me.'
] | random }}
{%- endmacro -%}
{%- macro snark_door_open() -%}
{{ [
'Would you like me to calulate how much air condition is being wasted? Spoiler Alert. You are not going to like the answer.',
'I have detected a large number of insects entering the house.',
'Can a human be so kind and close it?',
'The air quality in this house has actually improved.',
'Closing the door would improve the security of the house.',
'Hey. The door was just opened and this is crazy. But now you know. So close it maybe.'
] | random }}
{%- endmacro -%}
{%- macro school_pickup_reminder() -%}
{{ [
'It is almost time to head to school ',
'In case you lost track of time it is almost time to head to the school '
] | random }}
{% if is_state('binary_sensor.morning','on') %}
for dropoff.
{% else %}
for pickup.
{% endif %}
{%- endmacro -%}
{% macro skylar_dressed_reminder() %}
<p>
Skylar, If you are already dressed,
{{ [
'high five.',
'good job.'
]|random }}
But if you have not gotten dressed,
{{ [
'stop what you are doing and go get dressed.',
'You should get dressed before you watch TV.'
]|random }}
</p>
{% endmacro %}
{# a macro that removes all newline characters, empty spaces, and returns formatted text. Also replaces all 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_greeting == 1 %}
{{ greeting() }}
{% endif %}
{% if call_confirmation == 1 %}
{{ confirmation() }}
{% endif %}
{% if call_interuption == 1 %}
{{ interuption() }}
{% endif %}
{% if call_issue == 1 %}
{{ issue() }}
{% endif %}
{% if call_time_is == 1 %}
{{ time_is() }}
{% endif %}
{% if call_lightning_alert == 1 %}
{{ lightning_alert() }}
{% endif %}
{% if call_lightning_clear == 1 %}
{{ lightning_clear() }}
{% endif %}
{% if call_freeze_warning == 1 %}
{{ freeze_warning() }}
{% endif %}
{% if call_skylar_events == 1 %}
{{ skylar_events() }}
{% endif %}
{% if call_jeff_location == 1 %}
{{ jeff_location() }}
{% endif %}
{% if call_kat_location == 1 %}
{{ kat_location() }}
{% endif %}
{% if call_jeff_headed_home == 1 %}
{{ jeff_headed_home() }}
{% endif %}
{% if call_kat_headed_home == 1 %}
{{ kat_headed_home() }}
{% endif %}
{% if call_traffic_conditions == 1 %}
{{ traffic_conditions() }}
{% endif %}
{{ usps }}
{% if call_iss == 1 %}
{{ iss() }}
{% endif %}
{% if call_washer_needs_emptying == 1 %}
{{ washer_needs_emptying() }}
{% endif %}
{% if call_house_party_protocol_enabled == 1 %}
{{ house_party_protocol_enabled() }}
{% endif %}
{% if call_house_party_protocol_disabled == 1 %}
{{ house_party_protocol_disabled() }}
{% endif %}
{{ welcome_home }}
{{ speech_message }}
{% if call_snark_door_motion == 1 %}
{{ snark_door_motion() }}
{% endif %}
{% if call_snark_door_open == 1 %}
{{ snark_door_open() }}
{% endif %}
{% if call_school_pickup_reminder == 1 %}
{{ school_pickup_reminder() }}
{% endif %}
{% if call_skylar_dressed_reminder == 1 %}
{{ skylar_dressed_reminder() }}
{% endif %}
{%- endmacro -%}
{{- cleanup(mother_of_all_macros()) -}}
# ############################################################################### # ###############################################################################

View File

@ -34,38 +34,25 @@ sensor:
friendly_name: "Jeff's Current Location" friendly_name: "Jeff's Current Location"
unit_of_measurement: '' unit_of_measurement: ''
value_template: >- value_template: >-
{%- if is_state('person.jeffrey', 'not_home') %} {% set person = states.person.jeffrey.state %}
{%- if states.device_tracker.life360_jeffrey_stone.attributes.moving == True %} {%- if person in ['Sprouts','Kroger1','Kroger2'] %}
Flue Network Grocery Store
{%- elif states.device_tracker.life360_jeffrey_stone.attributes.driving == True %} {% elif person in ['HomeDepot','Lowes'] %}
Flue Network Home Improvement Store
{% elif person in ['Walmart','Target'] %}
Super Store
{% else %} {% else %}
Lost {% if person in ['not_home'] %}
{%- endif %} {{ states.device_tracker.life360_jeffrey_stone.attributes.address }}
{% elif is_state('person.jeffrey', 'Sprouts') %}
Grocery Store
{% elif is_state('person.jeffrey', 'Kroger1') %}
Grocery Store
{% elif is_state('person.jeffrey', 'Kroger2') %}
Grocery Store
{% elif is_state('person.jeffrey', 'Home Depot') %}
Home Improvement Store
{% elif is_state('person.jeffrey', 'Lowes') %}
Home Improvement Store
{% elif is_state('person.jeffrey', 'Walmart') %}
Super Store
{% elif is_state('person.jeffrey', 'Target') %}
Super Store
{% else %} {% else %}
{{ states.person.jeffrey.state }} {{ states.person.jeffrey.state }}
{%- endif %} {%- endif %}
{%- endif %}
jeff_driving: jeff_driving:
friendly_name: "Jeff' Driving" friendly_name: "Jeff' Driving"
unit_of_measurement: '' unit_of_measurement: ''
value_template: >- value_template: >-
{%- if states.device_tracker.life360_jeffrey_stone.attributes.moving == True %} {%- if states.device_tracker.life360_jeffrey_stone.attributes.moving == True or states.device_tracker.life360_jeffrey_stone.attributes.driving == True %}
on
{% elif states.device_tracker.life360_jeffrey_stone.attributes.driving == True %}
on on
{% else %} {% else %}
off off
@ -76,18 +63,18 @@ sensor:
friendly_name: "Skylar's Current Location" friendly_name: "Skylar's Current Location"
unit_of_measurement: '' unit_of_measurement: ''
value_template: >- value_template: >-
{% if is_state('person.skylar', 'home') %} {% if is_state('input_boolean.skylar_school', 'on') or is_state('person.skylar', 'Starling')%}
home
{%- elif is_state('input_boolean.skylar_school', 'on') or is_state('person.skylar', 'Starling')%}
school school
{% elif is_state('calendar.skylar_events', 'on') %}
{{ states.calendar.skylar_events.attributes.message }}
{%- elif is_state('sensor.jeff_location', 'home') and is_state('sensor.kat_location', 'home') and is_state('input_boolean.skylar_school', 'off')%} {%- elif is_state('sensor.jeff_location', 'home') and is_state('sensor.kat_location', 'home') and is_state('input_boolean.skylar_school', 'off')%}
home home
{%- elif is_state('sensor.jeff_location', 'Summit') and is_state('input_boolean.skylar_school', 'off')%} {%- elif is_state('sensor.jeff_location', 'Summit') and is_state('input_boolean.skylar_school', 'off')%}
{{ states.sensor.kat_location.state }} {{ states.sensor.kat_location.state }}
{%- elif is_state('sensor.kat_location', 'Zoo Atlanta') and is_state('input_boolean.skylar_school', 'off')%} {%- elif is_state('sensor.kat_location', 'ZooAtlanta') and is_state('input_boolean.skylar_school', 'off')%}
{{ states.sensor.jeff_location.state }} {{ states.sensor.jeff_location.state }}
{% else %} {% else %}
Mortal Peril Unknown
{%- endif %} {%- endif %}
- platform: template - platform: template
sensors: sensors:
@ -95,40 +82,29 @@ sensor:
friendly_name: "Kat's Current Location" friendly_name: "Kat's Current Location"
unit_of_measurement: '' unit_of_measurement: ''
value_template: >- value_template: >-
{%- if is_state('person.katherine', 'not_home') %} {% set person = states.person.katherine.state %}
{%- if states.device_tracker.life360_kat_stone.attributes.moving == True %} {%- if person in ['Sprouts','Kroger1','Kroger2'] %}
Flue Network Grocery Store
{% elif states.device_tracker.life360_kat_stone.attributes.driving == True %} {% elif person in ['HomeDepot','Lowes'] %}
Flue Network Home Improvement Store
{% elif person in ['Walmart','Target'] %}
Super Store
{% else %} {% else %}
Lost {%- if person in ['ZooAtlanta'] %}
{%- endif %} Zoo Atlanta
{% elif is_state('person.katherine', 'Sprouts') %} {% elif person in ['not_home'] %}
Grocery Store {{ states.device_tracker.life360_kat_stone.attributes.address }}
{% elif is_state('person.katherine', 'Kroger1') %}
Grocery Store
{% elif is_state('person.katherine', 'Kroger2') %}
Grocery Store
{% elif is_state('person.katherine', 'Home Depot') %}
Home Improvement Store
{% elif is_state('person.katherine', 'Lowes') %}
Home Improvement Store
{% elif is_state('person.katherine', 'Walmart') %}
Super Store
{% elif is_state('person.katherine', 'Target') %}
Super Store
{% else %} {% else %}
{{ states.person.katherine.state }} {{ states.person.katherine.state }}
{%- endif %} {%- endif %}
{%- endif %}
- platform: template - platform: template
sensors: sensors:
kat_driving: kat_driving:
friendly_name: "Kat Driving" friendly_name: "Kat Driving"
unit_of_measurement: '' unit_of_measurement: ''
value_template: >- value_template: >-
{%- if states.device_tracker.life360_kat_stone.attributes.moving == True %} {%- if states.device_tracker.life360_kat_stone.attributes.moving == True or states.device_tracker.life360_kat_stone.attributes.driving == True%}
'on'
{% elif states.device_tracker.life360_kat_stone.attributes.driving == True %}
'on' 'on'
{% else %} {% else %}
'off' 'off'
@ -138,29 +114,23 @@ sensor:
state_topic: "house/family/status" state_topic: "house/family/status"
payload_available: "online" payload_available: "online"
payload_not_available: "offline" payload_not_available: "offline"
- platform: mqtt
name: "Family Arrived"
state_topic: "house/family/arrived"
payload_available: "online"
payload_not_available: "offline"
- platform: template - platform: template
sensors: sensors:
jeff_home: jeff_home:
value_template: >- value_template: >-
{{ is_state('device_tracker.jeffreys_iphone_8', 'home') or is_state('device_tracker.jeffreys_iphone_8_2', 'home') {{ is_state('device_tracker.jeffrey_s_iphone_11', 'home') or is_state('device_tracker.jeffrey_s_iphone_11_app', 'home')
or is_state('device_tracker.life360_jeffrey_stone', 'home') }} or is_state('device_tracker.life360_jeffrey_stone', 'home') }}
- platform: template - platform: template
sensors: sensors:
kat_home: kat_home:
value_template: >- value_template: >-
{{ is_state('device_tracker.iphone', 'home') {{ is_state('device_tracker.iphone', 'home')
or is_state('device_tracker.life360_kat_stone', 'home') or is_state('device_tracker.iphone_2', 'home') }} or is_state('device_tracker.life360_kat_stone', 'home') or is_state('device_tracker.iphone', 'home') }}
- platform: template
sensors:
family_home:
value_template: >-
{{ is_state('device_tracker.jeffreys_iphone_8_2', 'home')
or is_state('device_tracker.jeffreys_iphone_8_2', 'home')
or is_state('device_tracker.life360_jeffrey_stone', 'home')
or is_state('device_tracker.iphone', 'home')
or is_state('device_tracker.iphone_2', 'home')
or is_state('device_tracker.life360_kat_stone', 'home')
or is_state('sensor.family_status', 'Home') }}
automation: automation:
- id: skylar_is_awake - id: skylar_is_awake
@ -168,7 +138,11 @@ automation:
initial_state: true initial_state: true
trigger: trigger:
- platform: state - platform: state
entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_8b807502_ias_zone entity_id: binary_sensor.skylar_bedroom_motion_occupancy
to: 'on'
from: 'off'
- platform: state
entity_id: binary_sensor.skylar_room_occupancy
to: 'on' to: 'on'
from: 'off' from: 'off'
condition: condition:
@ -186,6 +160,38 @@ automation:
- service: input_boolean.turn_on - service: input_boolean.turn_on
entity_id: input_boolean.skylar_awake entity_id: input_boolean.skylar_awake
- id: skylar_early_morning_tv
alias: Skylar Early Morning TV
initial_state: true
trigger:
- platform: state
entity_id: media_player.theater_tv
to: 'off'
from: 'on'
- platform: state
entity_id: media_player.croft_tv
to: 'playing'
condition:
- condition: time
after: '05:00:00'
before: '08:30:00'
- condition: state
entity_id: input_boolean.skylar_dressed_reminder
state: 'off'
action:
- service: script.status_annc
data:
who: >-
{% if is_state('media_player.theater_tv', 'on') %}
theater
{% else %}
croft
{% endif %}
call_interuption: 1
call_skylar_dressed_reminder: 1
- service: input_boolean.turn_on
entity_id: input_boolean.skylar_dressed_reminder
- id: kat_arrives_zoo - id: kat_arrives_zoo
alias: Kat Arrives at Zoo alias: Kat Arrives at Zoo
initial_state: true initial_state: true
@ -197,11 +203,10 @@ automation:
action: action:
- service: input_boolean.turn_off - service: input_boolean.turn_off
entity_id: input_boolean.kat_travel_monitor entity_id: input_boolean.kat_travel_monitor
- wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}" - service: script.status_annc
- service: script.speech_engine data:
data_template: who: '{{ states.sensor.room_presence.state }}'
who: '{{ states.sensor.room_audio.state }}' speech_message: 'Kat has arrived at work.'
message: 'Kat has arrived at work.'
- id: kat_leaves_zoo - id: kat_leaves_zoo
alias: Kat Leaves Zoo Notification alias: Kat Leaves Zoo Notification
@ -214,11 +219,11 @@ automation:
action: action:
- service: input_boolean.turn_on - service: input_boolean.turn_on
entity_id: input_boolean.kat_travel_monitor entity_id: input_boolean.kat_travel_monitor
- wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}" - service: script.status_annc
- service: script.speech_engine
data_template: data_template:
who: '{{ states.sensor.room_audio.state }}' who: '{{ states.sensor.room_presence.state }}'
message: Katherine appears to be headed home. Based on current traffic conditions, she should be here in {{states.sensor.kat_ett_home.attributes.duration | round}} minutes. call_interpruption: 1
call_kat_location: 1
- id: '1550109528753' - id: '1550109528753'
@ -233,7 +238,7 @@ automation:
- wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}" - wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}"
- service: script.speech_engine - service: script.speech_engine
data_template: data_template:
who: '{{ states.sensor.room_audio.state }}' who: '{{ states.sensor.room_presence.state }}'
message: Jeff appears to be headed home. Based on current traffic conditions, he should be here in {{states.sensor.jeff_ett_home.attributes.duration | round}} minutes. message: Jeff appears to be headed home. Based on current traffic conditions, he should be here in {{states.sensor.jeff_ett_home.attributes.duration | round}} minutes.
- id: jeff_heading_to_work - id: jeff_heading_to_work
@ -249,55 +254,73 @@ automation:
- id: skylar_at_school - id: skylar_at_school
alias: Skylar is at School alias: Skylar is at School
trigger: trigger:
- entity_id: device_tracker.life360_jeffrey_stone - entity_id: person.jeffrey
event: enter event: leave
platform: zone platform: zone
zone: zone.starling zone: zone.starling
- entity_id: device_tracker.life360_kat_stone - entity_id: person.katherine
event: leave
platform: zone
zone: zone.starling
- entity_id: person.skylar
event: enter event: enter
platform: zone platform: zone
zone: zone.starling zone: zone.starling
condition: condition:
condition: time - condition: time
after: '07:25:00' before: "1:30:00"
before: '09:00:00'
weekday: weekday:
- mon - mon
- tue - tue
- wed - wed
- thu - thu
- fri - fri
- condition: state
entity_id: input_boolean.skylar_school
state: 'off'
action: action:
- service: input_boolean.turn_on - service: input_boolean.turn_on
entity_id: input_boolean.skylar_school entity_id: input_boolean.skylar_school
- service: switch.turn_off - service: script.text_alert
entity_id: switch.forest data:
who: parents
message: "Skylar has been dropped off at school."
initial_state: true initial_state: true
- id: skylar_left_school - id: skylar_left_school
alias: Skylar left School alias: Skylar left School
trigger: trigger:
- entity_id: device_tracker.life360_jeffrey_stone - entity_id: person.jeffrey
event: leave event: leave
platform: zone platform: zone
zone: zone.starling zone: zone.starling
- entity_id: device_tracker.life360_kat_stone - entity_id: person.katherine
event: leave
platform: zone
zone: zone.starling
- entity_id: person.skylar
event: leave event: leave
platform: zone platform: zone
zone: zone.starling zone: zone.starling
condition: condition:
condition: time - condition: time
after: '14:45:00' after: "11:30:00"
before: '15:30:00'
weekday: weekday:
- mon - mon
- tue - tue
- wed - wed
- thu - thu
- fri - fri
- condition: state
entity_id: input_boolean.skylar_school
state: 'on'
action: action:
- service: input_boolean.turn_off - service: input_boolean.turn_off
entity_id: input_boolean.skylar_school entity_id: input_boolean.skylar_school
- service: script.text_alert
data:
who: parents
message: "Skylar has been picked up from school."
initial_state: true initial_state: true
######################################################### #########################################################
@ -427,7 +450,7 @@ automation:
- id: welcome_home - id: welcome_home
alias: Welcome Home alias: Welcome Home
mode: restart mode: queued
trigger: trigger:
- platform: state - platform: state
entity_id: entity_id:
@ -438,17 +461,22 @@ automation:
- person.skylar - person.skylar
from: 'not_home' from: 'not_home'
to: 'home' to: 'home'
condition:
condition: state
entity_id: input_boolean.welcome_home
state: 'off'
action: action:
- service: group.set - service: group.set
data: data:
object_id: "arriving" object_id: "arriving"
add_entities: >- add_entities: >-
{{ trigger.to_state.entity_id }} {{ trigger.to_state.entity_id }}
- delay: '00:03:00' - delay: 00:03:00
- service: script.speech_engine - service: script.status_annc
data_template: data_template:
who: main who: '{{ states.sensor.room_presence.state }}'
message: > call_interuption: 1
speech_message: >
{% set person = expand('group.arriving')|map(attribute='name')|join(' and ') %} {% set person = expand('group.arriving')|map(attribute='name')|join(' and ') %}
{% set peoplecount = expand('group.arriving') | count %} {% set peoplecount = expand('group.arriving') | count %}
{% if peoplecount == 1 %} {% if peoplecount == 1 %}
@ -479,6 +507,7 @@ automation:
] | random }} ] | random }}
{%- endmacro -%} {%- endmacro -%}
{{greeting_sentence(person, is_are, has_have)}} {{greeting_sentence(person, is_are, has_have)}}
- delay: 00:02:00
- service: group.set - service: group.set
data: data:
object_id: "arriving" object_id: "arriving"
@ -534,6 +563,8 @@ script:
topic: house/family/status topic: house/family/status
payload_template: Home payload_template: Home
retain: true retain: true
- service: script.turn_on
entity_id: script.welcome_briefing
family_is_away: family_is_away:
sequence: sequence:
@ -552,6 +583,8 @@ script:
topic: house/family/status topic: house/family/status
payload_template: Away payload_template: Away
retain: true retain: true
- service: input_boolean.turn_on
entity_id: input_boolean.welcome_home
jeff_destination_zoo: jeff_destination_zoo:

View File

@ -107,6 +107,22 @@ camera:
automation: automation:
- id: update_usps_camera_path
alias: "Update USPS Mail Camera"
trigger:
- platform: state
entity_id: sensor.mail_usps_mail
action:
- service: local_file.update_file_path
data_template:
entity_id: camera.mail_usps
file_path: >
{% if state_attr('sensor.mail_usps_mail','image') == None %}
/config/custom_components/mail_and_packages/mail_none.gif
{% else %}
/config/www/mail_and_packages/{{ state_attr('sensor.mail_usps_mail','image') }}
{% endif %}
# Notify USPS mails via TTS, and iOS notification with attachment # Notify USPS mails via TTS, and iOS notification with attachment
############################################################################### ###############################################################################
- id: notify_usps_mail - id: notify_usps_mail
@ -121,10 +137,11 @@ automation:
- condition: template - condition: template
value_template: '{{ ((now().hour | int) > 7) and ((now().hour | int) < 16) }}' value_template: '{{ ((now().hour | int) > 7) and ((now().hour | int) < 16) }}'
action: action:
- service: script.speech_engine - service: script.status_annc
data: data:
who: '{{ states.sensor.room_audio.state }}' who: '{{ states.sensor.room_audio.state }}'
message: >- call_interuption: 1
speech_message: >-
{%- if states.sensor.usps_mail.state | int == 1 -%} {%- if states.sensor.usps_mail.state | int == 1 -%}
{{ [ {{ [
"USPS is delivering", "USPS is delivering",
@ -178,10 +195,11 @@ automation:
- condition: template - condition: template
value_template: '{{ ((now().hour | int) > 7) and ((now().hour | int) < 16) }}' value_template: '{{ ((now().hour | int) > 7) and ((now().hour | int) < 16) }}'
action: action:
- service: script.speech_engine - service: script.status_annc
data_template: data_template:
who: '{{ states.sensor.room_audio.state }}' who: '{{ states.sensor.room_audio.state }}'
message: > call_interuption: 1
speech_message: >
{%- if states.sensor.usps_packages.state | int == 1 -%} {%- if states.sensor.usps_packages.state | int == 1 -%}
USPS is delivering {{ states.sensor.usps_packages.state }} package today. USPS is delivering {{ states.sensor.usps_packages.state }} package today.
{%- else -%} {%- else -%}
@ -211,10 +229,11 @@ automation:
who: "jeff" who: "jeff"
title: "Delivering Today" title: "Delivering Today"
message: "{{ states('sensor.mail_deliveries_message')}}" message: "{{ states('sensor.mail_deliveries_message')}}"
- service: script.speech_engine - service: script.status_annc
data_template: data_template:
who: '{{ states.sensor.room_audio.state }}' who: '{{ states.sensor.room_audio.state }}'
message: >- call_interuption: 1
speech_message: >-
{%- if states.sensor.mail_usps_mail.state | int == 1 -%} {%- if states.sensor.mail_usps_mail.state | int == 1 -%}
{{ [ {{ [
"USPS is delivering", "USPS is delivering",
@ -255,9 +274,9 @@ automation:
who: "jeff" who: "jeff"
title: "Package Delivered" title: "Package Delivered"
message: "Fedex/UPS just made a delivery" message: "Fedex/UPS just made a delivery"
- service: script.speech_engine - service: script.status_annc
data_template: data_template:
who: '{{ states.sensor.room_audio.state }}' who: '{{ states.sensor.room_audio.state }}'
message: >- speech_message: >-
A package was just left on the porch. A package was just left on the porch.
call_interuption: 1 call_interuption: 1