This has come up a couple of times recently, so I thought I’d post some of my success with Actionable Notifications. They have gotten a lot simpler than they used to be, and they’re super nice if you’ve got an Apple Watch to use them.
The first thing you need to know, and this is important, is that Actionable Notification choices are not shown by default on an iPhone. You need to LONG PRESS on the notification to see them. Apple has no indicator showing an actionable notification is any different from a regular notification, so you either have to write text indicating this, or remember this fact.
An “Actionable Notification” disguised as a regular notification:
What happens after you “long tap”:
The necessary YAML to make the magic happen:
automation:
- alias: Test Notify Mobile app
trigger:
platform: state
entity_id: input_boolean.test_toggle
action:
service: notify.iphone
data:
title: "Check this out!"
message: "Something happened at home!"
data:
actions:
- action: "SOUND_ALARM" # The key you are sending for the event
title: "Sound Alarm" # The button title
icon: "sfsymbols:lock.fill"
- action: "SILENCE_ALARM" # The key you are sending for the event
title: "Silence Alarm" # The button title
icon: "sfsymbols:airplane.departure"
- action: "URI" # Must be set to URI if you plan to use a URI
title: "Open Url"
uri: "https://google.com" # URL to open when action is selected, can also be a lovelace view/dashboard
- alias: Test push on
trigger:
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: 'SOUND_ALARM'
action:
- service: notify.pushover_me
data:
message: 'SOUND ALARM'
- alias: Test push off
trigger:
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: 'SILENCE_ALARM'
action:
- service: notify.pushover_me
data:
message: 'SILENCE ALARM'
What this looks like on an Apple Watch:
You can also setup actions for your HA app on Apple Watch to execute common tasks:
Here’s the YAML for the above buttons:
ios:
actions:
- name: 'ARM_NIGHT'
background_color: "#1c1741"
label:
text: "Alarm Night"
color: "#1d00ff"
icon:
icon: weather-night
color: "#1d00ff"
- name: 'COMMON_LIGHTS_OFF'
background_color: "#555555"
label:
text: "Common Off"
color: "#DDDDDD"
icon:
icon: lightbulb
color: "#000000"
- name: 'ARM_AWAY'
background_color: "#411616"
label:
text: "Alarm Away"
color: "#ff0003"
icon:
icon: lock
color: "#ff0003"
- name: 'SILENCE_DOOR_ALERT'
background_color: "#411939"
label:
text: "Silence Door"
color: "#ff00e3"
icon:
icon: bell-off
color: "#ff00e3"
- name: 'INTERIOR_LIGHTS_OFF'
background_color: "#555555"
label:
text: "Interior Off"
color: "#DDDDDD"
icon:
icon: lightbulb
color: "#000000"
- name: 'ARM_VACATION'
background_color: "#172b41"
label:
text: "Vacation"
color: "#03c7ff"
icon:
icon: island
color: "#03c7ff"
- name: 'GARAGE_CAR_DOOR_TOGGLE'
background_color: "#413c17"
label:
text: "Garage Door"
color: "#ff9d00"
icon:
icon: car-hatchback
color: "#ff9d00"
- name: 'DISARM'
background_color: "#2d4148"
label:
text: "Disarm Alarm"
color: "#03ff00"
icon:
icon: lock-open
color: "#03ff00"
And the resulting action triggers to make them do something when tapped:
automation:
- alias: IOS Alarm Away
trigger:
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: 'ARM_AWAY'
- platform: event
event_type: ios.action_fired
event_data:
actionName: 'ARM_AWAY'
action:
- service: alarm_control_panel.alarm_arm_away
entity_id: alarm_control_panel.home
- service: script.light_common_area_off
- service: script.light_bedroom_area_off
- alias: IOS Alarm Night
trigger:
platform: event
event_type: ios.action_fired
event_data:
actionName: 'SOUND_ALARM'
action:
- service: alarm_control_panel.alarm_arm_night
entity_id: alarm_control_panel.home
- service: script.light_common_area_off
- alias: IOS Alarm Vacation
trigger:
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: 'ARM_VACATION'
- platform: event
event_type: ios.action_fired
event_data:
actionName: 'ARM_VACATION'
action:
- service: alarm_control_panel.alarm_arm_away
entity_id: alarm_control_panel.home
- service: input_boolean.turn_on
entity_id: input_boolean.vacation
- service: script.light_common_area_off
- service: script.light_bedroom_area_off
- alias: IOS Alarm Disarm
id: ios_alarm_disarm
trigger:
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: 'DISARM'
action:
- service: alarm_control_panel.alarm_disarm
entity_id: alarm_control_panel.home
- service: input_boolean.turn_off
entity_id: input_boolean.vacation
- alias: IOS Common Lights Off
id: ios_common_lights_off
trigger:
platform: event
event_type: ios.action_fired
event_data:
actionName: 'COMMON_LIGHTS_OFF'
action:
- service: script.light_common_area_off
- alias: IOS Interior Lights Off
id: ios_interior_lights_off
trigger:
platform: event
event_type: ios.action_fired
event_data:
actionName: 'INTERIOR_LIGHTS_OFF'
action:
- service: script.light_common_area_off
- service: script.light_bedroom_area_off
- alias: IOS Garage Car Door Toggle
id: ios_garage_car_door_toggle
trigger:
platform: event
event_type: ios.action_fired
event_data:
actionName: 'GARAGE_CAR_DOOR_TOGGLE'
action:
- service: cover.toggle
data: {}
target:
entity_id: cover.garage_door
- alias: IOS Silence Door Alert
id: ios_silence_door_alert
trigger:
platform: event
event_type: ios.action_fired
event_data:
actionName: 'SILENCE_DOOR_ALERT'
action:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.alert_silence
Note the ARM_VACATION and ARM_AWAY which have two different methods of being triggered. The ios_action_fired is from the Watch and the ios.notification_action_fired is from an Actionable Notification, as below:
automation:
- alias: "Tracker All Away"
trigger:
platform: state
entity_id: group.persons_all
to: not_home
for:
minutes: 30
condition:
- condition: state
entity_id: alarm_control_panel.home
state: disarmed
action:
service: notify.iphone
data:
title: "All Persons Away"
message: "Set alarm?"
data:
actions:
- action: "ARM_AWAY" # The key you are sending for the event
title: "Away" # The button title
- action: "ARM_VACATION"
title: "Vacation"
- action: "NOTHING"
title: "Ignore"
Hope that helps! Have fun.