mysmarthome/packages/notify.yaml

344 lines
11 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:
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
2020-09-08 02:02:44 +00:00
- name: telegram
platform: telegram
chat_id: !secret telegram_chatid
2019-04-17 22:46:06 +00:00
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
2020-09-08 02:02:44 +00:00
#
# Telegram Configuration
#
2020-03-15 23:42:44 +00:00
telegram_bot:
- platform: broadcast
api_key: !secret telegram_apikey
allowed_chat_ids:
- !secret telegram_chatid
2020-09-08 02:02:44 +00:00
- platform: polling
api_key: !secret telegram_apikey
2021-08-31 02:07:33 +00:00
parse_mode: html
2020-09-08 02:02:44 +00:00
allowed_chat_ids:
- !secret telegram_chatid
2022-12-03 16:28:12 +00:00
2022-12-04 17:38:48 +00:00
###############################################################################
# _ _ _ _ __
# | \ | | | | (_)/ _|
# | \| | ___ | |_ _| |_ _ _
# | . ` |/ _ \| __| | _| | | |
# | |\ | (_) | |_| | | | |_| |
# |_| \_|\___/ \__|_|_| \__, |
# __/ |
# |___/
# Notify Related Scripts
###############################################################################
2022-12-03 16:28:12 +00:00
script:
2022-12-06 22:52:48 +00:00
notify_family_with_picture:
sequence:
- condition: template
value_template: '{{ message | trim != "" }}'
- service: script.notify_telegram_with_picture
data:
url: "{{ url }}"
path: "{{ path }}" # local path
title: "{{ title }}"
message: "{{ message }}"
notify_options: "{{ notify_options }}"
- service: script.notify_email_with_picture
data:
title: "{{ title }}"
message: "{{ message }}"
path: "{{ path }}" # local path
notify_options: "{{ notify_options }}"
2022-12-03 16:28:12 +00:00
notify_family:
sequence:
- condition: template
value_template: '{{ message | trim != "" }}'
- service: script.notify_on_led_screen
2022-12-05 00:02:34 +00:00
data:
2022-12-03 16:28:12 +00:00
message: "{{ message }}"
notify_options: "{{ notify_options }}"
- service: script.notify_firestick
2022-12-05 00:02:34 +00:00
data:
url: "{{ url }}" # local url
path: "{{ file }}" # local path
2022-12-03 16:28:12 +00:00
title: "{{ title }}"
message: "{{ message }}"
notify_options: "{{ notify_options }}"
- service: script.notify_telegram
2022-12-05 00:02:34 +00:00
data:
2022-12-03 16:28:12 +00:00
title: "{{ title }}"
message: "{{ message }}"
notify_options: "{{ notify_options }}"
- service: script.notify_email
2022-12-05 00:02:34 +00:00
data:
2022-12-03 16:28:12 +00:00
title: "{{ title }}"
message: "{{ message }}"
notify_options: "{{ notify_options }}"
- service: script.notify_voice
2022-12-05 00:02:34 +00:00
data:
2022-12-03 16:28:12 +00:00
message: "{{ message }}"
notify_options: "{{ notify_options }}"
###############################################################################
# NOTIFY OPTIONS
# 1. tv
# 2. telegram
# 3. led
# 4. email
# 5. voice
###############################################################################
notify_firestick:
sequence:
2022-12-04 17:38:48 +00:00
- condition: state
2022-12-04 19:33:29 +00:00
entity_id: input_boolean.firetv_notifications
2022-12-04 17:38:48 +00:00
state: "on"
2022-12-03 16:28:12 +00:00
- condition: template
value_template: "{{ 'tv' in notify_options }}"
- service: notify.android_tv_fire_tv
data:
message: "{{ message }}"
title: Mahasri Bot
data:
color: red
duration: 7
2022-12-05 00:02:34 +00:00
url:
path: "{{ url }}" #/config/www/downloads/camera/driveway/driveway_20220604_185216.jpg
2022-12-06 22:52:48 +00:00
image:
url: "{{ url }}" #/config/www/downloads/camera/driveway/driveway_20220604_185216.jpg
2022-12-03 16:28:12 +00:00
icon:
2022-12-04 17:38:48 +00:00
path: >
/config/www/{{- [ "suresh.jpg", "srinika.jpg", "mallika.jpg", "hasika.jpg",
"bob.jpg", "butters.jpg", "eric.jpg", "gene.jpg", "kyle.jpg", "linda.jpg",
"lois.jpg", "louis.jpg", "meg.jpg", "morty.jpg", "peter.jpg", "quagmire.jpg",
"randy.jpg", "tina.jpg" ] | random -}}
2022-12-03 16:28:12 +00:00
notify_telegram:
sequence:
2022-12-04 17:38:48 +00:00
- condition: state
2022-12-04 19:20:32 +00:00
entity_id: input_boolean.telegram_notifications
2022-12-04 17:38:48 +00:00
state: "on"
2022-12-03 16:28:12 +00:00
- condition: template
value_template: "{{ 'telegram' in notify_options }}"
2022-12-05 00:02:34 +00:00
- service: notify.telegram
2022-12-03 16:28:12 +00:00
data:
2022-12-05 00:02:34 +00:00
message: "{{ message }}"
title: "{{ title }}"
2022-12-03 16:28:12 +00:00
notify_email:
sequence:
2022-12-04 17:38:48 +00:00
- condition: state
2022-12-04 19:20:32 +00:00
entity_id: input_boolean.email_notifications
2022-12-04 17:38:48 +00:00
state: "on"
2022-12-03 16:28:12 +00:00
- condition: template
value_template: "{{ 'email' in notify_options }}"
2022-12-04 17:38:48 +00:00
- service: notify.notify_smtp
2022-12-05 00:02:34 +00:00
data:
2022-12-03 16:28:12 +00:00
title: "{{ title }}"
message: "{{ message }}"
notify_voice:
sequence:
2022-12-04 17:38:48 +00:00
- condition: state
2022-12-04 19:20:32 +00:00
entity_id: input_boolean.voice_notifications
2022-12-04 17:38:48 +00:00
state: "on"
2022-12-03 16:28:12 +00:00
- condition: template
value_template: "{{ 'voice' in notify_options }}"
- service: script.voice_notify
2022-12-05 00:02:34 +00:00
data:
2022-12-03 16:28:12 +00:00
message: "{{ message }}"
notify_on_led_screen:
sequence:
2022-12-04 17:38:48 +00:00
- condition: state
entity_id: input_boolean.led_notifications
state: "on"
2022-12-03 16:28:12 +00:00
- condition: template
value_template: "{{ 'led' in notify_options }}"
- service: mqtt.publish
2022-12-05 00:02:34 +00:00
data:
2022-12-03 16:28:12 +00:00
topic: messageboard/messages
payload: "{{ message }}"
2022-12-04 17:38:48 +00:00
2022-12-06 22:52:48 +00:00
notify_telegram_with_picture:
sequence:
- condition: state
entity_id: input_boolean.telegram_notifications
state: "on"
- condition: template
value_template: "{{ 'telegram' in notify_options }}"
- service: notify.telegram
data:
message: "{{ message }}"
title: "{{ title }}"
data:
photo:
- url: "{{ url }}"
caption: "{{ title }}"
notify_email_with_picture:
sequence:
- condition: state
entity_id: input_boolean.email_notifications
state: "on"
- condition: template
value_template: "{{ 'email' in notify_options }}"
- delay: "00:00:20"
- service: notify.notify_smtp
data:
title: "{{ title }}"
message: "{{ message }}"
data:
images:
- "{{- path -}}"
2022-12-04 17:38:48 +00:00
###############################################################################
# Voice Notify
# Conditions:
# => Only Announce when people are home. Except in emergency mode!
# => Only Announce when Music is NOT being played
###############################################################################
voice_notify:
sequence:
- condition: template
value_template: "{{ states('input_boolean.voice_notifications') == 'on' }}"
- condition: template
value_template: "{{ states('input_boolean.do_not_disturb') | lower == 'off' }}"
- condition: template
value_template: "{{ message | trim != '' }}"
- condition: template
value_template: "{{ states('input_boolean.home_mode_away') == 'off' }}"
- condition: template
value_template: >
{% if only_at_night | default('no', true ) == "yes" %}
{% if states('sun.sun') == "above_horizon" %}
false
{% else %}
true
{% endif %}
{% else %}
true
{% endif %}
- service: media_player.volume_set
entity_id: media_player.living_room, media_player.upstairs
2022-12-05 00:02:34 +00:00
data:
2022-12-04 17:38:48 +00:00
volume_level: >
{% if states('input_boolean.emergency_mode') == "on" %}
{{ states('input_number.tts_volume_level_alert') }}
{% else %}
{% if now().hour | int < 12 and now().hour | int > 6 %}
{{ states('input_number.tts_volume_level_morning') }}
{% elif now().hour|int > 12 and now().hour|int < 20 %}
{{ states('input_number.tts_volume_level_afternoon') }}
{% else %}
{{ states('input_number.tts_volume_level_evening') }}
{% endif %}
{% endif %}
- service: tts.amazon_polly_say
entity_id: media_player.living_room, media_player.upstairs
2022-12-05 00:02:34 +00:00
data:
2022-12-04 17:38:48 +00:00
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 }}
###############################################################################
# Greeting
###############################################################################
voice_greeting:
sequence:
- service: tts.amazon_polly_say
entity_id: media_player.living_room, media_player.upstairs
2022-12-05 00:02:34 +00:00
data:
2022-12-04 17:38:48 +00:00
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 }}