I’ve been trying to get this to work tonight and I’m at a point where this feels entirely too convoluted to be correct. Here’s what I’m trying to accomplish:
Alert triggered
Notification sent
Action slected
Stuff happens
I’ve gotten a test setup with a simple input_boolean that triggers an alert, the alert successfully gets delivered to my phone, but the events never trigger the automation that acts on the event. The order of operations within Home Assistant (from my understanding), is as follows:
Create item to be monitored
Create alert that monitors item
Create notification group that can be accessed by alert component
Create iOS notification actions
Create automation to act upon ios.notification_action_fired events
Again, this feels really convoluted, and I’m either grossly missing something or so far off that someone can hopefully point out my stupidity.
No clue why I removed the title fields. I believe that’s what you were referencing. I know a lot of people seem to use upper case for the action identifiers, but the documentation does specify that lower case is valid.
And this is why I needed a sanity check. It was getting late and I was running out of steam. The weird part is that the actionable notification worked previously. I must have made that mistake at some point.
Okay, so I’m to the point where the automation isn’t triggering. If I go into the dev tools and listen for the ios.notification_action_fired I do see the event from when I select a notification action.
whereas the JSON event has the actionName field nested within a data object. I’ve made the condition template "{{ trigger.data.actionName == "alert_test_yes" }}", but it does me no good if I can’t get the automation to trigger.
One possibility is that I am trying to trigger on an array of different actionName values rather than creating individual triggers for each, but I’m trying to consolidate as much as possible. As I’ve said before, it already seems really convoluted that I’ve had to create 5 separate components for this task.
I haven’t seen lists given to actionName until now. Have you come across this somewhere? I can understand that you might’ve deduced this as a possibility (it intuitively makes sense). Genuinely curious.
Since you say that you see the event under the dev tools: How sure are you it’s not triggering vs one of the choose sequences not executing? Perhaps for testing purposes, just have one simple action that creates a persistent notification with a message or the data to confirm whether it’s the trigger or the choose conditions (or some other mechanism you fancy, such as an input_text or writing to the system log).
If you eventually get this to work maybe bear in mind that it may only be working as a side effect and that it may break in the future.
Ideally, I’d like to turn all of this into a blueprint that I could share with the community since so many people get hung up on actionable notifications, but I’m worried that I might have to to go down the route of creating individual automations for each notification action.
I’m looking at breaking the notification service itself off into a separate script that I can reuse. Carlo has a great example in his repo.
Something that stands out is that the actionName is still converted to upper case. I changed my condition template to "{{ trigger.event.data.actionName | lower == "alert_test_yes" }}", but it still isn’t hitting one of the choose conditions. I changed it to upper case in both the identifier and template, and it’s still not hitting.
I changed the automation to the following… and it works.
Okay, I figured out you can trigger on the ios push category name. Now I’ve just got to figure out the templates for picking out the correct action names.
Current template is "{{ trigger.event.data.actionName == "ALERT_TEST_YES" }}"
Looking at the documentation, it should match, but maybe I’ve got my string comparison operator wrong.
I can’t see anything wrong myself. These are guesses but perhaps the data is still JSON, or the casing changed (e.g. to action_name).
As an alternative, you can pass your own data along. I know it’s redundant since the actionName is already there but until you can figure out how to get to it.