From 780653212317a472fe787f7504032ae824021688 Mon Sep 17 00:00:00 2001 From: Jeffrey Stone Date: Fri, 4 Dec 2020 12:55:04 -0500 Subject: [PATCH] Changing all speech notifications to go through new speech engine. --- config/automations.yaml | 2 +- config/groups.yaml | 13 ++++ config/packages/announcements.yaml | 40 ++++++----- config/packages/appliances.yaml | 6 +- config/packages/audio.yaml | 37 ++++++---- config/packages/events.yaml | 6 +- config/packages/jarvis.yaml | 4 +- config/packages/presence.yaml | 8 +-- config/packages/security.yaml | 22 +++--- config/packages/space.yaml | 6 +- config/packages/usps.yaml | 8 +-- config/packages/weather.yaml | 70 +++++++++---------- config/sensors/google_travel_time.yaml | 1 - config/sensors/house.yaml | 4 +- config/templates/speech/morning_briefing.yaml | 6 +- 15 files changed, 129 insertions(+), 104 deletions(-) diff --git a/config/automations.yaml b/config/automations.yaml index cc15b8c..ee1e711 100644 --- a/config/automations.yaml +++ b/config/automations.yaml @@ -254,7 +254,7 @@ entity_id: binary_sensor.front_door state: 'off' action: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: '{{ [ "I have detected motion at the ", "Someone may be at the diff --git a/config/groups.yaml b/config/groups.yaml index 9a6bf9d..ec5a46e 100755 --- a/config/groups.yaml +++ b/config/groups.yaml @@ -18,6 +18,19 @@ House Conditions: - sensor.accurite_garage_temperature - sensor.accurite_garage_humidity +occupancy: + - binary_sensor.kitchen_occupancy + - binary_sensor.living_room_occupancy + - binary_sensor.master_bedroom_occupancy + - binary_sensor.skylar_room_occupancy + - binary_sensor.croft_occupancy + - binary_sensor.theater_occupancy + +audio_devices: + - media_player.kitchen_display + - media_player.upstairs_speaker + - media_player.master_bedroom_speaker + Outside Lights: - switch.driveway_light - switch.front_porch_light diff --git a/config/packages/announcements.yaml b/config/packages/announcements.yaml index 17e2119..bd16bb2 100755 --- a/config/packages/announcements.yaml +++ b/config/packages/announcements.yaml @@ -100,7 +100,7 @@ automation: to: 'on' condition: - condition: time - after: '07:00:00' + after: '06:45:00' before: '08:30:00' - condition: state entity_id: input_boolean.good_morning_report @@ -200,64 +200,66 @@ script: security_briefing: sequence: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.alexa_audio.state }}' message: !include ../templates/speech/security_report.yaml event_briefing: sequence: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.alexa_audio.state }}' message: !include ../templates/speech/event_briefing.yaml - skylar_morning_briefing_jarvis: + skylar_morning_briefing: sequence: - - service: script.jarvis_voice + - service: > + {%- if is_state('binary_sensor.theater_occupancy', 'on') and is_state('media_player.theater_tv', 'on') %} + script.speech_engine + {% else %} + script.alexa_voice + {%- endif %} data: - who: main + who: > + {%- if is_state('binary_sensor.theater_occupancy', 'on') and is_state('media_player.theater_tv', 'on') %} + theater + {% else %} + skylar_bedroom + {%- endif %} message: !include ../templates/speech/skylar_morning_briefing.yaml - skylar_morning_briefing_alexa: - sequence: - - service: notify.alexa_media_skylar_s_bedroom - data: - message: !include ../templates/speech/skylar_morning_briefing.yaml - data: - type: tts - skylar_nightly_briefing: sequence: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: !include ../templates/speech/skylar_nightly_briefing.yaml nightly_briefing_report: sequence: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: !include ../templates/speech/nightly_briefing.yaml sundown_briefing: sequence: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: !include ../templates/speech/sundown_briefing.yaml morning_briefing: sequence: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: kitchen message: !include ../templates/speech/morning_briefing.yaml morning_wakeup_report: sequence: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: master_bedroom message: !include ../templates/speech/morning_wakeup_report.yaml diff --git a/config/packages/appliances.yaml b/config/packages/appliances.yaml index 89b7a01..1476039 100755 --- a/config/packages/appliances.yaml +++ b/config/packages/appliances.yaml @@ -149,7 +149,7 @@ script: - condition: state entity_id: sensor.washer_status state: complete - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: > @@ -157,10 +157,10 @@ script: {{ [ 'Just a reminder. Washing machine needs to be emptied.', 'I am sure you have more inportant things to do, but do not forget to empty the washer.', - 'Looks like the washing machine has completed it is cycle. You know what to do. I hope.', + 'Looks like the washing machine has completed it is cycle. You know what to do,,I hope.', 'Do not forget to move the clothes to the dryer.', 'Someone forgot to move the clothes to the dryer. I am not going to name any names. But there is a camera in there. ', - 'Do you like when your clothes smell like mildew? Because that is what is happeneing. Right now. ' + 'Do you like when your clothes smell like mildew? Because that is what is happening,,Right now. ' ] | random }}

diff --git a/config/packages/audio.yaml b/config/packages/audio.yaml index 6b3b56c..1ac12a9 100755 --- a/config/packages/audio.yaml +++ b/config/packages/audio.yaml @@ -113,19 +113,30 @@ sensor: room_audio: friendly_name: "Room Audio" value_template: >- - {%- if is_state('binary_sensor.theater_occupancy', 'on') and is_state('media_player.theater_tv', 'on') %} - theater - {% elif is_state('binary_sensor.kitchen_occupancy', 'on') %} - kitchen - {% elif is_state('binary_sensor.living_room_occupancy', 'on') and is_state('input_boolean.audible_notifications', 'on') %} - main - {% elif is_state('binary_sensor.croft_occupancy', 'on') %} - croft - {% elif is_state('binary_sensor.master_bedroom_occupancy', 'on') %} - master_bedroom - {% else %} - all_google - {%- endif %} + {% set sensor_count = expand('group.occupancy') | selectattr('state', 'eq', 'on') | list | count %} + {% if sensor_count >= 1 %} + {% for sensor in expand('group.occupancy') %} + {% if as_timestamp(sensor.last_changed) == as_timestamp(expand('group.occupancy') | selectattr('state', 'eq', 'on') | map(attribute='last_changed') | max) %} + {%- if sensor.name == 'Theater Occupancy' and is_state('media_player.theater_tv', 'on') %} + theater + {% elif sensor.name == 'Kitchen Occupancy' %} + kitchen + {% elif sensor.name == 'Living Room Occupancy' and is_state('input_boolean.audible_notifications', 'on') %} + main + {% elif sensor.name == 'Living Room Occupancy' and is_state('input_boolean.audible_notifications', 'off') %} + kitchen + {% elif sensor.name == 'Croft Occupancy' %} + croft + {% elif sensor.name == 'Master Bedroom Occupancy' %} + master_bedroom + {% else %} + all_google + {%- endif %} + {% endif %} + {% endfor %} + {% else %} + main + {% endif %} alexa_audio: friendly_name: "Alexa Audio" value_template: >- diff --git a/config/packages/events.yaml b/config/packages/events.yaml index 86a3b29..9e0af90 100755 --- a/config/packages/events.yaml +++ b/config/packages/events.yaml @@ -185,7 +185,7 @@ automation: value_template: '{{ states.calendar.skylar_school.state == "Off" }}' action: - wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}" - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: "Blackout time has started." @@ -204,7 +204,7 @@ automation: state: 'on' action: - wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}" - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: "Blackout time has ended" @@ -272,7 +272,7 @@ script: - condition: state entity_id: sensor.family_status state: Home - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: "Skylar, digital learning will begin in about thirty minutes. I have turned on the lighting around your desk. I will be disabling audible notifications during school hours." diff --git a/config/packages/jarvis.yaml b/config/packages/jarvis.yaml index ff816f3..df7caeb 100755 --- a/config/packages/jarvis.yaml +++ b/config/packages/jarvis.yaml @@ -20,7 +20,7 @@ automation: action: - service: homeassistant.turn_on entity_id: group.incense - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: Incense has been turned on. @@ -35,7 +35,7 @@ automation: action: - service: homeassistant.turn_off entity_id: group.incense - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: Incense has been turned off. diff --git a/config/packages/presence.yaml b/config/packages/presence.yaml index 8624e91..8564562 100755 --- a/config/packages/presence.yaml +++ b/config/packages/presence.yaml @@ -198,7 +198,7 @@ automation: - service: input_boolean.turn_off entity_id: input_boolean.kat_travel_monitor - wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}" - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: 'Kat has arrived at work.' @@ -215,7 +215,7 @@ automation: - service: input_boolean.turn_on entity_id: input_boolean.kat_travel_monitor - wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}" - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.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. @@ -231,7 +231,7 @@ automation: action: - service: script.jeff_destination_home - wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}" - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.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. @@ -449,7 +449,7 @@ automation: - wait_template: "{{ states.binary_sensor.kitchen_door.state == 'on' }}" timeout: '00:01:00' - delay: '00:02:00' - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: main message: > diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 7a21460..ec3f3f4 100755 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -193,7 +193,7 @@ automation: entity_id: input_boolean.audible_notifications state: 'on' action: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: > @@ -210,8 +210,8 @@ automation: 'The air quality in this house has actually improved.', 'Closing the door would improve the internal climate of the house.', 'Hey. The door was just opened and this is crazy. But now you know. So close it maybe.', - 'They always say when one door closes another one opens...that must of been waht happened', - 'And the automatic door closer appears to be broken. So...' + 'They always say when one door closes another one opens...that must of been what happened', + 'And the automatic door closer appears to be broken. So, you know what to do.' ] | random }} initial_state: true @@ -238,7 +238,7 @@ automation: entity_id: input_boolean.sentry_mode state: 'on' action: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: > @@ -358,7 +358,7 @@ automation: from: 'off' to: 'on' action: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: > @@ -385,7 +385,7 @@ automation: to: 'off' action: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: > @@ -410,7 +410,7 @@ automation: from: 'off' to: 'on' action: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: > @@ -773,7 +773,7 @@ script: activate_barn_door_protocol: sequence: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: >- @@ -806,7 +806,7 @@ script: - condition: state entity_id: sensor.family_status state: "Home" - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: >- @@ -837,7 +837,7 @@ script: - condition: state entity_id: group.external_doors state: "on" - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: > @@ -866,7 +866,7 @@ script: activate_guest_mode: sequence: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: >- diff --git a/config/packages/space.yaml b/config/packages/space.yaml index 29a3568..8460aa3 100755 --- a/config/packages/space.yaml +++ b/config/packages/space.yaml @@ -66,7 +66,7 @@ automation: # action: # - wait_template: >- # {{((as_timestamp(now()) - states('sensor.launch_window') | float) | abs < 601)}} - # - service: script.ah_report + # - service: script.speech_engine # data: # call_launch: 1 # - service: script.text_notify @@ -107,7 +107,7 @@ automation: # to: 'on' # from: 'off' # action: - # - service: script.ah_report + # - service: script.speech_engine # data: # call_interuption: 1 # call_iss: 1 @@ -124,7 +124,7 @@ automation: entity_id: sensor.moon state: 'full_moon' action: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: > diff --git a/config/packages/usps.yaml b/config/packages/usps.yaml index e100b34..584e72b 100755 --- a/config/packages/usps.yaml +++ b/config/packages/usps.yaml @@ -121,7 +121,7 @@ automation: - condition: template value_template: '{{ ((now().hour | int) > 7) and ((now().hour | int) < 16) }}' action: - - service: script.jarvis_voice + - service: script.speech_engine data: who: '{{ states.sensor.room_audio.state }}' message: >- @@ -178,7 +178,7 @@ automation: - condition: template value_template: '{{ ((now().hour | int) > 7) and ((now().hour | int) < 16) }}' action: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: > @@ -211,7 +211,7 @@ automation: who: "jeff" title: "Delivering Today" message: "{{ states('sensor.mail_deliveries_message')}}" - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: >- @@ -255,7 +255,7 @@ automation: who: "jeff" title: "Package Delivered" message: "Fedex/UPS just made a delivery" - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: >- diff --git a/config/packages/weather.yaml b/config/packages/weather.yaml index 72a9071..c56daee 100755 --- a/config/packages/weather.yaml +++ b/config/packages/weather.yaml @@ -51,33 +51,33 @@ sensor: - platform: nws_alerts zone_id: 'GAZ034,GAC135' - - platform: mqtt - name: "Back Porch" - state_topic: "house/acurite2mqtt/Acurite-6045M_3078" - unit_of_measurement: '°F' - value_template: "{{ value_json.temperature_F }}" - json_attributes_topic: "house/acurite2mqtt/Acurite-6045M_3078" - device_class: temperature + # - platform: mqtt + # name: "Back Porch" + # state_topic: "house/acurite2mqtt/Acurite-6045M_3078" + # unit_of_measurement: '°F' + # value_template: "{{ value_json.temperature_F }}" + # json_attributes_topic: "house/acurite2mqtt/Acurite-6045M_3078" + # device_class: temperature - - platform: mqtt - name: "Crawlspace" - state_topic: "house/acurite2mqtt/Acurite-609TXC_73" - unit_of_measurement: '°F' - value_template: "{{ value_json.temperature_F }}" - json_attributes_topic: "house/acurite2mqtt/Acurite-609TXC_73" - device_class: temperature + # - platform: mqtt + # name: "Crawlspace" + # state_topic: "house/acurite2mqtt/Acurite-609TXC_73" + # unit_of_measurement: '°F' + # value_template: "{{ value_json.temperature_F }}" + # json_attributes_topic: "house/acurite2mqtt/Acurite-609TXC_73" + # device_class: temperature - - platform: mqtt - name: "Garage" - state_topic: "house/acurite2mqtt/Acurite-Tower_10968" - unit_of_measurement: '°F' - value_template: "{{ value_json.temperature_F }}" - json_attributes_topic: "house/acurite2mqtt/Acurite-Tower_10968" - device_class: temperature + # - platform: mqtt + # name: "Garage" + # state_topic: "house/acurite2mqtt/Acurite-Tower_10968" + # unit_of_measurement: '°F' + # value_template: "{{ value_json.temperature_F }}" + # json_attributes_topic: "house/acurite2mqtt/Acurite-Tower_10968" + # device_class: temperature - - platform: mqtt - name: "Lightning total count" - state_topic: "house/lightning/total_count" + # - platform: mqtt + # name: "Lightning total count" + # state_topic: "house/lightning/total_count" - platform: statistics name: Inside Humidity Stats @@ -185,13 +185,13 @@ sensor: {% endif %} backporch_weather: friendly_name: Back Porch Weather - value_template: "{{ states.sensor.back_porch.state | round}} °F / {{ states.sensor.back_porch.attributes.humidity }} %" + value_template: "{{ states.sensor.back_porch_temperature.state | round}} °F / {{ states.sensor.back_porch_humidity.state }} %" garage_weather: friendly_name: Garage Weather - value_template: "{{ states.sensor.garage.state | round}} °F / {{ states.sensor.garage.attributes.humidity }} %" + value_template: "{{ states.sensor.garage_temperature.state | round}} °F / {{ states.sensor.garage_humidity.state }} %" crawlspace_weather: friendly_name: Crawlspace Weather - value_template: "{{ states.sensor.crawlspace.state | round}} °F / {{ states.sensor.crawlspace.attributes.humidity }} %" + value_template: "{{ states.sensor.crawlspace_temperature.state | round}} °F / {{ states.sensor.crawlspace_humidity.state }} %" clothing_forecast: friendly_name: "Clothing Forecast" unit_of_measurement: '' @@ -309,7 +309,7 @@ sensor: value_template: "{{ states.climate.home.attributes.current_humidity }}" lighting_stike_count: friendly_name: "Lightning Strike Count" - value_template: "{{ states.sensor.back_porch.attributes.strike_count }}" + value_template: "{{ states.sensor.back_porch_strike_count.state }}" automation: - alias: 'NWS Weather Alert Pop Up Control' @@ -405,7 +405,7 @@ automation: - condition: template value_template: "{{ (('Severe' in states.sensor.nws_alerts.attributes.title) or ('Thunderstorm' in states.sensor.nws_alerts.attributes.title)) and 'Warning' in states.sensor.nws_alerts.attributes.title }}" action: - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: > @@ -431,7 +431,7 @@ automation: {{ [ "/config/www/tweet_images/lightning.jpg", "/config/www/tweet_images/lightning-bolt.jpg"] | random }} - delay: '00:00:15' - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: main message: > @@ -491,7 +491,7 @@ automation: - alias: Lightning Detected trigger: - platform: template - value_template: '{{ states.sensor.back_porch.attributes.strike_count | int > states.sensor.lightning_total_count.state | int }}' + value_template: '{{ states.sensor.back_porch_strike_count.state | int > states.sensor.lightning_total_count.state | int }}' condition: - condition: state entity_id: input_boolean.lightning_warning @@ -511,7 +511,7 @@ automation: mode: restart trigger: - platform: template - value_template: '{{ states.sensor.back_porch.attributes.strike_count | int == states.sensor.lightning_total_count.state | int }}' + value_template: '{{ states.sensor.back_porch_strike_count.state | int == states.sensor.lightning_total_count.state | int }}' for: minutes: 20 condition: @@ -605,7 +605,7 @@ script: - service: mqtt.publish data: topic: house/lightning/total_count - payload_template: "{{ states.sensor.back_porch.attributes.strike_count | int }}" + payload_template: "{{ states.sensor.back_porch_strike_count.state | int }}" retain: true @@ -659,7 +659,7 @@ script: image: >- {{ [ "/config/www/tweet_images/lightning.jpg", "/config/www/tweet_images/lightning-bolt.jpg"] | random }} - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: >- @@ -683,7 +683,7 @@ script: - condition: state entity_id: binary_sensor.day state: 'on' - - service: script.jarvis_voice + - service: script.speech_engine data_template: who: '{{ states.sensor.room_audio.state }}' message: >- diff --git a/config/sensors/google_travel_time.yaml b/config/sensors/google_travel_time.yaml index 7c62c30..5a9324a 100755 --- a/config/sensors/google_travel_time.yaml +++ b/config/sensors/google_travel_time.yaml @@ -10,7 +10,6 @@ origin: device_tracker.life360_kat_stone destination: zone.home region: 'US' - incl_filter: US-78 W - platform: waze_travel_time name: "Home To Summit" # api_key: !secret google_api diff --git a/config/sensors/house.yaml b/config/sensors/house.yaml index 1459121..96935d6 100755 --- a/config/sensors/house.yaml +++ b/config/sensors/house.yaml @@ -65,11 +65,11 @@ days: 7 - platform: statistics name: Outside Temp Stats - entity_id: sensor.back_porch + entity_id: sensor.back_porch_temperature sampling_size: 500 - platform: statistics name: Garage Temp Stats - entity_id: sensor.garage + entity_id: sensor.garage_temperature sampling_size: 500 - platform: min_max name: Inside Temp Stats diff --git a/config/templates/speech/morning_briefing.yaml b/config/templates/speech/morning_briefing.yaml index 24b0bd8..01ad4de 100755 --- a/config/templates/speech/morning_briefing.yaml +++ b/config/templates/speech/morning_briefing.yaml @@ -124,11 +124,11 @@ 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 the Cox Automotive appears heavy than normnal. + Traffic to Summit appears heavy than normnal. {% else %} - Traffic to the Cox is normal. + Traffic to Summit is normal. {% endif %} - Currently it will take {{states.sensor.home_to_summit.state|round}} minutes to get to Cox Automotive. + 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 -%}