Actionable Notifications Timeout

Hi all

I’ve been trying to get some actionable notification working, but can not achieve the wanted result.

In an nutshell, I want a notification being sent in the morning with “Yes” and “No” as options. If the response is yes, no further action is needed. If the response is no, then I want the notification to appear later that day at maybe 9pm again. However, if there is no response or the notification cleared for that matter, it should appear later again.

What I struggle to get to work, is if either the notification gets cleared or there is no response. Any help would be appreciated.

alias: Reminder Inhaler
description: ""
trigger:
  - platform: time
    at: "09:00:00"
    enabled: true
condition: []
action:
  - alias: Set up variables for the actions
    variables:
      action_yes: "{{ 'YES_' ~ context.id }}"
      action_no: "{{ 'NO_' ~ context.id }}"
  - alias: Ask if inhaler was used
    service: notify.mobile_app_s23u
    data:
      message: Did you already use your Inhaler?
      data:
        actions:
          - action: "{{ action_yes }}"
            title: "Yes"
          - action: "{{ action_no }}"
            title: "No"
      title: Inhaler Reminder
  - alias: Wait for a response
    wait_for_trigger:
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: "{{ action_yes }}"
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: "{{ action_no }}"
      - platform: event
        event_type: mobile_app_notification_cleared
        event_data:
          action_1_key: "{{ action_open }}"
  - alias: Perform the action
    choose:
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == action_yes }}"
            enabled: true
        sequence: []
      - conditions:
          - condition: template
            value_template: "{{ wait.trigger.event.data.action == action_no }}"
            enabled: true
        sequence:
          - delay:
              hours: 0
              minutes: 1
              seconds: 0
              milliseconds: 0
          - alias: Reminder Inhaler
            service: notify.mobile_app_s23u
            data:
              message: Remember your inhaler before sleeping!
              title: Inhaler Reminder
              data:
                actions:
                  - action: "{{ action_yes }}"
                    title: Ok
      - conditions:
          - condition: template
            value_template: >-
              {{ wait.trigger.event.event_type ==
              'mobile_app_notification_cleared' }}
        sequence:
          - service: light.toggle
            metadata: {}
            data: {}
            target:
              entity_id: light.pc_ambient_light
mode: parallel
max: 10

When a Wait for Trigger times out, the value of wait.trigger will be none, so you can use that if you need a specific action sequence for a time out. But don’t forget that you can set a default sequence for your Choose action so that any trigger (or lack of trigger) that doesn’t meet the specific condition set for one of the Options will be funneled into that sequence.

For your “no” response, the basic approach would be to set up an automation to send the notification at your desired later time with a condition, such as the state of an Input boolean helper, which can be controlled by the first automation.

1 Like

Hi,

For the clear problem, for me the Persistent Notification worked well. You can’t dismiss the notification until you press “Yes” or “No”.
Since I have a new android phone it doesn’t work anymore. I can dismiss the Persistent Notification like any other standard notify.

service: notify.mobile_app_android
data:
  message: text
  title: text
  data:
    ttl: 0
    priority: high
    actions:
      - action: action
        title: title_action_button
    persistent: true
    tag: name_of_tag
    sticky: true
1 Like