So a while ago I was thinking about notifications. I hate the idea of sprinkling to many specifics all across the configs. The notifier group is extremely useful for preventing this. But I still wanted TTS. So I ended up with something like this:
notify:
# For alerts
- name: notifier
platform: group
services:
- service: kodi_livingroom
- service: kodi_bedroom
- service: mobile_app_iphone
script:
alert:
sequence:
- service: notify.notifier
data_template:
message: "{{ message }}"
- service: tts.google_say
entity_id: media_player.hallway
data_template:
message: "{{ message }}"
That lets me have audible and push notifications sent by just calling a script! How sweet is that?! I can switch from telegram to the ios app with just a small tweak and it all works. Awesome!
Now I’ve been looking at critical notifications and curious if anyone’s figured out a nice way to do this. Obviously I don’t want every notification to be critical. So I need to pass more than message, but I’d like the default to be non-critical. As I understand it for ios I pretty much need to pass:
data:
push:
sound:
name: default
critical: 1
volume: 1.0 # 0.0 to 1.0
So what I’m trying to figure out is the best way to do this so that I can keep using a pretty straightforward:
- service: script.alert
data_template:
message: " {{ trigger.to_state.attributes.friendly_name }} triggered"
But only on occasion pass in an additional flag to make it critical.
Curious if anyone’s done something similar and/or has idea on how to do this. I’m not married to any particular element, but prefer to consolidate the logic for notifications as much as possible to avoid duplication.