Advanced medication reminder

same result. New traces:
Flonase

morning meds

do you use android or ios device ?

I found that on android I can add a check to handle different automations by adding

            event_data:
              tag: !input input_boolean

after

        - wait_for_trigger:
            platform: event
            event_type: mobile_app_notification_action

but it will not work on iOS devices after that :frowning:

I didn’t found a way on iOS, sorry

{
“trace”: {
“last_step”: “action/1/repeat/while/0/entity_id/0”,
“run_id”: “7fb46df0d17c03c791452a27031ef4db”,
“state”: “stopped”,
“script_execution”: “finished”,
“timestamp”: {
“start”: “2021-11-09T12:00:00.003463+00:00”,
“finish”: “2021-11-09T12:00:00.029290+00:00”
},
“domain”: “automation”,
“item_id”: “1635160206915”,
“trigger”: “time”,
“trace”: {
“trigger/0”: [
{
“path”: “trigger/0”,
“timestamp”: “2021-11-09T12:00:00.003840+00:00”,
“changed_variables”: {
“this”: {
“entity_id”: “automation.advanced_medication_reminder”,
“state”: “on”,
“attributes”: {
“last_triggered”: “2021-11-08T12:00:00.005137+00:00”,
“mode”: “restart”,
“current”: 0,
“id”: “1635160206915”,
“friendly_name”: “Advanced medication reminder”
},
“last_changed”: “2021-11-05T15:04:16.531271+00:00”,
“last_updated”: “2021-11-08T12:00:00.024240+00:00”,
“context”: {
“id”: “5068688c469c87de9ded4ae12458520f”,
“parent_id”: null,
“user_id”: null
}
},
“trigger”: {
“id”: “0”,
“idx”: “0”,
“platform”: “time”,
“now”: “2021-11-09T13:00:00.001184+01:00”,
“description”: “time”,
“entity_id”: null
}
}
}
],
“action/0”: [
{
“path”: “action/0”,
“timestamp”: “2021-11-09T12:00:00.010584+00:00”,
“changed_variables”: {
“context”: {
“id”: “65d275fb43a1a08185f88c710d7f32d7”,
“parent_id”: null,
“user_id”: null
}
},
“result”: {
“params”: {
“domain”: “input_boolean”,
“service”: “turn_off”,
“service_data”: {},
“target”: {
“entity_id”: [
“input_datetime.medics”
]
}
},
“running_script”: false,
“limit”: 10
}
}
],
“action/1”: [
{
“path”: “action/1”,
“timestamp”: “2021-11-09T12:00:00.022267+00:00”
}
],
“action/1/repeat”: [
{
“path”: “action/1/repeat”,
“timestamp”: “2021-11-09T12:00:00.022775+00:00”,
“changed_variables”: {
“repeat”: {
“first”: true,
“index”: 1
}
},
“result”: {
“result”: false
}
}
],
“action/1/repeat/while/0”: [
{
“path”: “action/1/repeat/while/0”,
“timestamp”: “2021-11-09T12:00:00.022906+00:00”,
“result”: {
“result”: false
}
}
],
“action/1/repeat/while/0/entity_id/0”: [
{
“path”: “action/1/repeat/while/0/entity_id/0”,
“timestamp”: “2021-11-09T12:00:00.023017+00:00”,
“result”: {
“result”: false,
“state”: “00:00:00”,
“wanted_state”: “off”
}
}
]
},
“config”: {
“trigger”: [
{
“platform”: “time”,
“at”: “13:00:00”
}
],
“mode”: “restart”,
“action”: [
{
“service”: “input_boolean.turn_off”,
“target”: {
“entity_id”: “input_datetime.medics”
}
},
{
“alias”: “Notify until the medication has been take”,
“repeat”: {
“while”: [
{
“condition”: “state”,
“entity_id”: “input_datetime.medics”,
“state”: “off”
}
],
“sequence”: [
{
“service”: “logbook.log”,
“data”: {
“name”: “Medication reminder!”,
“message”: “Reminder sent”,
“entity_id”: “input_datetime.medics”
}
},
{
“choose”: [
{
“conditions”: “{{ true }}”,
“sequence”: []
}
]
},
{
“device_id”: “7d1b8fbe6148552608b8beb99a0edba5”,
“domain”: “mobile_app”,
“type”: “notify”,
“title”: “Medication reminder!”,
“message”: “It’s time to take your medication”,
“data”: {
“actions”: [
{
“title”: “Taken”,
“action”: “taken”
},
{
“title”: “Ask later”,
“action”: “later”
},
{
“title”: “Skip”,
“action”: “skip”
}
],
“tag”: “medication-reminder”
}
},
{
“wait_for_trigger”: {
“platform”: “event”,
“event_type”: “mobile_app_notification_action”
},
“timeout”: {
“minutes”: 5
}
},
{
“choose”: [
{
“conditions”: “{{ wait.trigger.event.data.action == ‘taken’ }}”,
“sequence”: [
{
“service”: “input_boolean.turn_on”,
“target”: {
“entity_id”: “input_datetime.medics”
}
},
{
“service”: “logbook.log”,
“data”: {
“name”: “Medication reminder!”,
“message”: “Medication taken”,
“entity_id”: “input_datetime.medics”
}
}
]
},
{
“conditions”: “{{ wait.trigger.event.data.action == ‘later’ }}”,
“sequence”: [
{
“service”: “logbook.log”,
“data”: {
“name”: “Medication reminder!”,
“message”: “Postpone reminder”,
“entity_id”: “input_datetime.medics”
}
},
{
“delay”: {
“minutes”: 5
}
}
]
},
{
“conditions”: “{{ wait.trigger.event.data.action == ‘skip’ }}”,
“sequence”: [
{
“service”: “input_boolean.turn_on”,
“target”: {
“entity_id”: “input_datetime.medics”
}
},
{
“service”: “logbook.log”,
“data”: {
“name”: “Medication reminder!”,
“message”: “Reminder skipped”,
“entity_id”: “input_datetime.medics”
}
}
]
}
],
“default”: [
{
“device_id”: “7d1b8fbe6148552608b8beb99a0edba5”,
“domain”: “mobile_app”,
“type”: “notify”,
“message”: “clear_notification”,
“data”: {
“tag”: “medication-reminder”
}
},
{
“service”: “logbook.log”,
“data”: {
“name”: “Medication reminder!”,
“message”: “No answer time out”,
“entity_id”: “input_datetime.medics”
}
}
]
}
]
}
}
],
“id”: “1635160206915”,
“alias”: “Advanced medication reminder”,
“description”: “”
},
“blueprint_inputs”: {
“id”: “1635160206915”,
“alias”: “Advanced medication reminder”,
“description”: “”,
“use_blueprint”: {
“path”: “Aohzan/medication_reminder.yaml”,
“input”: {
“logbook_message_no_answer”: “No answer time out”,
“notify_device”: “7d1b8fbe6148552608b8beb99a0edba5”,
“reminder_time”: “13:00:00”,
“optional_action”: [],
“logbook_message_skip”: “Reminder skipped”,
“logbook_message_later”: “Postpone reminder”,
“logbook_message_taken”: “Medication taken”,
“logbook_message_remind”: “Reminder sent”,
“notification_action_skip”: “Skip”,
“notification_action_later”: “Ask later”,
“notification_action_taken”: “Taken”,
“notification_message”: “It’s time to take your medication”,
“ask_later_wait_time”: 5,
“notification_title”: “Medication reminder!”,
“input_boolean”: “input_datetime.medics”
}
}
},
“context”: {
“id”: “65d275fb43a1a08185f88c710d7f32d7”,
“parent_id”: null,
“user_id”: null
}
},
“logbookEntries”: [
{
“name”: “Advanced medication reminder”,
“message”: “has been triggered by time”,
“source”: “time”,
“entity_id”: “automation.advanced_medication_reminder”,
“context_id”: “65d275fb43a1a08185f88c710d7f32d7”,
“when”: “2021-11-09T12:00:00.004717+00:00”,
“domain”: “automation”
}
]
}

the notification is sent :

“device_id”: “7d1b8fbe6148552608b8beb99a0edba5”,
“domain”: “mobile_app”,
“type”: “notify”,
“title”: “Medication reminder!”,
“message”: “It’s time to take your medication”,
“data”: {
...

you should try a notification from dev tools, but the problem don’t come from this blueprint

What about with actions? Here is a pair of automations i made involving a notification and taking an action based on the response. Could this be a way to differentiate the entitiy?


automation:
- id: timetocheckglucose
  alias: Time to check glucose
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.glucosetimer
  action:
  - service: notify.mobile_app_josh_phone
    data:
      message: Check glucose
      data:
        actions:
        - action: glucose_checked
          title: Checked
  - service: notify.alexa_media_living_room_echo
    data:
      message: Josh, it's time to check your glucose
      data:
        type: tts
  mode: single
- id: '1627873698743'
  alias: Glucose checked
  description: ''
  trigger:
  - platform: event
    event_type: ios.notification_action_fired
    event_data:
      actionName: glucose_checked
  condition: []
  action:
  - service: script.glucose_tested
  mode: single

It seems to be sending duplicate notifications for me because the automation doesn’t pick up the action when clicking on an actionable notification. I love this because in order to get rid of the notification, I have to actually dismiss it. I’m using an iPhone. Please could you help me in terms of getting the automation to pick up the actionable notification item?

I just got this setup and working for my wife on her iphone, and she also gets the notification on her apple watch, but unfortunately there, she only gets a button to dismiss the notification, no actionable buttons. I assume this just how it works with the watch and phone, but if anyoen knows how to get a taken action button to show up in the watch notification, that would be perfect.

Right now she has to respond to the notification on the phone, and if she dismisses it from the watch, she can no longer find the phone notification until the next one gets sent.

Does anyone know if its possible to get a actionable button to show up in the phone notification?

Hi @nickshanks,

I have the same problem and i need to change some lines in blueprint yaml.

I add some actions in wait_for_trigger and change quotes ’ ’ to " in choose conditions.

You can check my yaml file in blueprint: name: Advanced medication reminder description: Get advanced no - Pastebin.com

Replace your medication_reminder.yaml, restart HA and test again.

Br

When I add this an automation - it doesn’t show up in the GUI, but writes to the automation.yaml file. The error comes back with:

Blueprint Advanced medication reminder generated invalid automation with inputs OrderedDict([(‘reminder_time’, 43500), (‘notify_device’, ‘65f01c631a9dd6df8fe29a1521c3cc3a7’), (‘input_boolean’, ‘medminderphone’)]): not a valid value for dictionary value @ data[‘action’][0][‘target’][‘entity_id’]. Got None

I am not clear as to what it is expecting so it doesn’t throw the error and shows up in the automation screen.

1 Like

Hi there, not sure this has been answered / asked before, but would it be possible to have different reminder times on different days of the week? For example, I want to be reminded around the time I wake up. This - on weekdays - is at around 7:30. But on weekends, I want to be reminded later - e.g. at around 9:00 or 10:00.
Could this be implemented? Thanks!

1 Like

Hello,
Everything goes well, the notification works, however I have this message:

Logger: homeassistant.helpers.template
Source: helpers/template.py:1834
First occurred: 23 mars 2022, 20:00:00 (66 occurrences)
Last logged: 06:30:01

Template variable error: 'None' has no attribute 'event' when rendering '{{ wait.trigger.event.data.action == 'taken' }}'
Template variable error: 'None' has no attribute 'event' when rendering '{{ wait.trigger.event.data.action == 'later' }}'
Template variable error: 'None' has no attribute 'event' when rendering '{{ wait.trigger.event.data.action == 'skip' }}'

Can anyone tell me what I missed?
Thank you

1 Like

This is what I am seeing too. I’m using iOS 15. I get the reminder, with the options, but selecting any one of the options logs the same thing as above. The reminder repeats every five minutes as it’s supposed to.

I was wondering if anyone else sees these error logs and where I might look to see if there is something setup incorrectly. Everything seems to work ok, but it just adds additional noise in the logs that I am trying to reduce. I think it happens when I miss a check and it alerts again.

Logger: homeassistant.helpers.template
Source: helpers/template.py:1840
First occurred: April 24, 2022, 08:30:00 (18 occurrences)
Last logged: 08:30:03

Template variable error: 'None' has no attribute 'event' when rendering '{{ wait.trigger.event.data.action == 'taken' }}'
Template variable error: 'None' has no attribute 'event' when rendering '{{ wait.trigger.event.data.action == 'later' }}'
Template variable error: 'None' has no attribute 'event' when rendering '{{ wait.trigger.event.data.action == 'skip' }}'

No Idea how I didn’t see the post from @Elekrea. My bad for dual posting.

1 Like

@Mati24 this looks like I want but I going to use it forreminding me to feed my Rat. will this work I hop so I trying to get it to work. I keep geet an unknow error for the Blueprint path. I have

Aohzan/medication_reminder

is this right ? my log give this to me

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/connection.py:146
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 9:22:26 PM (2 occurrences)
Last logged: 9:24:28 PM

[22499752294528] Error handling message: Unsupported url (unknown_error)
[22499752294528] Error handling message: No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax. (unknown_error)

Thank you @Mati24 for your work.

I finaly got it working for IOS device. But it required to change the blueprint as bellow:

 - wait_for_trigger:
            platform: event
            event_type: ios.notification_action_fired
            event_data:
              {}
              #tag: !input "input_boolean"
          timeout:
            minutes: !input "ask_later_wait_time"
        - choose:
            - conditions: "{{ wait.trigger.event.data.actionName == '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.event.data.actionName == '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.event.data.actionName == '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"

it will break the android support I guess :thinking: it should be a way to handle both device type

Just wanted to say thanks for a great blue print that i use every day

2 Likes

Great and simple to use tool for every human wanting to keep track of medicine.
Great tool.
thx Mati

3 Likes