Add speech engine scripts/automations
This commit is contained in:
@ -269,3 +269,375 @@ script:
|
|||||||
# badge: 0
|
# badge: 0
|
||||||
# category: '{{ ios_category }}'
|
# category: '{{ ios_category }}'
|
||||||
# entity_id: '{{ camera_entity }}'
|
# entity_id: '{{ camera_entity }}'
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Alert Notify
|
||||||
|
# Conditions:
|
||||||
|
# => Vacation mode should be off
|
||||||
|
# Services:
|
||||||
|
# => Audible
|
||||||
|
# => iOS
|
||||||
|
###############################################################################
|
||||||
|
alert_notify:
|
||||||
|
sequence:
|
||||||
|
- condition: state
|
||||||
|
entity_id: input_boolean.vacation_mode
|
||||||
|
state: 'off'
|
||||||
|
- service: tts.google_say
|
||||||
|
data_template:
|
||||||
|
entity_id: media_player.living_room_tv
|
||||||
|
message: >
|
||||||
|
{{ message }}
|
||||||
|
|
||||||
|
jarvis_alert:
|
||||||
|
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 | striptags | truncate(220)}}'
|
||||||
|
retain: true
|
||||||
|
- service: media_player.turn_on
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
{% if who in ['kallen_bedroom','media_player.kallen_bedroom_speaker'] %}
|
||||||
|
media_player.kallen_bedroom_speaker
|
||||||
|
{% else %}
|
||||||
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% else %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
- service: media_player.volume_set
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
{% if who in ['kallen_bedroom','media_player.kallen_bedroom_speaker'] %}
|
||||||
|
media_player.kallen_bedroom_speaker
|
||||||
|
{% else %}
|
||||||
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% else %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
volume_level: >
|
||||||
|
{% elif who == 'skylar_bedroom' %}
|
||||||
|
.50
|
||||||
|
{% else %}
|
||||||
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
|
.75
|
||||||
|
{% else %}
|
||||||
|
.99
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
- service: tts.amazon_polly_say
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
{% if who in ['kallen_bedroom','media_player.kallen_bedroom_speaker'] %}
|
||||||
|
media_player.kallen_bedroom_speaker
|
||||||
|
{% else %}
|
||||||
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% else %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
message: >-
|
||||||
|
<speak>
|
||||||
|
|
||||||
|
{{ message }}
|
||||||
|
|
||||||
|
</speak>
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Voice Notify
|
||||||
|
# Conditions:
|
||||||
|
# => Only Announce when people are home.
|
||||||
|
# => Only Announce when Audible Notifications are on
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
speech_engine:
|
||||||
|
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 | striptags | truncate(220)}}'
|
||||||
|
retain: true
|
||||||
|
- service: mqtt.publish
|
||||||
|
data_template:
|
||||||
|
topic: 'house/polly/lastloc'
|
||||||
|
payload: '{{ who }}'
|
||||||
|
retain: true
|
||||||
|
- condition: state
|
||||||
|
entity_id: input_boolean.audible_notifications
|
||||||
|
state: 'on'
|
||||||
|
- condition: state
|
||||||
|
entity_id: group.family
|
||||||
|
state: 'home'
|
||||||
|
- condition: state
|
||||||
|
entity_id: input_boolean.vacation_mode
|
||||||
|
state: 'off'
|
||||||
|
- service: >
|
||||||
|
{% if voice == 'nabu' %}
|
||||||
|
script.nabu_voice
|
||||||
|
{% elif who in ['living_room_echo_dot', 'media_player.living_room_echo_dot','living_room'] %}
|
||||||
|
{% set who = 'living_room_echo_dot' %}
|
||||||
|
script.alexa_voice
|
||||||
|
{% elif who in ['kallen_bedroom','media_player.kallen_bedroom_speaker'] %}
|
||||||
|
{% set who = 'kallen_bedroom_speaker' %}
|
||||||
|
script.jarvis_voice
|
||||||
|
{% elif who in ['master_bedroom','master_bedroom_echo_dot'] %}
|
||||||
|
{% set who = 'master_bedroom_echo_dot' %}
|
||||||
|
script.alexa_voice
|
||||||
|
{% elif who in ['basement','basement_echo_dot'] %}
|
||||||
|
{% set who = 'basement_echo_dot' %}
|
||||||
|
script.alexa_voice
|
||||||
|
{% else %}
|
||||||
|
{% set who = 'living_room_echo_dot' %}
|
||||||
|
script.alexa_voice
|
||||||
|
{% endif %}
|
||||||
|
data:
|
||||||
|
who: '{{ who }}'
|
||||||
|
message: >
|
||||||
|
{{ message }}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Use this Simplfied Script by calling in automaint or script like:
|
||||||
|
# service: script.speech_engine_simplified
|
||||||
|
# data:
|
||||||
|
# who: media_player.ha_blue
|
||||||
|
# #who: “{{ states(‘sensor.room_presence’) }}”
|
||||||
|
# #who: notify.kitchen_echo
|
||||||
|
# message: something to say
|
||||||
|
#
|
||||||
|
#
|
||||||
|
speech_engine_simplified:
|
||||||
|
sequence:
|
||||||
|
- condition: state
|
||||||
|
entity_id: input_boolean.audible_notifications
|
||||||
|
state: 'on'
|
||||||
|
- 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: >-
|
||||||
|
{{ who }}
|
||||||
|
message: >-
|
||||||
|
<speak>
|
||||||
|
<break time="1s"/>
|
||||||
|
{{ message }}
|
||||||
|
</speak>
|
||||||
|
cache: true
|
||||||
|
- service: >-
|
||||||
|
{{ who }}
|
||||||
|
data:
|
||||||
|
message: >
|
||||||
|
{{ message }}
|
||||||
|
data:
|
||||||
|
type: tts
|
||||||
|
- service: tts.cloud_say
|
||||||
|
data_template:
|
||||||
|
entity_id: >-
|
||||||
|
{{ who }}
|
||||||
|
message: >-
|
||||||
|
{{ message }}
|
||||||
|
cache: true
|
||||||
|
language: en-GB
|
||||||
|
options:
|
||||||
|
gender: male
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Called wheh notification needs to play on echos
|
||||||
|
alexa_voice:
|
||||||
|
sequence:
|
||||||
|
- service: media_player.turn_on
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
{% if who in ['living_room_echo_dot', 'media_player.living_room_echo_dot','living_room'] %}
|
||||||
|
notify.alexa_media_living_room_echo_dot
|
||||||
|
{% elif who in ['master_bedroom','master_bedroom_echo_dot'] %}
|
||||||
|
notify.alexa_media_master_bedroom_echo_dot
|
||||||
|
{% elif who in ['basement','basement_echo_dot'] %}
|
||||||
|
notify.alexa_media_basement_echo_dot
|
||||||
|
{% else %}
|
||||||
|
notify.alexa_media_living_room_echo_dot
|
||||||
|
{% endif %}
|
||||||
|
- service: media_player.volume_set
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
{% if who in ['living_room_echo_dot', 'media_player.living_room_echo_dot','living_room'] %}
|
||||||
|
notify.alexa_media_living_room_echo_dot
|
||||||
|
{% elif who in ['master_bedroom','master_bedroom_echo_dot'] %}
|
||||||
|
notify.alexa_media_master_bedroom_echo_dot
|
||||||
|
{% elif who in ['basement','basement_echo_dot'] %}
|
||||||
|
notify.alexa_media_basement_echo_dot
|
||||||
|
{% else %}
|
||||||
|
notify.alexa_media_living_room_echo_dot
|
||||||
|
{% endif %}
|
||||||
|
volume_level: >
|
||||||
|
{% if is_state('input_boolean.audible_notifications.state','on') %}
|
||||||
|
.6
|
||||||
|
{% else %}
|
||||||
|
.4
|
||||||
|
{% endif %}
|
||||||
|
- service: >
|
||||||
|
{% if who in ['living_room_echo_dot', 'media_player.living_room_echo_dot','living_room'] %}
|
||||||
|
notify.alexa_media_living_room_echo_dot
|
||||||
|
{% elif who in ['master_bedroom','master_bedroom_echo_dot'] %}
|
||||||
|
notify.alexa_media_master_bedroom_echo_dot
|
||||||
|
{% elif who in ['basement','basement_echo_dot'] %}
|
||||||
|
notify.alexa_media_basement_echo_dot
|
||||||
|
{% else %}
|
||||||
|
notify.alexa_media_living_room_echo_dot
|
||||||
|
{% endif %}
|
||||||
|
data:
|
||||||
|
message: >
|
||||||
|
{{ message }}
|
||||||
|
data:
|
||||||
|
type: tts
|
||||||
|
|
||||||
|
# Default audible notifications. Notifcations play on the google devices.
|
||||||
|
jarvis_voice:
|
||||||
|
sequence:
|
||||||
|
- service: media_player.turn_on
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
{% if who in ['kallen_bedroom','media_player.kallen_bedroom_speaker'] %}
|
||||||
|
media_player.kallen_bedroom_speaker
|
||||||
|
{% else %}
|
||||||
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% else %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
- service: media_player.volume_set
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
{% if who in ['kallen_bedroom','media_player.kallen_bedroom_speaker'] %}
|
||||||
|
media_player.kallen_bedroom_speaker
|
||||||
|
{% else %}
|
||||||
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% else %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
volume_level: >
|
||||||
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
|
{% if who == 'kallen_bedroom_speaker' %}
|
||||||
|
{{ states('input_number.tts_volume') | float }}
|
||||||
|
{% else %}
|
||||||
|
{{ states('input_number.tts_volume') | float }}
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{{ states('input_number.tts_low_volume') | float }}
|
||||||
|
{% endif %}
|
||||||
|
- service: tts.amazon_polly_say
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
{% if who in ['kallen_bedroom','media_player.kallen_bedroom_speaker'] %}
|
||||||
|
media_player.kallen_bedroom_speaker
|
||||||
|
{% else %}
|
||||||
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% else %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
message: >-
|
||||||
|
<speak>
|
||||||
|
<break time="1s"/>
|
||||||
|
{{ message }}
|
||||||
|
</speak>
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
nabu_voice:
|
||||||
|
sequence:
|
||||||
|
- service: media_player.turn_on
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
{% if who in ['kallen_bedroom','media_player.kallen_bedroom_speaker'] %}
|
||||||
|
media_player.kallen_bedroom_speaker
|
||||||
|
{% else %}
|
||||||
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% else %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
- service: media_player.volume_set
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
{% if who in ['kallen_bedroom','media_player.kallen_bedroom_speaker'] %}
|
||||||
|
media_player.kallen_bedroom_speaker
|
||||||
|
{% else %}
|
||||||
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% else %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
volume_level: >
|
||||||
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
|
.7
|
||||||
|
{% else %}
|
||||||
|
.3
|
||||||
|
{% endif %}
|
||||||
|
- service: tts.cloud_say
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
{% if who in ['kallen_bedroom','media_player.kallen_bedroom_speaker'] %}
|
||||||
|
media_player.kallen_bedroom_speaker
|
||||||
|
{% else %}
|
||||||
|
{% if states.input_boolean.audible_notifications.state == 'on' %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% else %}
|
||||||
|
media_player.living_room_tv
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
message: >-
|
||||||
|
{{ message }}
|
||||||
|
cache: true
|
||||||
|
language: en-GB
|
||||||
|
options:
|
||||||
|
gender: male
|
||||||
|
|
||||||
|
|
||||||
|
# dim_main_volume:
|
||||||
|
# sequence:
|
||||||
|
# - condition: state
|
||||||
|
# entity_id: 'media_player.ha_blue'
|
||||||
|
# state: 'playing'
|
||||||
|
# - service: input_number.set_value
|
||||||
|
# data_template:
|
||||||
|
# entity_id: input_number.old_volume
|
||||||
|
# value: >
|
||||||
|
# {{ states.media_player.ha_blue.attributes.volume_level }}
|
||||||
|
# - service: media_player.volume_set
|
||||||
|
# data_template:
|
||||||
|
# entity_id: media_player.ha_blue
|
||||||
|
# volume_level: .2
|
||||||
|
|
||||||
|
# raise_main_volume:
|
||||||
|
# sequence:
|
||||||
|
# - condition: state
|
||||||
|
# entity_id: 'media_player.ha_blue'
|
||||||
|
# state: 'playing'
|
||||||
|
# - service: media_player.volume_set
|
||||||
|
# data_template:
|
||||||
|
# entity_id: media_player.ha_blue
|
||||||
|
# volume_level: >
|
||||||
|
# {{ states.input_number.old_volume.state }}
|
||||||
|
Reference in New Issue
Block a user