Skip to content

Instantly share code, notes, and snippets.

@jcallaghan
Last active February 13, 2020 10:05
Show Gist options
  • Save jcallaghan/2a7e6d73835bff19ca52a96a5bc056ec to your computer and use it in GitHub Desktop.
Save jcallaghan/2a7e6d73835bff19ca52a96a5bc056ec to your computer and use it in GitHub Desktop.
Example configuration and automation for actionable push notifications - this is triggered by motion when away and prompts me to sound an aggressive dog bar throughout the house using my Sonos speakers.
# Config
ios:
push:
categories:
- name: Alarm
identifier: 'alarm'
actions:
- identifier: 'alarm_silence'
title: 'Silence Alarm'
authenticationRequired: true
destructive: false
behavior: 'default'
activationMode: 'background'
- identifier: 'alarm_dogs'
title: 'Sounds Dogs'
destructive: false
activationMode: 'background'
- identifier: 'alarm_sirens'
title: 'Sound sirens'
destructive: true
activationMode: 'background'
# Automation 1 of 2 - initial action that sends the push notification with the actions
action:
- service: notify.ios_james_iphone
data_template:
title: 'Motion detected'
message: '{{ trigger.to_state.attributes.friendly_name | replace(" Motion", "") }} detected motion.'
data:
push:
category: 'alarm'
# Automation 2 of 2 - This listens for the push category actions.
alias: Security - Notification trigger alarm action
trigger:
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: ALARM_SILENCE
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: ALARM_SIRENS
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: ALARM_DOGS
action:
- service_template: >-
{% if trigger.event.data.actionName == "ALARM_SILENCE" %}
script.reset_sonos
{% elif trigger.event.data.actionName == "ALARM_SIRENS" %}
script.sound_dog_barking_1
{% elif trigger.event.data.actionName == "ALARM_DOGS" %}
script.sound_dog_barking_2
{% endif %}
data_template:
volume: 0.9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment