Postpone notification without extra helper - challenge?

Hello there guys,

recently I created a notification which reminds me to take a pill every morning and evening and it repeats every five minutes until I take it (means until I set the input_boolean as off via actionable button in notification itself).

That is working fine but I would like to take it a bit further. There are situations I cannot do it within 5/10/15 and so minutes. I do have two actions there. One is to turn on the reminder and the other one is to turn it off which is a part of the repeat section. To make it work since beginning before the repeat section I turn the reminder helper on so “postpone” action is actually doing nothing right now and I want to change it.

I want the notification being send at specific time morning/evening and repeat until I select “taken” from the action part in notification. When I select “postpone” it will pause the automation for let’s say 30 minutes and then runs it again. I am looking for a way to do it without another helper or automation if it is possible. Here is my script and automation itself.

automation:

alias: take_pill
description: ""
trigger:
  - platform: time
    at: "08:00:00"
  - platform: time
    at: "20:00:00"
condition: []
action:
  - action: input_boolean.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: input_boolean.take_pill_reminder
  - repeat:
      sequence:
        - action: script.pill
          metadata: {}
          data: {}
          enabled: true
        - delay:
            hours: 0
            minutes: 5
            seconds: 0
            milliseconds: 0
      until:
        - condition: state
          entity_id: input_boolean.take_pill_reminder
          state: "off"
mode: single

script:

alias: pill
sequence:
  - action: notify.mobile_app_telefon
    metadata: {}
    data:
      message: and drink water
      title: Take your pill
      data:
        actions:
          - action: taken
            title: Taken
            icon: sfsymbols:pill
            destructive: true
          - action: postpone
            title: Postpone
            icon: sfsymbols:clock
        push:
          sound: Spolkni prášek.wav
          critical: 1
          volume: 1
fields: {}
description: ""
icon: mdi:pill-multiple

Any ideas?

And as a bonus is there a way to clear all those previous notifications I did not take action on when I select “taken” or “postopne” - those which are related to this script/automation? Or a way to just repeat the sound without sending new notification?

Instead of an an automation why not use an alert with dynamic notification times?

Great! I didn’t know about this function, thank you.

Seems like it is doing exactly what I want. There is only one thing I cannot handle - the volume of the alert (which was not working in a script neither). I changed that from:
critical: 1
to:
interruption-level: critical
and the volume is really 100% which is a bit too much :slight_smile: I didn’t find any update on this, I tried 0.5/0,5/50% but it is not changing anything. Is it doing something or it is useless?

Anyway here is the final setup for those who might be interested and didn’t hear about alerts yet, just like me. Alert itself is in alerts.yaml included into configuration.yaml (or can be written directly in configuration.yaml)

Alert:

pill:
  name: Pill alert
  message: and drink some water
  title: Take your pill!
  data:
    actions:
      - action: taken
        title: Taken
        icon: sfsymbols:pill
        destructive: true
      - action: postpone
        title: Postpone
        icon: sfsymbols:clock
    push:
      sound: Spolkni prášek.wav
      interruption-level: time-sensitive ##want to use "critical" as it is bypass the muted phone but it is too loud
      volume: 10% ##probably useless
    tag: your-pill ##this tags the notification for clearing when done with done_message below and as that wanted bonus it does not create new when repeated but update the first one OR clear the previous one and create new - not really sure what is true
  done_message: clear_notification ##actual clearing
  entity_id: input_boolean.pill_reminder
  state: "on"
  repeat: 5
  can_acknowledge: true
  skip_first: false
  notifiers:
    - mobile_app_telefon

automation:

alias: pill_reminder_set
description: ""
trigger:
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: taken
    id: taken
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: postpone
    id: postpone
  - platform: time
    at: "08:00:00"
    id: morning
  - platform: time
    at: "20:00:00"
    id: evening
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.timer_pill
    id: timer
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - morning
              - evening
        sequence:
          - action: input_boolean.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.pill_reminder
      - conditions:
          - condition: trigger
            id:
              - taken
        sequence:
          - action: input_boolean.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.pill_reminder
          - action: timer.cancel
            metadata: {}
            data: {}
            target:
              entity_id: timer.timer_pill
      - conditions:
          - condition: trigger
            id:
              - postpone
        sequence:
          - action: input_boolean.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.pill_reminder
          - action: timer.start
            target:
              entity_id: timer.timer_pill
            data:
              duration: "1800"
            enabled: true
      - conditions:
          - condition: trigger
            id:
              - timer
        sequence:
          - action: input_boolean.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.pill_reminder
mode: single