From 43fac944f50c2b079d1a4d1cf2fc538fdce99682 Mon Sep 17 00:00:00 2001 From: thomas Date: Fri, 29 Aug 2025 14:07:47 +0000 Subject: [PATCH] blueprints/automation/medication-reminder.yaml aktualisiert --- .../automation/medication-reminder.yaml | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/blueprints/automation/medication-reminder.yaml b/blueprints/automation/medication-reminder.yaml index 1d970ed..5be71a6 100644 --- a/blueprints/automation/medication-reminder.yaml +++ b/blueprints/automation/medication-reminder.yaml @@ -15,7 +15,7 @@ blueprint: nfc_tag_id: name: NFC Tag ID selector: - text: + text reminder_delay: name: Reminder Interval selector: @@ -42,30 +42,26 @@ trigger: condition: - condition: template value_template: > - {{ trigger.event.data.tag_id == inputs.nfc_tag_id }} - + {{ trigger.event.data.tag_id == !input nfc_tag_id }} variables: scanned_user_id: "{{ trigger.context.user_id }}" - manual_person: "{{ states(inputs.person_selector) | lower }}" - # Determine the "person" whose medication schedule should be reset + manual_person: "{{ states(!input person_selector) | lower }}" person: > {% if manual_person != "no selection" %} {{ manual_person }} {% else %} {{ state_attr('user.' ~ scanned_user_id, 'friendly_name') | lower }} {% endif %} - # Calculate the delay in seconds delay_seconds: > - {% if inputs.reminder_unit == 'Days' %} - {{ (inputs.reminder_delay | int) * 86400 }} + {% if !input reminder_unit == 'Days' %} + {{ (!input reminder_delay | int) * 86400 }} {% else %} - {{ (inputs.reminder_delay | int) * 3600 }} + {{ (!input reminder_delay | int) * 3600 }} {% endif %} datetime_entity: "input_datetime.medication_{{ person }}" - # Determine notification target: always the scanner's device notify_service: > - {% set scanner_device = "notify.mobile_app_" ~ state_attr('user.' ~ scanned_user_id, 'device_name') | lower %} + {% set scanner_device = "notify.mobile_app_" ~ (state_attr('user.' ~ scanned_user_id, 'device_name') | lower | default('unknown')) %} {{ scanner_device }} action: @@ -80,7 +76,7 @@ action: - service: "{{ notify_service }}" data: - message: "{{ inputs.medication_name }} is due again for {{ person | title }}." + message: "{{ !input medication_name }} is due again for {{ person | title }}." - service: input_select.select_option target: