SOLVED:
The YAML in the HA automation was incorrect.
This part was wrong with the id: mobile_app_notification_action
trigger:
- platform: event
event_type: ''
id: mobile_app_notification_action
event_data:
action: SPEAKERS_OFF
It should be this:
trigger:
- platform: event
event_type: "mobile_app_notification_action"
event_data:
action: SPEAKERS_OFF
I want to add an action to a working notification (to the iOS companion app). The action would then trigger an automation in HA. When I run the automation in HA, it works. I have the button coming up on the iOS app, but it appears the button does nothing.
Running Home Assistant 2021.12.7 with the node-red addon.
Here is the JSON for the call service node:
{
"title": "Speakers",
"message": "Kitchen Speakers are on.",
"data": {
"push": {
"sound": {
"name": "default"
}
},
"actions": [
{
"action": "SPEAKERS_OFF",
"title": "Turn off speakers.",
"icon": "sfsymbols:bell"
}
]
}
}
Here is the YAML for the HA automation (and automation works when triggered manually in HA).
alias: Turn off Speakers (Alert Action)
description: ''
trigger:
- platform: event
event_type: ''
id: mobile_app_notification_action
event_data:
action: SPEAKERS_OFF
condition: []
action:
- scene: scene.turn_off_speakers
- service: notify.mobile_app_andys_iphone_13
data:
message: Speakers have been turned off.
mode: single
And here is the output of the debug node for the call-service node that holds the actionable notification.
#Debug output in node-red from the node that triggers the notification
msg :
object
domain: "notify"
service: "mobile_app_iphone_13"
data: object
title: "Speakers"
message: "Kitchen Speakers are on."
data: object
push: object
sound: object
name: "default"
actions: array[1]
0: object
action: "SPEAKERS_OFF"
title: "Turn off speakers."
icon: "sfsymbols:bell"
I’ve watched a bunch of videos, read the docs, and found a similar thread where someone was able to get it working. But when copying and pasting that solution it didn’t work and got a "Call-service error. required key not provided @ data['message']"
error. Tried tweaking it a little here and there to get the error gone and was able to do that, but still can’t trigger that action in HA.
Anyone know what I’m missing or can help me out to get this working? How do I make an actionable notification in node-red so that something will happen in HA when the button is pressed?