Advanced medication reminder

type: custom:stack-in-card
cards:
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.morning_medication_elapsed_time
        primary: Morning Medication
        secondary: |
          {{ states('sensor.morning_medication_elapsed_time') }} ago
        icon: mdi:pill-multiple
        icon_color: '#f7c242'
        tap_action:
          action: more-info
        layout: vertical
        fill_container: false
        multiline_secondary: false
      - type: custom:mushroom-template-card
        entity: sensor.evening_medication_elapsed_time
        primary: Evening Medication
        secondary: |
          {{ states('sensor.evening_medication_elapsed_time') }} ago
        icon: mdi:pill-multiple
        icon_color: '#79b74a'
        tap_action:
          action: more-info
        layout: vertical
        fill_container: false
        multiline_secondary: false
    style: |
      ha-card {
        background: none;
        box-shadow: none;
      }
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-chips-card
        chips:
          - type: template
            tap_action:
              action: none;
            hold_action:
              action: call-service
              service: automation.trigger
              data:
                skip_condition: true
              target:
                entity_id: automation.automation_62
            icon: mdi:refresh
            icon_color: red
            content: Log Medication
        alignment: center
        card_mod:
          style: |
            ha-card {

              /* Style Chip like Mushroom button */
              --chip-background: rgba(255, 215, 0, 0.2);
              --chip-border-radius: var(--mush-control-border-radius, 12px);
              --chip-height: var(--mush-control-height, 42px);
              --chip-box-shadow: none;
              user-select: none;
            }
            ha-card:active {

              /* Add effect to give feedback on button press */
              --chip-background: rgba(var(--rgb-red), 0.4);
            }
      - type: custom:mushroom-chips-card
        chips:
          - type: template
            tap_action:
              action: none;
            hold_action:
              action: call-service
              service: automation.trigger
              data:
                skip_condition: true
              target:
                entity_id: automation.log_evening_medications_updated
            icon: mdi:refresh
            icon_color: red
            content: Log Medication
        alignment: center
        card_mod:
          style: |
            ha-card {

              /* Style Chip like Mushroom button */
              --chip-background: rgba(0, 128, 0, 0.2);
              --chip-border-radius: var(--mush-control-border-radius, 12px);
              --chip-height: var(--mush-control-height, 42px);
              --chip-box-shadow: none;
              user-select: none;
            }
            ha-card:active {

              /* Add effect to give feedback on button press */
              --chip-background: rgba(var(--rgb-red), 0.4);
            }
  - type: custom:canary-card
    theme: midnight
    style: |
      ha-card {
        font-variant: small-caps;
      }
      .card-header {
        font-size: 16px;
      }
    card:
      type: entities
      entities:
        - type: custom:fold-entity-row
          head:
            type: section
            label: Stock Management
          entities:
            - type: divider
            - entity: counter.med_1_refill
              icon: mdi:alpha-t-circle
              show_state: false
              type: custom:multiple-entity-row
              name: Med 1
              entities:
                - entity: counter.med_1_refill
                  name: Pills Left
                  format: precision0
                  styles:
                    font-weight: bold
            - type: divider
            - entity: counter.med_2_refill
              icon: mdi:alpha-v-circle
              show_state: false
              type: custom:multiple-entity-row
              name: Med 2
              entities:
                - entity: counter.med_2_refill
                  name: Pills Left
                  format: precision0
                  styles:
                    font-weight: bold
            - type: divider
            - entity: counter.med_3_refill
              icon: mdi:alpha-b-circle
              show_state: false
              type: custom:multiple-entity-row
              name: Med 3
              entities:
                - entity: counter.med_3_refill
                  name: Pills Left
                  format: precision0
                  styles:
                    font-weight: bold
            - type: divider
            - entity: counter.med_4_refill
              icon: mdi:alpha-s-circle
              show_state: false
              type: custom:multiple-entity-row
              name: Med 4
              entities:
                - entity: counter.med_4_refill
                  name: Pills Left
                  format: precision0
                  styles:
                    font-weight: bold
            - type: divider
      style: |
        ha-card {
          background: none;
          box-shadow: none;
        }

excellent. Thanks. Got my counters set up and working - now to prettify it. First go at mushroom-cards. look nice.

1 Like

How would I adapt this if itā€™s a month medication for a pet???

I combined those 2 into one (removed ios vs android dependency)

Add new variable and new if the feedback loop:

  phone: "{{ device_attr(device, 'manufacturer')}}"
    - if:
        - condition: template
          value_template: "{{ phone == 'Apple'}}"
      then:
        - wait_for_trigger:
            platform: event
            event_type: ios.notification_action_fired
            event_data: {}
          timeout:
            minutes: !input ask_later_wait_time
      else:      
        - wait_for_trigger:
            platform: event
            event_type: mobile_app_notification_action
            event_data:
              tag: !input input_boolean
          timeout:
            minutes: !input ask_later_wait_time
1 Like

Trying to get the blueprint working for multiple days. Happy to code in if too difficult to get a selector. When I use the following suggestion:

trigger:
...

condition:
   - condition: time
      weekday:
        - mon
        - tue
        - wed

mode: restart

And try and import the Blueprint, I get the following error:
mapping values are not allowed here in "<unicode string>", line 103, column 15: weekday: ^

Is someone able to assist with how to correct this?

In the code you provided, the indentation is wrong. :slight_smile:

Everything under condition: needs to be correctly indented => two spaces. Like this:

trigger:
...
condition:
  - condition: time
    weekday:
      - mon
      - tue
      - wed

mode: restart

Thanks for that. I thought I had checked the indentation but obviously not closely enoughā€¦

Been trying all day to figure out how to get your amendments working with an NFC tag rather than a switch. I setup a toggle that will turn on when the tag is scanned, but I canā€™t get the event and notification/changing to taken working. I either get an error, or only the reply to the notification on the phone works. I have the following code updates:
Resets the toggles to off when the automation runs:

action:
- service: input_boolean.turn_off
  target:
    entity_id: input_boolean.meds_taken
- service: input_boolean.turn_off
  target:
    entity_id: input_boolean.mednfc

Waiting for either than notification on the app to be acknowledged or toggle change to on meaning the NFC tag has been scanned:

    - wait_for_trigger:
        - platform: event
          event_type: mobile_app_notification_action
          event_data:
            tag: !input input_boolean
        - platform: event
          event_type: state_change
          event_data:
            entity_id: input_boolean.mednfc
          new_state: "on"

Taken path to clear notification on NFC scan. I believe this is where my error is coming from:

      - conditions: '{{ wait.trigger and wait.trigger.event.data.command wait.trigger.event.data.command == ''on'' }}'
        sequence:
        - service: input_boolean.turn_on
          target:
            entity_id: !input input_boolean
        - device_id: !input notify_device
          domain: mobile_app
          type: notify
          title: !input notification_title
          message: "clear_notification"
          data:
            tag: !input input_boolean
        - service: logbook.log
          data:
            name: !input notification_title
            message: !input logbook_message_taken
            entity_id: !input input_boolean

Error Iā€™m currently getting:

Message malformed: Expected a dictionary @ data['action'][2]['repeat']['sequence'][4]['choose'][1]['conditions'][0]

A little late, I hope you got it fixed already, but if notā€¦ :slight_smile:

Youā€™re having the condition wrong, I suspect you duplicated something accidentally.

Correct would be:
- conditions: '{{ wait.trigger and wait.trigger.event.data.command == ''on'' }}'

Iā€™m not exactly sure what youā€™re trying to do, but if it would be me, I wouldnā€™t work with the blueprint for your automation. Just setup an automation using the blueprint as a template. Makes it easier to work with in the aftermath.

If you need help there, let me know! :slight_smile:

Thanks for the response. I ended up just simplifying the automation and bypassing the notification options altogether and it just sending the message. When I get a chance, I might have another go at it.
Cheers.

1 Like

Just discovered this blueprint - looks like it would be exactly what I need. Iā€™m on iOS, and the actionable notifications arenā€™t working. If I call the notify service directly, with an actions key, it errors unless I nest another data: block.

data:
  message: Test message
  title: Test title
  data:
    actions:
      - action: Test
        title: This is option 1

The blueprint only has a single data block and no actions display. If I try and modify the blueprint to add another data block, HA complains about a missing message key. Iā€™m confusedā€¦ and pretty new to this :slight_smile:

Could someone check if the actions are shown in this blueprint on iOS?

Is there a way to add a notification sound to the device? The ā€œOptional Actionā€ does not work, as it kills the entire automation.

Thank you in advance

I agree with adding the possibility to name a channel.
We can indeed customize the blueprint but when we update we have to edit the blueprint.
Not everyone is able or has the knowledge to edit a script/blueprint

greetings

@Mati24

look in the blueprint for this code

  - 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
        channel: medication
    - wait_for_trigger:

I have put in new line with ā€œchannel: medicationā€ in
Run it once manually
Then, in the app go to channels and look after the channel you past thru the notification en edit to the sound you like

I hope this help.
If I get to ask for a channel in the setup I will pass it on

Ronald