2025-08-29 11:58:12 +00:00
blueprint :
2025-08-30 12:10:34 +00:00
name : Medication Reminder via NFC (Companion App Primary)
2025-08-29 12:13:37 +00:00
description : >
2025-08-30 12:10:34 +00:00
Tracks medication intake. Defaults to the Companion App user who scans the tag.
A manual person selection can override this if selected.
Creates calendar entries and calculates the next dose time.
2025-08-29 11:58:12 +00:00
domain : automation
2025-08-29 14:08:55 +00:00
2025-08-29 11:58:12 +00:00
input :
medication_name :
name : Medication Name
2025-08-30 12:10:34 +00:00
description : The name of the medication.
2025-08-29 11:58:12 +00:00
selector :
2025-08-29 14:08:55 +00:00
text
2025-08-30 12:10:34 +00:00
medication_tag_id :
name : Medication NFC Tag ID
description : The unique ID of the NFC tag for this medication.
2025-08-29 11:58:12 +00:00
selector :
2025-08-29 14:07:47 +00:00
text
2025-08-30 12:10:34 +00:00
person_selector :
name : Manual Person Selection Helper
description : The input_select helper for manual override.
selector :
entity :
domain : input_select
calendar_entity_id :
name : Medication Calendar
description : The calendar entity to log medication intake.
selector :
entity :
domain : calendar
2025-08-29 11:58:12 +00:00
reminder_delay :
name : Reminder Interval
2025-08-30 12:10:34 +00:00
description : The number of hours or days for the next reminder.
2025-08-29 11:58:12 +00:00
selector :
number :
min : 1
max : 168
reminder_unit :
name : Time Unit
2025-08-30 12:10:34 +00:00
description : The unit of time for the reminder (Hours or Days).
2025-08-29 11:58:12 +00:00
selector :
select :
options :
- Hours
- Days
trigger :
- platform : event
event_type : tag_scanned
2025-08-30 12:10:34 +00:00
event_data :
tag_id : !input medication_tag_id
2025-08-29 11:58:12 +00:00
variables :
scanned_user_id : "{{ trigger.context.user_id }}"
2025-08-30 12:10:34 +00:00
scanned_person : "{{ state_attr('user.' ~ scanned_user_id, 'friendly_name') | default('Unknown User') }}"
manual_person : "{{ states(!input person_selector) }}"
person_name : >
{% if manual_person != 'No selection' %}
2025-08-29 12:13:37 +00:00
{{ manual_person }}
2025-08-29 11:58:12 +00:00
{% else %}
2025-08-30 12:10:34 +00:00
{{ scanned_person }}
2025-08-29 11:58:12 +00:00
{% endif %}
2025-08-30 12:10:34 +00:00
2025-08-29 11:58:12 +00:00
delay_seconds : >
2025-08-29 14:07:47 +00:00
{% if !input reminder_unit == 'Days' %}
{{ (!input reminder_delay | int) * 86400 }}
2025-08-29 11:58:12 +00:00
{% else %}
2025-08-29 14:07:47 +00:00
{{ (!input reminder_delay | int) * 3600 }}
2025-08-29 11:58:12 +00:00
{% endif %}
2025-08-30 12:10:34 +00:00
2025-08-29 11:58:12 +00:00
action :
2025-08-30 12:10:34 +00:00
- choose :
- conditions :
- condition : template
value_template : "{{ person_name != 'Unknown User' and person_name != 'No selection' }}"
sequence :
- service : calendar.create_event
data :
calendar_entity_id : !input calendar_entity_id
summary : "{{ !input medication_name }} taken by {{ person_name }}"
description : "Next dose due for {{ person_name }} at {{ (now() + timedelta(seconds=delay_seconds)).strftime('%Y-%m-%d %H:%M:%S') }}"
start_date_time : "{{ now() }}"
end_date_time : "{{ now() }}"
- service : input_select.select_option
target :
entity_id : !input person_selector
data :
option : "No selection"
default :
- service : notify.mobile_app_{{ scanned_person | lower | replace(' ', '_') }}
data :
message : "Could not determine who took the medication. Please ensure your Home Assistant app has permission to identify you or manually select a person first."