New Speech engine routing speech to either echos or chromecast based on context
This commit is contained in:
parent
da591c9631
commit
8793ee9117
|
@ -100,47 +100,47 @@ notify:
|
||||||
name: alexa_media
|
name: alexa_media
|
||||||
|
|
||||||
|
|
||||||
automation:
|
# automation:
|
||||||
|
|
||||||
- id: audio_isssue
|
# - id: audio_isssue
|
||||||
alias: Audio Issue
|
# alias: Audio Issue
|
||||||
initial_state: true
|
# initial_state: true
|
||||||
trigger:
|
# trigger:
|
||||||
- platform: state
|
# - platform: state
|
||||||
entity_id: media_player.ha_speaker
|
# entity_id: media_player.ha_speaker
|
||||||
to: 'unavailable'
|
# to: 'unavailable'
|
||||||
condition:
|
# condition:
|
||||||
- condition: state
|
# - condition: state
|
||||||
entity_id: binary_sensor.day
|
# entity_id: binary_sensor.day
|
||||||
state: 'on'
|
# state: 'on'
|
||||||
action:
|
# action:
|
||||||
- service: input_boolean.turn_off
|
# - service: input_boolean.turn_off
|
||||||
entity_id: input_boolean.audible_notifications
|
# entity_id: input_boolean.audible_notifications
|
||||||
- service: script.text_notify
|
# - service: script.text_notify
|
||||||
data_template:
|
# data_template:
|
||||||
who: "jeff"
|
# who: "jeff"
|
||||||
title: "Audio Issue"
|
# title: "Audio Issue"
|
||||||
message: "HA Audible Notifications turning off due to Chromecast Issue"
|
# message: "HA Audible Notifications turning off due to Chromecast Issue"
|
||||||
|
|
||||||
- id: audio_isssue_cleared
|
# - id: audio_isssue_cleared
|
||||||
alias: Audio Issue Cleared
|
# alias: Audio Issue Cleared
|
||||||
initial_state: true
|
# initial_state: true
|
||||||
trigger:
|
# trigger:
|
||||||
- platform: state
|
# - platform: state
|
||||||
entity_id: media_player.ha_speaker
|
# entity_id: media_player.ha_speaker
|
||||||
from: 'unavailable'
|
# from: 'unavailable'
|
||||||
to: 'off'
|
# to: 'off'
|
||||||
condition:
|
# condition:
|
||||||
- condition: state
|
# - condition: state
|
||||||
entity_id: binary_sensor.day
|
# entity_id: binary_sensor.day
|
||||||
state: 'on'
|
# state: 'on'
|
||||||
action:
|
# action:
|
||||||
- service: script.text_notify
|
# - service: script.text_notify
|
||||||
data_template:
|
# data_template:
|
||||||
who: "jeff"
|
# who: "jeff"
|
||||||
title: "Audio Issue Cleared"
|
# title: "Audio Issue Cleared"
|
||||||
message: "Main hromecast is back on"
|
# message: "Main hromecast is back on"
|
||||||
- service: script.turn_on_ha_speaker
|
# - service: script.turn_on_ha_speaker
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -303,9 +303,9 @@ script:
|
||||||
media_player.ha_speaker
|
media_player.ha_speaker
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
media_player.ha_speaker
|
media_player.ha_speaker
|
||||||
{% else %}
|
{% else %}
|
||||||
media_player.house
|
media_player.house
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
volume_level: >
|
volume_level: >
|
||||||
|
@ -345,9 +345,9 @@ script:
|
||||||
media_player.ha_speaker
|
media_player.ha_speaker
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
media_player.ha_speaker
|
media_player.ha_speaker
|
||||||
{% else %}
|
{% else %}
|
||||||
media_player.house
|
media_player.house
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
message: >-
|
message: >-
|
||||||
|
@ -368,39 +368,107 @@ script:
|
||||||
# => Only Announce when Audible Notifications are on
|
# => Only Announce when Audible Notifications are on
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
voice_notify:
|
speech_engine:
|
||||||
sequence:
|
sequence:
|
||||||
|
- service: mqtt.publish
|
||||||
|
data_template:
|
||||||
|
topic: 'house/polly/lastmsg'
|
||||||
|
payload: 'This message is from {{ now().strftime("%-I") }}:{{ now().strftime("%M") }} {{ now().strftime("%p") }}. {{ message | truncate(220)}}'
|
||||||
|
retain: true
|
||||||
|
- service: mqtt.publish
|
||||||
|
data_template:
|
||||||
|
topic: 'house/polly/lastloc'
|
||||||
|
payload: '{{ who }}'
|
||||||
|
retain: true
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: '{{ states.input_boolean.audible_notifications.state == "on" }}'
|
value_template: '{{ states.binary_sensor.quiet_time.state == "off" }}'
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: sensor.family_status
|
entity_id: group.family
|
||||||
state: 'Home'
|
state: 'home'
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: input_boolean.vacation_mode
|
entity_id: input_boolean.vacation_mode
|
||||||
state: 'off'
|
state: 'off'
|
||||||
- service: tts.google_translate_say
|
- service: >
|
||||||
data_template:
|
{% if voice == 'alexa' %}
|
||||||
entity_id: media_player.guest_tv
|
script.alexa_voice
|
||||||
message: >-
|
{% elif who in ['skylar_bedroom','kitchen_echo','livingroom_echo'] %}
|
||||||
{{message }}
|
script.alexa_voice
|
||||||
|
{% elif voice == 'jarvis' %}
|
||||||
|
{% if who == 'main' and is_state('media_player.ha_speaker','playing') %}
|
||||||
|
{% set who = 'livingroom_echo' %}
|
||||||
|
script.alexa_voice
|
||||||
|
{% else %}
|
||||||
|
script.speech_engine
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{% if who == 'main' and is_state('media_player.ha_speaker','playing') %}
|
||||||
|
{% set who = 'livingroom_echo' %}
|
||||||
|
script.alexa_voice
|
||||||
|
{% else %}
|
||||||
|
script.speech_engine
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
data:
|
||||||
|
who: '{{ who }}'
|
||||||
|
message: >
|
||||||
|
{{ message }}
|
||||||
|
|
||||||
|
# Called wheh notification needs to play on echos
|
||||||
|
alexa_voice:
|
||||||
|
sequence:
|
||||||
|
- service: media_player.turn_on
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
{% if who == 'skylar_bedroom' %}
|
||||||
|
notify.alexa_media_skylar_s_bedroom
|
||||||
|
{% elif who == 'kitchen_echo' %}
|
||||||
|
notify.alexa_media_kitchen
|
||||||
|
{% elif who == 'livingroom_echo' %}
|
||||||
|
notify.alexa_media_living_room
|
||||||
|
{% else %}
|
||||||
|
notify.alexa_media_living_room
|
||||||
|
{% endif %}
|
||||||
|
- service: script.dim_main_volume
|
||||||
|
- service: media_player.volume_set
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
{% if who == 'skylar_bedroom' %}
|
||||||
|
notify.alexa_media_skylar_s_bedroom
|
||||||
|
{% elif who == 'kitchen_echo' %}
|
||||||
|
notify.alexa_media_kitchen
|
||||||
|
{% elif who == 'livingroom_echo' and is_state('media_player.ha_speaker','playing') %}
|
||||||
|
{% set old_volume = states.media_player.ha_speaker.attributes.volume_level %}
|
||||||
|
media_player.ha_speaker
|
||||||
|
{% else %}
|
||||||
|
notify.alexa_media_living_room
|
||||||
|
{% endif %}
|
||||||
|
volume_level: >
|
||||||
|
{% if is_state('input_boolean.audible_notifications.state','on') %}
|
||||||
|
.6
|
||||||
|
{% else %}
|
||||||
|
.4
|
||||||
|
{% endif %}
|
||||||
|
- service: >
|
||||||
|
{% if who == 'skylar_bedroom' %}
|
||||||
|
notify.alexa_media_skylar_s_bedroom
|
||||||
|
{% elif who == 'kitchen_echo' %}
|
||||||
|
notify.alexa_media_kitchen
|
||||||
|
{% elif who == 'livingroom_echo' %}
|
||||||
|
notify.alexa_media_living_room
|
||||||
|
{% else %}
|
||||||
|
notify.alexa_media_living_room
|
||||||
|
{% endif %}
|
||||||
|
data:
|
||||||
|
message: >
|
||||||
|
{{ message }}
|
||||||
|
data:
|
||||||
|
type: tts
|
||||||
|
- delay: 00:00:20
|
||||||
|
- service: script.raise_main_volume
|
||||||
|
|
||||||
|
# Default audible notifications. Notifcations play on the google devices.
|
||||||
jarvis_voice:
|
jarvis_voice:
|
||||||
sequence:
|
sequence:
|
||||||
- service: mqtt.publish
|
|
||||||
data_template:
|
|
||||||
topic: 'house/polly/lastmsg'
|
|
||||||
payload: 'This message is from {{ now().strftime("%-I") }}:{{ now().strftime("%M") }} {{ now().strftime("%p") }}. {{ message | truncate(220)}}'
|
|
||||||
retain: true
|
|
||||||
- condition: template
|
|
||||||
value_template: '{{ states.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: media_player.turn_on
|
- service: media_player.turn_on
|
||||||
data_template:
|
data_template:
|
||||||
entity_id: >
|
entity_id: >
|
||||||
|
@ -460,7 +528,7 @@ script:
|
||||||
media_player.upstairs_speaker
|
media_player.upstairs_speaker
|
||||||
{% elif who == 'master_bedroom' %}
|
{% elif who == 'master_bedroom' %}
|
||||||
media_player.master_bedroom_speaker
|
media_player.master_bedroom_speaker
|
||||||
{% elif who == 'studio' %}
|
{% elif who == 'theater' %}
|
||||||
media_player.theater
|
media_player.theater
|
||||||
{% elif who == 'all_google' %}
|
{% elif who == 'all_google' %}
|
||||||
media_player.house
|
media_player.house
|
||||||
|
@ -482,7 +550,31 @@ script:
|
||||||
</speak>
|
</speak>
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
|
dim_main_volume:
|
||||||
|
sequence:
|
||||||
|
- condition: state
|
||||||
|
entity_id: 'media_player.ha_speaker'
|
||||||
|
state: 'playing'
|
||||||
|
- service: input_number.set_value
|
||||||
|
data_template:
|
||||||
|
entity_id: input_number.old_volume
|
||||||
|
value: >
|
||||||
|
{{ states.media_player.ha_speaker.attributes.volume_level }}
|
||||||
|
- service: media_player.volume_set
|
||||||
|
data_template:
|
||||||
|
entity_id: media_player.ha_speaker
|
||||||
|
volume_level: .2
|
||||||
|
|
||||||
|
raise_main_volume:
|
||||||
|
sequence:
|
||||||
|
- condition: state
|
||||||
|
entity_id: 'media_player.ha_speaker'
|
||||||
|
state: 'playing'
|
||||||
|
- service: media_player.volume_set
|
||||||
|
data_template:
|
||||||
|
entity_id: media_player.ha_speaker
|
||||||
|
volume_level: >
|
||||||
|
{{ states.input_number.old_volume.state }}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Twitter
|
# Twitter
|
||||||
|
@ -584,7 +676,7 @@ script:
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# weather_report:
|
# weather_report:
|
||||||
# sequence:
|
# sequence:
|
||||||
# - service: script.ah_report
|
# - service: script.speech_engine
|
||||||
# data:
|
# data:
|
||||||
# call_weather_alerts: 1
|
# call_weather_alerts: 1
|
||||||
# call_current_conditions_outside: 1
|
# call_current_conditions_outside: 1
|
||||||
|
@ -600,7 +692,7 @@ script:
|
||||||
# ###############################################################################
|
# ###############################################################################
|
||||||
# traffic_report:
|
# traffic_report:
|
||||||
# sequence:
|
# sequence:
|
||||||
# - service: script.ah_report
|
# - service: script.speech_engine
|
||||||
# data:
|
# data:
|
||||||
# call_traffic_conditions: 1
|
# call_traffic_conditions: 1
|
||||||
|
|
||||||
|
@ -609,7 +701,7 @@ script:
|
||||||
# ###############################################################################
|
# ###############################################################################
|
||||||
# security_report:
|
# security_report:
|
||||||
# sequence:
|
# sequence:
|
||||||
# - service: script.ah_report
|
# - service: script.speech_engine
|
||||||
# data:
|
# data:
|
||||||
# call_security_report: 1
|
# call_security_report: 1
|
||||||
|
|
||||||
|
@ -618,13 +710,13 @@ script:
|
||||||
# ###############################################################################
|
# ###############################################################################
|
||||||
# jeff_eta_report:
|
# jeff_eta_report:
|
||||||
# sequence:
|
# sequence:
|
||||||
# - service: script.ah_report
|
# - service: script.speech_engine
|
||||||
# data:
|
# data:
|
||||||
# call_jeff_location: 1
|
# call_jeff_location: 1
|
||||||
|
|
||||||
# jeff_headed_home_annc:
|
# jeff_headed_home_annc:
|
||||||
# sequence:
|
# sequence:
|
||||||
# - service: script.ah_report
|
# - service: script.speech_engine
|
||||||
# data:
|
# data:
|
||||||
# call_jeff_headed_home: 1
|
# call_jeff_headed_home: 1
|
||||||
|
|
||||||
|
@ -634,12 +726,12 @@ script:
|
||||||
# ###############################################################################
|
# ###############################################################################
|
||||||
# kat_eta_report:
|
# kat_eta_report:
|
||||||
# sequence:
|
# sequence:
|
||||||
# - service: script.ah_report
|
# - service: script.speech_engine
|
||||||
# data:
|
# data:
|
||||||
# call_kat_location: 1
|
# call_kat_location: 1
|
||||||
|
|
||||||
# kat_headed_home_annc:
|
# kat_headed_home_annc:
|
||||||
# sequence:
|
# sequence:
|
||||||
# - service: script.ah_report
|
# - service: script.speech_engine
|
||||||
# data:
|
# data:
|
||||||
# call_kat_headed_home: 1
|
# call_kat_headed_home: 1
|
Loading…
Reference in New Issue