Advanced medication reminder

thank you, file updated

No thank you for all your hard work setting up the blueprint. Glad I could help

I have android pixel but when I click on any of the options (taken / ask later / skip) it is not recorded. So after the reminder I get a new notification. I click always on taken but for some reason it’s not send back to HA.

2 Likes

Hi Same problem as above with my wife Samsung s21. When i took a look at the blueprint the IOS version and the Android version are the same!

The Android Version of the blueprint is not correct (it is for IOS)

Agreed. PR here:

1 Like

merged, thank you for the fix

1 Like

Still not working for me.
When I click any button (Taken, Ask Later or Skip) I get immediately a new notification. So it seems it’s in some kind of a loop.

Is your input boolean turned on when you select “taken”?

Input boolean is off and is not turned on

Logs attached.

It needs to be “on” to start I believe. The trigger turns it off, then if “taken” is selected it should turn back on.

At least I think that is the case, this is day 1 of my use on this.

Made a new automation, put it on. Put same … once the automation runs it’s keep getting the notification no matter which option I click.

Uninstall the blueprint and automation restart home assistant install blueprint then make your automation.

This is the working blueprint for Android…

blueprint:
  name: Advanced medication reminder
  description: Get advanced notification and history for medication reminder
  domain: automation
  input:
    reminder_time:
      name: Reminder time
      description: At what time do you want to be reminded
      selector:
        time: {}
    notify_device:
      name: Notification
      description: Device needs to run the official Home Assistant app to receive
        notifications
      selector:
        device:
          integration: mobile_app
          multiple: false
    input_boolean:
      name: Dedicated input_boolean
      description: Create and set here a input_boolean to handle history and state
        of the automation
      selector:
        entity:
          domain: input_boolean
          multiple: false
    notification_title:
      name: Notification title (Optional)
      description: 'Default: Medication reminder'
      default: Medication reminder!
    notification_message:
      name: Notification message (Optional)
      description: 'Default: It''s time to take your medication'
      default: It's time to take your medication
    notification_action_taken:
      name: 'Notification action: Taken (Optional)'
      description: 'Default: Taken'
      default: Taken
    notification_action_later:
      name: 'Notification action: Ask later (Optional)'
      description: 'Default: Ask later'
      default: Ask later
    notification_action_skip:
      name: 'Notification action: Skip (Optional)'
      description: 'Default: Skip'
      default: Skip
    ask_later_wait_time:
      name: Wait time before next reminder
      description: Minutes before notify again after a Ask later action.
      default: 30
      selector:
        number:
          min: 5.0
          max: 1440.0
          unit_of_measurement: minutes
          mode: slider
          step: 1.0
    logbook_message_remind:
      name: Logbook message for remind (Optional)
      description: 'Default: Reminder sent'
      default: Reminder sent
    logbook_message_taken:
      name: Logbook message for action Taken (Optional)
      description: 'Default: Medication taken'
      default: Medication taken
    logbook_message_later:
      name: Logbook message for action Ask later (Optional)
      description: 'Default: Postpone reminder'
      default: Postpone reminder
    logbook_message_skip:
      name: Logbook message for action Skip (Optional)
      description: 'Default: Reminder skipped'
      default: Reminder skipped
    logbook_message_no_answer:
      name: Logbook message for no action after timeout (Optional)
      description: 'Default: No answer time out'
      default: No answer time out
    optional_action:
      name: Optional action
      description: Run an action like notify a speaker at the same time that the mobile
        notification
      selector:
        action: {}
      default: []
  source_url: https://raw.githubusercontent.com/Aohzan/hass-blueprints/main/blueprints/medication_reminder.yaml
trigger:
- platform: time
  at: !input reminder_time
mode: restart
action:
- service: input_boolean.turn_off
  target:
    entity_id: !input input_boolean
- alias: Notify until the medication has been take
  repeat:
    while:
    - condition: state
      entity_id: !input input_boolean
      state: 'off'
    sequence:
    - service: logbook.log
      data:
        name: !input notification_title
        message: !input logbook_message_remind
        entity_id: !input input_boolean
    - choose:
      - conditions: '{{ true }}'
        sequence: !input optional_action
    - device_id: !input notify_device
      domain: mobile_app
      type: notify
      title: !input notification_title
      message: !input notification_message
      data:
        actions:
        - title: !input notification_action_taken
          action: taken
        - title: !input notification_action_later
          action: later
        - title: !input notification_action_skip
          action: skip
        tag: !input input_boolean
    - wait_for_trigger:
        platform: event
        event_type: mobile_app_notification_action
        event_data:
          tag: !input input_boolean
      timeout:
        minutes: !input ask_later_wait_time
    - choose:
      - conditions: '{{ wait.trigger and wait.trigger.event.data.action == ''taken'' }}'
        sequence:
        - service: input_boolean.turn_on
          target:
            entity_id: !input input_boolean
        - service: logbook.log
          data:
            name: !input notification_title
            message: !input logbook_message_taken
            entity_id: !input input_boolean
      - conditions: '{{ wait.trigger and wait.trigger.event.data.action == ''later'' }}'
        sequence:
        - service: logbook.log
          data:
            name: !input notification_title
            message: !input logbook_message_later
            entity_id: !input input_boolean
        - delay:
            minutes: !input ask_later_wait_time
      - conditions: '{{ wait.trigger and wait.trigger.event.data.action == ''skip'' }}'
        sequence:
        - service: input_boolean.turn_on
          target:
            entity_id: !input input_boolean
        - service: logbook.log
          data:
            name: !input notification_title
            message: !input logbook_message_skip
            entity_id: !input input_boolean
      default:
      - device_id: !input notify_device
        domain: mobile_app
        type: notify
        message: clear_notification
        data:
          tag: !input input_boolean
      - service: logbook.log
        data:
          name: !input notification_title
          message: !input logbook_message_no_answer
          entity_id: !input input_boolean



I rollback the missing default part at the end, I pushed the update, sorry

1 Like

Removed the blueprint, restarted Home Assistant. Imported the Blueprint again via this link : hass-blueprints/medication_reminder_android.yaml at 0092094776715d880e0eff3b0d2b54807dbd50aa · Aohzan/hass-blueprints · GitHub

But still not solved. Input Boolean I have put on.
When automation runs it’s put to off. But then again no mater which option I click the notification pops up again immediately.

Log of the input Boolean:

Reminder sent getriggerd door automatisering Notificatie ImmuDefense innemen getriggerd door tijd
11:01:20 - 2 minuten geleden
No answer time out getriggerd door automatisering Notificatie ImmuDefense innemen getriggerd door tijd
11:01:20 - 2 minuten geleden
Reminder sent getriggerd door automatisering Notificatie ImmuDefense innemen getriggerd door tijd
11:01:17 - 2 minuten geleden
No answer time out getriggerd door automatisering Notificatie ImmuDefense innemen getriggerd door tijd
11:01:17 - 2 minuten geleden
Reminder sent getriggerd door automatisering Notificatie ImmuDefense innemen getriggerd door tijd
11:01:12 - 2 minuten geleden
No answer time out getriggerd door automatisering Notificatie ImmuDefense innemen getriggerd door tijd
11:01:12 - 2 minuten geleden
Reminder sent getriggerd door automatisering Notificatie ImmuDefense innemen getriggerd door tijd
11:01:06 - 2 minuten geleden
No answer time out getriggerd door automatisering Notificatie ImmuDefense innemen getriggerd door tijd
11:01:06 - 2 minuten geleden
Reminder sent getriggerd door automatisering Notificatie ImmuDefense innemen getriggerd door tijd
11:01:00 - 2 minuten geleden
Is uitgeschakeld getriggerd door automatisering Notificatie ImmuDefense innemen getriggerd door tijd
11:01:00 - 2 minuten geleden
Is ingeschakeld getriggerd door service input_boolean.turn_on
10:57:21 - 6 minuten geleden - Yves

The Blueprint config

id: '1668765563911'
alias: Notificatie ImmuDefense innemen
description: Notificatie voor Yves voor het innemen van ImmuDefense
use_blueprint:
  path: Aohzan/medication_reminder_android.yaml
  input:
    reminder_time: '11:01:00'
    notify_device: f1e469f41a3ad819a0b437bcb88b7d9d
    input_boolean: input_boolean.yves_immudefense
    notification_title: Medicatie herinnering
    notification_message: Neem 1 pil ImmuDefense
    notification_action_taken: Ingenomen
    notification_action_later: Uitstellen
    notification_action_skip: Overslaan

The automation:

trigger:
  - platform: time
    at: '11:01:00'
mode: restart
action:
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.yves_immudefense
  - alias: Notify until the medication has been take
    repeat:
      while:
        - condition: state
          entity_id: input_boolean.yves_immudefense
          state: 'off'
      sequence:
        - service: logbook.log
          data:
            name: Medicatie herinnering
            message: Reminder sent
            entity_id: input_boolean.yves_immudefense
        - choose:
            - conditions: '{{ true }}'
              sequence: []
        - device_id: f1e469f41a3ad819a0b437bcb88b7d9d
          domain: mobile_app
          type: notify
          title: Medicatie herinnering
          message: Neem 1 pil ImmuDefense
          data:
            actions:
              - title: Ingenomen
                action: taken
              - title: Uitstellen
                action: later
              - title: Overslaan
                action: skip
            tag: input_boolean.yves_immudefense
        - wait_for_trigger:
            platform: event
            event_type: mobile_app_notification_action
            event_data:
              tag: input_boolean.yves_immudefense
          timeout:
            minutes: 30
        - choose:
            - conditions: >-
                {{ wait.trigger and wait.trigger.event.data.actionName ==
                'taken' }}
              sequence:
                - service: input_boolean.turn_on
                  target:
                    entity_id: input_boolean.yves_immudefense
                - service: logbook.log
                  data:
                    name: Medicatie herinnering
                    message: Medication taken
                    entity_id: input_boolean.yves_immudefense
            - conditions: >-
                {{ wait.trigger and wait.trigger.event.data.actionName ==
                'later' }}
              sequence:
                - service: logbook.log
                  data:
                    name: Medicatie herinnering
                    message: Postpone reminder
                    entity_id: input_boolean.yves_immudefense
                - delay:
                    minutes: 30
            - conditions: >-
                {{ wait.trigger and wait.trigger.event.data.actionName == 'skip'
                }}
              sequence:
                - service: input_boolean.turn_on
                  target:
                    entity_id: input_boolean.yves_immudefense
                - service: logbook.log
                  data:
                    name: Medicatie herinnering
                    message: Reminder skipped
                    entity_id: input_boolean.yves_immudefense
          default:
            - device_id: f1e469f41a3ad819a0b437bcb88b7d9d
              domain: mobile_app
              type: notify
              message: clear_notification
              data:
                tag: input_boolean.yves_immudefense
            - service: logbook.log
              data:
                name: Medicatie herinnering
                message: No answer time out
                entity_id: input_boolean.yves_immudefense
id: '1668765563911'
alias: Notificatie ImmuDefense innemen
description: Notificatie voor Yves voor het innemen van ImmuDefense

Trace timeline


Triggered by the time at 18 november 2022 om 11:01:00
Boolean invoer: Turn off Yves ImmuDefense
(input_boolean.yves_immudefense) turned off
Notify until the medication has been take
unknown
Medicatie herinnering (input_boolean.yves_immudefense) Reminder sent
7 seconden later
unknown
Medicatie herinnering (input_boolean.yves_immudefense) No answer time out
Medicatie herinnering (input_boolean.yves_immudefense) Reminder sent
5 seconden later
Medicatie herinnering (input_boolean.yves_immudefense) No answer time out
unknown
Medicatie herinnering (input_boolean.yves_immudefense) Reminder sent
5 seconden later
Medicatie herinnering (input_boolean.yves_immudefense) No answer time out
unknown
Medicatie herinnering (input_boolean.yves_immudefense) Reminder sent
3 seconden later
unknown
Medicatie herinnering (input_boolean.yves_immudefense) No answer time out
Medicatie herinnering (input_boolean.yves_immudefense) Reminder sent
Still running

Copy and paste the blueprint code i posted above into file: blueprints/automation/Aohzan/medication_reminder_android.yaml

restart home assistant. This should work.

The default action at the bottom of the blueprint on github is not in the correct format (i think)

1 Like

It is working now with the code as you have mentioned, thanks!

Your welcome

Hello. How do I add this in the Blueprint mask because its an action that I can select? Do I select conditon?