############################################################################### # @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 ############################################################################### ############################################################################### # AWS Polly Options: # pause: # # emphasis: # really like # 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

# Adding a Pause Between Sentences: # Ending a sentence with a period (.) # Controlling How Special Types of Words Are Spoken: # [text to be interpreted] # 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. ################################################################################ tts: - platform: google_translate cache: true cache_dir: /tmp/tts time_memory: 300 - 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 input_boolean: text_notify_jeff: name: Send Texts to Jeff icon: mdi:telegram text_notify_kat: name: Send Texts to Kat icon: mdi:telegram text_notify_skylar: name: Send Texts Skylar icon: mdi:telegram text_notify_parents: name: Send Texts to Parents icon: mdi:telegram text_notifications: name: Text Notifications icon: mdi:telegram presence_text_notifications: name: Presence Texts icon: mdi:telegram notifications_audio: name: Audio Notifications icon: mdi:speaker-wireless presence_audio_notifications: name: Presence Audio icon: mdi:speaker-wireless audible_notifications: name: Audible Notifications icon: mdi:speaker-wireless presence_notifications_jeff: name: Send Jeff Presence Texts icon: mdi:telegram presence_notifications_kat: name: Send Kat Presence Texts icon: mdi:telegram lockdown_notification: name: Lockdown Notifications icon: mdi:speaker-wireless garage_notifications: name: Garage Notifications icon: mdi:speaker-wireless trash_notification: name: Trash Notification icon: mdi:telegram notify: - platform: ios - name: all_ios platform: group services: - service: mobile_app_jeffreys_iphone_11 - service: mobile_app_jeffreys_ipad - service: mobile_app_iphone - service: mobile_app_skylars_iphone - name: ios_parents platform: group services: - service: mobile_app_jeffreys_iphone_11 - service: mobile_app_jeffreys_ipad - service: mobile_app_iphone - name: jeff_ios platform: group services: - service: mobile_app_jeffreys_iphone_11 - service: mobile_app_jeffreys_ipad - name: kat_ios platform: group services: - service: mobile_app_iphone - name: skylar_ios platform: group services: - service: mobile_app_skylars_iphone - 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 - 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 - platform: alexa_media name: alexa_media # 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 script: ############################################################################### # 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 }} text_notify: sequence: - condition: state entity_id: input_boolean.text_notifications state: 'on' - choose: - conditions: - condition: template value_template: '{{ who == "jeff"}}' - condition: state entity_id: input_boolean.text_notify_jeff state: 'on' sequence: - service: notify.jeff_ios data: title: '{{ title }}' message: '{{ message }}' - conditions: - condition: template value_template: '{{ who == "kat"}}' - condition: state entity_id: input_boolean.text_notify_kat state: 'on' sequence: - service: notify.kat_ios data: title: '{{ title }}' message: '{{ message }}' - conditions: - condition: template value_template: '{{ who == "skylar"}}' - condition: state entity_id: input_boolean.text_notify_skylar state: 'on' sequence: - service: notify.skylar_ios data: title: '{{ title }}' message: '{{ message }}' - conditions: - condition: template value_template: '{{ who == "parents"}}' - condition: state entity_id: input_boolean.text_notify_parents state: 'on' sequence: - service: notify.parents_ios data: title: '{{ title }}' message: '{{ message }}' default: - service: notify.all_ios data: title: '{{ title }}' message: '{{ message }}' text_alert: 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 # Conditions: # => Vacation mode should be off # Services: # => Audible # => iOS ############################################################################### alert_notify: sequence: - condition: state entity_id: input_boolean.vacation_mode state: 'off' - service: switch.turn_on entity_id: switch.ha_speaker - service: tts.google_translate_say data_template: entity_id: media_player.guest_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 == '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' %} .80 {% elif who == 'croft' %} .50 {% elif who == 'master_bedroom' %} .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 %} - 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 %} message: >- {{ message }} 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: 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: > {% 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. 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 %} - 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 == '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 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_notify: sequence: - service: > {% if who == 'thejeffreystone' %} notify.twitter_js {% elif who == 'slackerlabs' %} notify.twitter_sl {% else %} notify.twitter {% endif %} data_template: message: > {% set msg = '' %} {% set msg = msg + ' ' + message %} {% set msg = msg + ' #iot #smarthome' %} {{ msg }} twitter_notify_image: sequence: - service: > {% if who == 'thejeffreystone' %} notify.twitter_js {% elif who == 'slackerlabs' %} notify.twitter_sl {% else %} notify.twitter {% endif %} data_template: message: >- {{ tweet }} #iot #smarthome data: media: >- {{ image }} twitter_snark: sequence: - service: script.twitter_notify data_template: message: !include ../templates/twitter_snark.yaml twitter_stats: sequence: - service: script.twitter_notify data_template: message: !include ../templates/twitter_stats.yaml twitter_promos: sequence: - service: script.twitter_notify 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 }}' twitter_new_ha: sequence: - service: script.twitter_notify data_template: 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