From 67c813bdbd3953edd84b43cc19cef8a33ceb16d5 Mon Sep 17 00:00:00 2001 From: thomas Date: Fri, 29 Aug 2025 11:58:12 +0000 Subject: [PATCH] =?UTF-8?q?blueprints/automation/medication-reminder.yaml?= =?UTF-8?q?=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/medication-reminder.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 blueprints/automation/medication-reminder.yaml diff --git a/blueprints/automation/medication-reminder.yaml b/blueprints/automation/medication-reminder.yaml new file mode 100644 index 0000000..788660b --- /dev/null +++ b/blueprints/automation/medication-reminder.yaml @@ -0,0 +1,72 @@ +blueprint: + name: Dynamic Medication Reminder via NFC + description: Tracks medication intake via NFC scan, auto-detects user or uses manual selection, and sends reminders after a flexible interval. + domain: automation + input: + medication_name: + name: Medication Name + selector: + text: + nfc_tag_id: + name: NFC Tag ID + selector: + text: + reminder_delay: + name: Reminder Interval + selector: + number: + min: 1 + max: 168 + reminder_unit: + name: Time Unit + selector: + select: + options: + - Hours + - Days + person_selector: + name: input_select for manual person selection + selector: + entity: + domain: input_select + user_id_map: + name: User ID to Person Name Map + selector: + object: + +trigger: + - platform: event + event_type: tag_scanned + event_data: + tag_id: !input nfc_tag_id + +variables: + scanned_user_id: "{{ trigger.context.user_id }}" + selected_person: "{{ states(!input.person_selector) | lower }}" + person: > + {% set map = !input.user_id_map %} + {% if scanned_user_id in map %} + {{ map[scanned_user_id] | lower }} + {% else %} + {{ selected_person }} + {% endif %} + delay_seconds: > + {% if !input.reminder_unit == 'Days' %} + {{ ( !input.reminder_delay | int ) * 86400 }} + {% else %} + {{ ( !input.reminder_delay | int ) * 3600 }} + {% endif %} + datetime_entity: "input_datetime.medication_{{ person }}" + notify_service: "notify.mobile_app_{{ person }}" + +action: + - service: input_datetime.set_datetime + target: + entity_id: "{{ datetime_entity }}" + data: + timestamp: "{{ now().timestamp() }}" + - delay: + seconds: "{{ delay_seconds }}" + - service: "{{ notify_service }}" + data: + message: "{{ !input.medication_name }} is due again for {{ person | title }}."