mysmarthome/packages/notify.yaml

238 lines
7.8 KiB
YAML
Raw Normal View History

2019-04-17 22:46:06 +00:00
###############################################################################
# @author : Mahasri Kalavala
# @date : 04/15/2017
# @package : Scripts
# @description : Nothing but Notification Stuff!
###############################################################################
homeassistant:
customize:
group.tts_announcements:
order: 52
# Script Stuff
script.home_status:
friendly_name: Home Status (Hourly Report)
script.home_mode_away:
friendly_name: Set Home Mode to AWAY
script.good_night_tts:
friendly_name: Good Night TTS Report
script.voice_notify:
hidden: true
script.voice_greeting:
hidden: true
script.ifttt_leeo_color_change:
hidden: true
script.ifttt_notify:
hidden: true
script.notify_me:
hidden: true
ifttt:
key: !secret ifttt_key
notify:
- name: ios_devices
platform: group
services:
- service: ios_ipad
- service: ios_suresh
- service: ios_mallika
- service: ios_srinika
- service: ios_hasika
2019-12-20 15:32:28 +00:00
2019-04-17 22:46:06 +00:00
# make sure you generate app password for your email if you have 2FA enabled!
- name: notify_smtp
platform: smtp
server: smtp.gmail.com
port: 587
timeout: 15
username: !secret smtp_username
password: !secret smtp_password
2019-12-20 15:32:28 +00:00
sender: !secret smtp_sender
2019-04-17 22:46:06 +00:00
recipient: !secret smtp_recipient
2019-05-14 23:32:32 +00:00
# - name: notify_aws_sns
# platform: aws_sns
# aws_access_key_id: !secret aws_access_key_id
# aws_secret_access_key: !secret aws_secret_access_key
# region_name: 'us-east-1'
2019-04-17 22:46:06 +00:00
- name: file_notify
platform: file
filename: debug.log
tts:
- platform: amazon_polly
aws_access_key_id: !secret aws_access_key_id
aws_secret_access_key: !secret aws_secret_access_key
2019-12-20 15:32:28 +00:00
region_name: "us-east-1"
2019-04-17 22:46:06 +00:00
text_type: ssml
voice: Joanna
script:
2019-12-20 15:32:28 +00:00
###############################################################################
# Notify Related Scripts
###############################################################################
2019-04-17 22:46:06 +00:00
ifttt_notify:
sequence:
- condition: template
value_template: '{{ message | trim != "" }}'
- service: ifttt.trigger
data_template:
event: "Smart_Home"
value1: "{{ message }}"
value2: ""
ifttt_leeo_color_change:
sequence:
- condition: template
value_template: '{{ value1 | trim != "" }}'
- service: ifttt.trigger
2019-12-20 15:32:28 +00:00
data_template:
2019-04-17 22:46:06 +00:00
event: "LEEO_COLOR_CHANGE"
2019-12-20 15:32:28 +00:00
value1: "{{ value1 }}"
2019-04-17 22:46:06 +00:00
notify_me:
sequence:
- condition: state
entity_id: input_boolean.text_alerts
2019-12-20 15:32:28 +00:00
state: "on"
2019-04-17 22:46:06 +00:00
- condition: template
value_template: '{{ message | trim != "" }}'
- service: script.ifttt_notify
data_template:
message: "{{ message }}"
good_night_tts:
sequence:
- service: script.voice_notify
data_template:
message: !include ../templates/goodnight.yaml
2019-12-20 15:32:28 +00:00
###############################################################################
# Voice Notify
# Conditions:
# => Only Announce when people are home. Except in emergency mode!
# => Only Announce when Music is NOT being played
###############################################################################
2019-04-17 22:46:06 +00:00
voice_notify:
sequence:
2020-03-14 00:10:10 +00:00
# - service: script.led_message
# data_template:
# message: "{{ message }}"
2019-04-17 22:46:06 +00:00
- condition: template
2019-12-20 15:32:28 +00:00
value_template: "{{ states('input_boolean.voice_notifications') == 'on' }}"
2019-04-17 22:46:06 +00:00
- condition: template
2019-12-20 15:32:28 +00:00
value_template: "{{ states('input_boolean.do_not_disturb') | lower == 'off' }}"
2019-04-17 22:46:06 +00:00
- condition: template
2019-12-20 15:32:28 +00:00
value_template: "{{ message | trim != '' }}"
2020-02-09 23:33:06 +00:00
- condition: template
value_template: "{{ states('input_boolean.home_mode_away') == 'off' }}"
2019-04-17 22:46:06 +00:00
- condition: template
value_template: >
{% if only_at_night | default('no', true ) == "yes" %}
2019-12-20 15:32:28 +00:00
{% if states('sun.sun') == "above_horizon" %}
2019-04-17 22:46:06 +00:00
false
{% else %}
true
{% endif %}
{% else %}
true
{% endif %}
- service: media_player.volume_set
2020-02-05 23:28:38 +00:00
entity_id: media_player.living_room, media_player.upstairs
2019-04-17 22:46:06 +00:00
data_template:
volume_level: >
2019-12-20 15:32:28 +00:00
{% if states('input_boolean.emergency_mode') == "on" %}
{{ states('input_number.tts_volume_level_alert') }}
2019-04-17 22:46:06 +00:00
{% else %}
{% if now().hour | int < 12 and now().hour | int > 6 %}
2019-12-20 15:32:28 +00:00
{{ states('input_number.tts_volume_level_morning') }}
2019-04-17 22:46:06 +00:00
{% elif now().hour|int > 12 and now().hour|int < 20 %}
2019-12-20 15:32:28 +00:00
{{ states('input_number.tts_volume_level_afternoon') }}
2019-04-17 22:46:06 +00:00
{% else %}
2019-12-20 15:32:28 +00:00
{{ states('input_number.tts_volume_level_evening') }}
2019-04-17 22:46:06 +00:00
{% endif %}
{% endif %}
- service: tts.amazon_polly_say
2020-02-05 23:28:38 +00:00
entity_id: media_player.living_room, media_player.upstairs
2019-04-17 22:46:06 +00:00
data_template:
cache: true
message: >
{% set msg = "" %}
{% macro getGreeting() %}
{% if greeting | default('yes', true ) == "yes" %}
{% if now().hour|int < 12 %}
Good morning.
{% elif now().hour|int < 18 %}
Good afternoon.
{% else %}
Good evening.
{% endif %}
{% endif %}
{% endmacro %}
{%- macro getEndGreeting() -%}
{%- if greeting |default('yes', true ) == "yes" -%}
Thank you!
{%- endif -%}
{%- endmacro -%}
{% set msg = msg + "<speak> " %}
{% set msg = msg + getGreeting() %}
{% set msg = msg + ". " + message %}
{% set msg = msg.replace(".", " <break time='0.5s'/> ") %}
{% set msg = msg + " " + getEndGreeting() %}
{% set msg = msg + " </speak>" %}
{{ msg }}
2019-12-20 15:32:28 +00:00
###############################################################################
# Greeting
###############################################################################
2019-04-17 22:46:06 +00:00
voice_greeting:
sequence:
- service: tts.amazon_polly_say
2020-02-05 23:28:38 +00:00
entity_id: media_player.living_room, media_player.upstairs
2019-04-17 22:46:06 +00:00
data_template:
cache: true
message: >
{% set msg = "" %}
{% macro getGreeting() %}
{% if greeting | default('yes', true ) == "yes" %}
{% if now().hour|int < 12 %}
Good morning.
{% elif now().hour|int < 18 %}
Good afternoon.
{% else %}
Good evening.
{% endif %}
{% endif %}
{% endmacro %}
{% set msg = msg + "<speak> " %}
{% set msg = msg + " " + getGreeting() %}
{% set msg = msg.replace(".", " <break time='0.5s'/> ") %}
{% set msg = msg + " </speak>" %}
{{ msg }}
2019-12-20 15:32:28 +00:00
###############################################################################
# Status around the house
###############################################################################
2019-04-17 22:46:06 +00:00
home_status:
sequence:
- service: script.voice_notify
data_template:
2019-12-20 15:32:28 +00:00
message: !include ../templates/home_status.yaml
2020-03-14 00:10:10 +00:00
###############################################################################
# Display message on LED Matrix Screen
###############################################################################
led_message:
sequence:
- condition: state
entity_id: input_boolean.led_alerts
state: "on"
- service: mqtt.publish
data_template:
topic: messageboard/messages
payload: >
{ 'message': '{{ message }}','frameDelay': 50 }