Unable to setup Actionable Notifications in 1 Automation - Specifically Template Variable in Condition Action

I am now unable to get actionable notifications to work under one automation. I have managed to get this to work in the past but not anymore. I am not sure if this was because of an update to HA or just the configuration is just wrong.

Here is my YAML automation:

alias: "Notification: Actionable (Example)"
description: ""
trigger: []
condition: []
action:
  - service: notify.mobile_app_maia_pixel_7_pro
    data:
      message: Message
      title: Title
      data:
        actions:
          - action: action_open
            title: Open
          - action: action_close
            title: Close
  - wait_for_trigger:
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: action_open
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: action_close
    continue_on_timeout: false
    timeout:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == action_open }}"
        sequence:
          - service: notify.alexa_media_kitchen_echo
            data:
              message: open
              data:
                type: tts
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == action_close }}"
        sequence:
          - service: notify.alexa_media_kitchen_echo
            data:
              data:
                type: tts
              message: close
    default:
      - service: notify.alexa_media_kitchen_echo
        data:
          data:
            type: tts
          message: default
mode: single

If I remove the Condition step and have separate automations based on the action, it works, but ideally I would like to keep it all under one automation like the above. So the issue appears to be the vaule_template code which is causing the problem. Can someone help me please?

Inside each of the value templates, term to the right of the equal sign in the comparison needs to be in quotes since the value for action is returned as a string.

...
        conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == 'action_open' }}"
        sequence:
...

I also tried that and unfortunately that doesnt work either. I can see that the wait action is being triggered

Post the actual automation… and the debugging trace.

Here is the debugging trace on the wait action:

Here is the full automation in UI:

According to the documentation, actions need to be in all caps. This is how I have mine configured, and I have no issues.

1 Like

From what I can see from the trace debbuging, is that the wait.trigger is null. Would you mind sharing yours?

  1. This is unreadable… always post the YAML, not a screenshot.
  2. It’s not a full automation. Automations must have a trigger.

You should always post the full trace json file. A single screenshot has a lot of information missing.

As indicated in the trace, your wait is timing out.

Options:

  1. Use a non-zero wait time.
  2. Remove the timeout portion completely. (Not recommended)

Optional:
Do #1 above and change continue_on_timeout to true to receive the default notification after timeout.

Apologies, I have managed to get it to work and you are right. I changed the timeout time to 1m for testing and it works. I didnt need to have the action in all caps but I did need to add double quotes around the action for the template i.e. {{ wait.trigger.event.data.action == "action_open" }}

Thank you so much for your help.

1 Like

THANK YOU!!!
Why are the double quotes not listed in the official documentation!
I was going crazy, but you my friend, have made me sane again.

Thank you.

The example actionable notification in the HA Companion app docs doesn’t show comparing the Wait trigger action to a string because it defines the value in a variable that returns a unique action string. The example is specifically set up this way to show best practices which will prevent you from experiencing seemingly random triggers.

image

If you do not use the suggested method then you must make sure all your actions are, at a minimum, unique to the script or automation they are in and to clear notifications completely.