I’ve been reading through the documentation and looked at several tutorials, but I can’t get actionable notifications working.
Here’s an example YAML that was originally done in the GUI. It’s intented to send an actionable notification with two options, and when you click one, it should send another notification to confirm it worked.
It sends the notification fine, and when I tap the button the wait for trigger section in Home Assistant lights up to indicate that it’s been triggered. But nothing further happens.
Any help appreciated!
alias: Actionable notification test
description: ""
trigger: []
condition: []
action:
- service: notify.notify
metadata: {}
data:
message: Message me?
data:
actions:
- action: ACTION_NOTIFY
title: Message me
- action: ACTION_IGNORE
title: Ignore
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: ACTION_NOTIFY
- platform: event
event_type: mobile_app_notification_action
event_data:
action: ACTION_IGNORE
continue_on_timeout: false
timeout:
hours: 0
minutes: 0
seconds: 0
milliseconds: 0
- alias: Perform the action
choose:
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == \"ACTION_NOTIFY\" }}"
sequence:
- service: notify.notify
metadata: {}
data:
message: Requested message
mode: single
Set the wait to have a timeout and it will work.
Your wait needs to wait for a time, and decide if you want to proceed if you don’t get a response. Right now the wait for a trigger is expecting the event to be ready when it starts (before you’ve even seen the notification), and when it’s not the automation is stopping because continue on timeout is false. A wait for a trigger without a timeout doesn’t wait forever.
Interesting, I haven’t heard that til now. Do you know how long it does wait for?
If you set the wait to 0, it will not wait at all and will proceed immediately (or stop the automation if continue is not set). It might be counter intuitive, in some systems a 0 wait means wait forever.
Thanks!
I got it working, though it seemed to be a combination of two things. I added the timeout, but it didn’t help. Then I read that sometimes calling a general notification doesn’t work, so I set it to specifically my phone and suddenly it worked! I removed the timeout, and broken again, so it definitely needs the timeout (despite saying it’s optional), so thanks for that tip! Weird that it still fires and recognises the trigger, but it just doesn’t do other actions because the automation already aborted.
Is there any issue setting super long timeouts? Can I set it to 24 or 48 hours without issue?
I have actionable notifications with notify.notify service working so I’m not sure there - something sounds off.
I don’t think there’s issues with long timeouts, but realize that they won’t persist through restarts of Home Assistant, and depending on your automation settings you can control the number of instances. To disconnect the action from the running automation I often add the event as another trigger to the automation and then add logic to handle the normal trigger and the notification trigger separately. No wait needed in the automation then, just fire the notification and another instance of the automation handles the action.
Oh that sounds like a better way of handling it! When I get a chance I’ll take another stab at it and see if I can get it working your way.
Have you tried running it through a YAML validator? I have found that a lot of times it’s simply spacing.
I just ran it through one, and it says it’s valid.
Home Assistant actually seems to validate it as well.
As @[email protected] already mentioned, I would recommend using a new automation for the action. Here is a simple example from my setup:
alias: Notification Action - Disable Theater Mode description: "" trigger: - platform: event event_type: mobile_app_notification_action event_data: action: THEATER_MODE_OFF condition: [] action: - service: input_boolean.turn_off data: {} target: entity_id: input_boolean.theater_mode mode: single
Thanks! I managed to get it working using one automation with three triggers (original trigger, plus one trigger for each of the two actions), where I have a conditional checking which of the triggers was the one that started the automation. It seems to work 🙂
deleted by creator