Sticky Actionable Notification Buttons Only Work Once

When I make an Android “sticky” actionable notification, the notification buttons only work for the first button pressed. You can press either button after that, but they do nothing.

I was hoping to have a sticky notification that I can use to activate both buttons, and then swipe it away. Is this possible?

any errors in the companion app logs? can you share the YAML?

1 Like

There are no errors in the logs. YAML posted below.

I noticed that when I make one of the buttons a URL, that button will work every time, but the button that sends light.toggle will only work once.

alias: Actionable Notification Test
description: ""
trigger: []
condition: []
action:
  - variables:
      action_desk: "{{ 'DESK_' ~ context.id }}"
    alias: Set up variables for the actions
  - service: notify.mobile_app_pixel_6
    data:
      title: Test
      message: This is a test
      data:
        actions:
          - action: "{{ action_desk }}"
            title: Toggle
          - action: URI
            title: Google
            uri: https://www.google.com/
        sticky: "true"
  - wait_for_trigger:
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: "{{ action_desk }}"
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == action_desk }}"
        sequence:
          - service: light.toggle
            metadata: {}
            data: {}
            target:
              entity_id: light.zbmini_desk
mode: restart

split your automation into 2, your current wait_for_trigger only gets triggered one time as it only happens one time it does not wait for multiple triggers indefinitely. So while the automation only runs once the app is still sending the event if you subscribe to the event itself.

1 Like

Ahh, that makes sense.

I listened to the event “mobile_app_notification_action” in Developer tools, and I do see the events firing.

Since the context.id changes with each new notification, I ditched it completely. This has allowed me to simplify things considerably.

alias: Sticky Actionable Notification (Simplified)
description: "Example of an actionable notification that can be activated multiple times without automatically closing"
trigger: []
condition: []
action:
  - service: notify.mobile_app_PHONE_NAME_HERE
    data:
      title: Test
      message: This is a test
      data:
        actions:
          - action: ACTION_1
            title: Button Title
        sticky: true
mode: single

Then I just create an automation that triggers when “action: ACTION_1” shows up in the event “mobile_app_notification_action”.

platform: event
event_type: mobile_app_notification_action
event_data:
  action: ACTION_1
context: {}

This works exactly the way I want. Is there any reason I would want to use the context.id?

1 Like