home-assistant-configuration/config/packages/notify.yaml

737 lines
24 KiB
YAML
Raw Normal View History

2019-02-21 17:49:55 +00:00
###############################################################################
# @author : Jeffrey Stone
# @date : 02/19/2019
# @package : Notify
# @description : A Collection of Notification Scripts and Configs.
# Package modified from https://github.com/skalavala/smarthome/blob/master/packages/notify.yaml with inspiration
# from https://github.com/CCOSTAN/Home-AssistantConfig/blob/master/config/script/speech_engine.yaml
2019-02-21 17:49:55 +00:00
###############################################################################
2019-02-23 04:32:32 +00:00
###############################################################################
# AWS Polly Options:
# pause:
# <break time="3s"/>
# emphasis:
# <emphasis level="strong">really like</emphasis>
# level attribute values:
# Strong: Increases the volume and slows the speaking rate so that the speech is louder and slower.
# Moderate: Increases the volume and slows the speaking rate, but less than strong. Moderate is the default.
# Reduced: Decreases the volume and speeds up the speaking rate. Speech is softer and faster.
# Pause Between Paragraphs:
# Wrap text in <p> </p>
# Adding a Pause Between Sentences:
# Ending a sentence with a period (.)
# Controlling How Special Types of Words Are Spoken:
# <say-as interpret-as="value">[text to be interpreted]</say-as>
# characters or spell-out: Spells out each letter of the text, as in a-b-c.
# cardinal or number: Interprets the numerical text as a cardinal number, as in 1,234.
# ordinal: Interprets the numerical text as an ordinal number, as in 1,234th.
# digits: Spells out each digit individually, as in 1-2-3-4.
# fraction: Interprets the numerical text as a fraction. This works for both common fractions such as 3/20, and mixed fractions, such as 2 ½. See below for more information.
# unit: Interprets a numerical text as a measurement. The value should be either a number or a fraction followed by a unit with no space in between as in 1/2inch, or by just a unit, as in 1meter.
# date: Interprets the text as a date. The format of the date must be specified with the format attribute. See below for more information.
# time: Interprets the numerical text as duration, in minutes and seconds, as in 1'21".
# address: Interprets the text as part of a street address.
# expletive: "Beeps out" the content included within the tag.
# telephone: Interprets the numerical text as a 7-digit or 10-digit telephone number, as in 2025551212. You can also use this value for handle telephone extensions, as in 2025551212x345. See below for more information.
################################################################################
2019-02-21 17:49:55 +00:00
tts:
- platform: google_translate
2019-02-21 17:49:55 +00:00
cache: true
cache_dir: /tmp/tts
time_memory: 300
2019-07-12 20:35:11 +00:00
- platform: amazon_polly
aws_access_key_id: !secret aws_key
aws_secret_access_key: !secret aws_secret
region_name: 'us-east-1'
text_type: ssml
voice: Brian
cache: True
2019-02-21 17:49:55 +00:00
notify:
- platform: ios
- name: all_ios
platform: group
services:
- service: mobile_app_jeffreys_iphone_11
2020-04-14 02:21:12 +00:00
- service: mobile_app_jeffreys_ipad
- service: mobile_app_iphone
2020-04-14 02:21:12 +00:00
- service: mobile_app_skylars_iphone
2019-07-14 01:38:53 +00:00
- name: ios_parents
platform: group
services:
- service: mobile_app_jeffreys_iphone_11
2020-04-14 02:21:12 +00:00
- service: mobile_app_jeffreys_ipad
- service: mobile_app_iphone
2019-02-21 17:49:55 +00:00
- name: jeff_ios
platform: group
services:
- service: mobile_app_jeffreys_iphone_11
2020-04-14 02:21:12 +00:00
- service: mobile_app_jeffreys_ipad
- name: kat_ios
platform: group
services:
- service: mobile_app_iphone
2020-04-14 02:21:12 +00:00
- name: skylar_ios
platform: group
services:
- service: mobile_app_skylars_iphone
2019-02-21 17:49:55 +00:00
- name: twitter
platform: twitter
consumer_key: !secret twitter_consumer_key
consumer_secret: !secret twitter_consumer_secret
access_token: !secret twitter_access_token
access_token_secret: !secret twitter_access_secret
- name: twitter_js
platform: twitter
consumer_key: !secret twitter2_consumer_key
consumer_secret: !secret twitter2_consumer_secret
access_token: !secret twitter2_access_token
access_token_secret: !secret twitter2_access_secret
2020-11-28 01:48:28 +00:00
- name: twitter_sl
platform: twitter
consumer_key: !secret twitter3_consumer_key
consumer_secret: !secret twitter3_consumer_secret
access_token: !secret twitter3_access_token
access_token_secret: !secret twitter3_access_secret
2020-01-03 17:28:38 +00:00
- platform: alexa_media
name: alexa_media
2019-09-07 19:11:00 +00:00
# automation:
# - id: audio_isssue
# alias: Audio Issue
# initial_state: true
# trigger:
# - platform: state
# entity_id: media_player.ha_speaker
# to: 'unavailable'
# condition:
# - condition: state
# entity_id: binary_sensor.day
# state: 'on'
# action:
# - service: input_boolean.turn_off
# entity_id: input_boolean.audible_notifications
# - service: script.text_notify
# data_template:
# who: "jeff"
# title: "Audio Issue"
# message: "HA Audible Notifications turning off due to Chromecast Issue"
# - id: audio_isssue_cleared
# alias: Audio Issue Cleared
# initial_state: true
# trigger:
# - platform: state
# entity_id: media_player.ha_speaker
# from: 'unavailable'
# to: 'off'
# condition:
# - condition: state
# entity_id: binary_sensor.day
# state: 'on'
# action:
# - service: script.text_notify
# data_template:
# who: "jeff"
# title: "Audio Issue Cleared"
# message: "Main hromecast is back on"
# - service: script.turn_on_ha_speaker
2019-02-21 17:49:55 +00:00
script:
2019-02-23 04:32:32 +00:00
2019-02-21 17:49:55 +00:00
###############################################################################
# Txt Notify
###############################################################################
text_notify_all:
sequence:
- service: notify.all_ios
data_template:
message: >
{{ message }}
text_notify_jeff:
sequence:
- condition: state
entity_id: input_boolean.text_notify_jeff
state: 'on'
- service: notify.jeff_ios
data_template:
message: >
{{ message }}
text_notify_kat:
sequence:
- condition: state
entity_id: input_boolean.text_notify_kat
state: 'on'
- service: notify.kat_ios
data_template:
message: >
{{ message }}
2019-07-14 01:38:53 +00:00
text_notify:
sequence:
- condition: state
entity_id: input_boolean.text_notifications
state: 'on'
- service: >
2019-07-14 01:38:53 +00:00
{% 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:
2019-07-14 01:38:53 +00:00
title: '{{ title }}'
message: '{{ message }}'
#data:
# attachment:
# url: '{{ url }}'
# content-type: '{{ content_type }}'
2019-07-14 01:38:53 +00:00
# hide-thumbnail: false
# push:
# sound: '{{ ios_sound }}'
2019-07-14 01:38:53 +00:00
# badge: 0
# category: '{{ ios_category }}'
# entity_id: '{{ camera_entity }}'
2019-07-14 01:38:53 +00:00
text_alert:
sequence:
- service: >
2019-07-14 01:38:53 +00:00
{% 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:
2019-07-14 01:38:53 +00:00
title: '{{ title }}'
message: '{{ message }}'
#data:
# attachment:
# url: '{{ url }}'
# content-type: '{{ content_type }}'
2019-07-14 01:38:53 +00:00
# hide-thumbnail: false
# push:
# sound: '{{ ios_sound }}'
2019-07-14 01:38:53 +00:00
# badge: 0
# category: '{{ ios_category }}'
# entity_id: '{{ camera_entity }}'
2019-07-14 01:38:53 +00:00
2019-02-21 17:49:55 +00:00
###############################################################################
# Alert Notify
# Conditions:
# => Vacation mode should be off
# Services:
# => Audible
# => iOS
###############################################################################
alert_notify:
sequence:
- condition: state
entity_id: input_boolean.vacation_mode
state: 'off'
2019-09-07 19:11:00 +00:00
- service: switch.turn_on
entity_id: switch.ha_speaker
- service: tts.google_translate_say
2019-02-21 17:49:55 +00:00
data_template:
2019-09-07 19:11:00 +00:00
entity_id: media_player.guest_tv
2019-02-21 17:49:55 +00:00
message: >
{{ message }}
2019-07-12 20:35:11 +00:00
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 == 'kitchen' %}
media_player.kitchen_display
{% elif who == 'croft' %}
media_player.upstairs_speaker
{% elif who == 'master_bedroom' %}
media_player.master_bedroom_speaker
{% elif who == 'studio' %}
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 == 'studio' %}
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 who == 'kitchen' %}
2020-11-28 01:48:28 +00:00
.80
{% elif who == 'croft' %}
.50
{% elif who == 'master_bedroom' %}
2020-11-07 16:20:26 +00:00
.50
{% elif who == 'studio' %}
.30
{% elif who == 'all_google' %}
.99
{% elif who == 'main' %}
.99
{% else %}
{% if states.input_boolean.audible_notifications.state == 'on' %}
.75
{% else %}
.99
{% endif %}
{% endif %}
2019-07-12 20:35:11 +00:00
- service: tts.amazon_polly_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 == 'studio' %}
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 %}
2019-07-12 20:35:11 +00:00
message: >-
<speak>
<amazon:auto-breaths>
2019-07-12 20:35:11 +00:00
{{ message }}
</amazon:auto-breaths>
2019-07-12 20:35:11 +00:00
</speak>
cache: true
2019-02-21 17:49:55 +00:00
2019-02-21 17:49:55 +00:00
###############################################################################
# Voice Notify
# Conditions:
# => Only Announce when people are home.
# => Only Announce when Audible Notifications are on
###############################################################################
speech_engine:
2019-02-21 17:49:55 +00:00
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
2019-02-21 17:49:55 +00:00
- condition: template
value_template: '{{ states.binary_sensor.quiet_time.state == "off" }}'
2019-02-21 17:49:55 +00:00
- condition: state
entity_id: group.family
state: 'home'
2019-02-21 17:49:55 +00:00
- condition: state
entity_id: input_boolean.vacation_mode
state: 'off'
- service: >
{% if voice == 'alexa' %}
script.alexa_voice
{% elif who in ['skylar_bedroom','kitchen_echo','livingroom_echo'] %}
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.jarvis_voice
{% endif %}
{% else %}
{% if who == 'main' and is_state('media_player.ha_speaker','playing') %}
{% set who = 'livingroom_echo' %}
script.alexa_voice
{% else %}
script.jarvis_voice
{% 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.
2019-07-12 20:35:11 +00:00
jarvis_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 %}
2019-07-12 20:35:11 +00:00
- service: tts.amazon_polly_say
data_template:
2019-07-14 01:38:53 +00:00
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
2019-07-14 01:38:53 +00:00
{% else %}
{% if states.input_boolean.audible_notifications.state == 'on' %}
media_player.ha_speaker
{% else %}
media_player.house
{% endif %}
2019-07-14 01:38:53 +00:00
{% endif %}
2019-07-12 20:35:11 +00:00
message: >-
<speak>
<break time="1s"/>
<amazon:auto-breaths>
2019-07-12 20:35:11 +00:00
{{ message }}
</amazon:auto-breaths>
2019-07-12 20:35:11 +00:00
</speak>
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 }}
2019-02-21 17:49:55 +00:00
###############################################################################
# Twitter
###############################################################################
2019-02-21 17:49:55 +00:00
twitter_notify:
sequence:
- service: >
{% if who == 'thejeffreystone' %}
notify.twitter_js
{% elif who == 'slackerlabs' %}
notify.twitter_sl
{% else %}
notify.twitter
{% endif %}
2019-02-21 17:49:55 +00:00
data_template:
message: >
{% set msg = '' %}
{% set msg = msg + ' ' + message %}
{% set msg = msg + ' #iot #smarthome' %}
2019-02-21 17:49:55 +00:00
{{ msg }}
2019-11-14 01:53:43 +00:00
twitter_notify_image:
sequence:
- service: >
{% if who == 'thejeffreystone' %}
notify.twitter_js
{% elif who == 'slackerlabs' %}
notify.twitter_sl
{% else %}
notify.twitter
{% endif %}
2019-11-14 01:53:43 +00:00
data_template:
message: >-
{{ tweet }} #iot #smarthome
data:
media: >-
{{ image }}
2019-02-21 17:49:55 +00:00
twitter_snark:
sequence:
- service: script.twitter_notify
2019-02-21 17:49:55 +00:00
data_template:
message: !include ../templates/twitter_snark.yaml
2019-07-14 01:38:53 +00:00
twitter_stats:
sequence:
- service: script.twitter_notify
2019-07-14 01:38:53 +00:00
data_template:
2019-11-25 02:58:35 +00:00
message: !include ../templates/twitter_stats.yaml
2019-02-21 17:49:55 +00:00
2019-11-11 03:45:04 +00:00
twitter_promos:
sequence:
- service: script.twitter_notify
2019-11-11 03:45:04 +00:00
data_template:
message: !include ../templates/twitter_promos.yaml
who: '{{ who }}'
twitter_follow_me:
sequence:
- service: script.twitter_notify
data_template:
message: !include ../templates/twitter_follow_me.yaml
who: '{{ who }}'
twitter_selfpromos:
sequence:
- service: script.twitter_notify
data_template:
message: !include ../templates/twitter_selfpromos.yaml
who: '{{ who }}'
twitter_recent_content:
sequence:
- service: script.twitter_notify
data:
who: '{{ who }}'
message: !include ../templates/twitter_recent_content.yaml
twitter_great_content:
sequence:
- service: script.twitter_notify
data_template:
message: !include ../templates/twitter_great_content.yaml
who: '{{ who }}'
2019-02-21 17:49:55 +00:00
twitter_new_ha:
sequence:
- service: script.twitter_notify
data_template:
2019-11-25 02:58:35 +00:00
message: !include ../templates/twitter_new_ha.yaml
who: '{{ who }}'
###############################################################################
# Weather Report
###############################################################################
# weather_report:
# sequence:
# - service: script.speech_engine
# data:
# call_weather_alerts: 1
# call_current_conditions_outside: 1
# call_current_conditions_inside: 1
# call_current_conditions_garage: 1
# call_daily_forecast: 1
# call_overnight_forecast: 1
# call_future_forecast: 1
# ###############################################################################
# # Traffic Report
# ###############################################################################
# traffic_report:
# sequence:
# - service: script.speech_engine
# data:
# call_traffic_conditions: 1
# ###############################################################################
# # Security Report
# ###############################################################################
# security_report:
# sequence:
# - service: script.speech_engine
# data:
# call_security_report: 1
# ###############################################################################
# # Jeff Traffic Reports
# ###############################################################################
# jeff_eta_report:
# sequence:
# - service: script.speech_engine
# data:
# call_jeff_location: 1
# jeff_headed_home_annc:
# sequence:
# - service: script.speech_engine
# data:
# call_jeff_headed_home: 1
# ###############################################################################
# # Kat Traffic Reports
# ###############################################################################
# kat_eta_report:
# sequence:
# - service: script.speech_engine
# data:
# call_kat_location: 1
# kat_headed_home_annc:
# sequence:
# - service: script.speech_engine
# data:
# call_kat_headed_home: 1