blueprints/automation/medication-reminder.yaml aktualisiert
This commit is contained in:
@@ -15,7 +15,7 @@ blueprint:
|
|||||||
nfc_tag_id:
|
nfc_tag_id:
|
||||||
name: NFC Tag ID
|
name: NFC Tag ID
|
||||||
selector:
|
selector:
|
||||||
text:
|
text
|
||||||
reminder_delay:
|
reminder_delay:
|
||||||
name: Reminder Interval
|
name: Reminder Interval
|
||||||
selector:
|
selector:
|
||||||
@@ -42,30 +42,26 @@ trigger:
|
|||||||
condition:
|
condition:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: >
|
value_template: >
|
||||||
{{ trigger.event.data.tag_id == inputs.nfc_tag_id }}
|
{{ trigger.event.data.tag_id == !input nfc_tag_id }}
|
||||||
|
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
scanned_user_id: "{{ trigger.context.user_id }}"
|
scanned_user_id: "{{ trigger.context.user_id }}"
|
||||||
manual_person: "{{ states(inputs.person_selector) | lower }}"
|
manual_person: "{{ states(!input person_selector) | lower }}"
|
||||||
# Determine the "person" whose medication schedule should be reset
|
|
||||||
person: >
|
person: >
|
||||||
{% if manual_person != "no selection" %}
|
{% if manual_person != "no selection" %}
|
||||||
{{ manual_person }}
|
{{ manual_person }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ state_attr('user.' ~ scanned_user_id, 'friendly_name') | lower }}
|
{{ state_attr('user.' ~ scanned_user_id, 'friendly_name') | lower }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
# Calculate the delay in seconds
|
|
||||||
delay_seconds: >
|
delay_seconds: >
|
||||||
{% if inputs.reminder_unit == 'Days' %}
|
{% if !input reminder_unit == 'Days' %}
|
||||||
{{ (inputs.reminder_delay | int) * 86400 }}
|
{{ (!input reminder_delay | int) * 86400 }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ (inputs.reminder_delay | int) * 3600 }}
|
{{ (!input reminder_delay | int) * 3600 }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
datetime_entity: "input_datetime.medication_{{ person }}"
|
datetime_entity: "input_datetime.medication_{{ person }}"
|
||||||
# Determine notification target: always the scanner's device
|
|
||||||
notify_service: >
|
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 }}
|
{{ scanner_device }}
|
||||||
|
|
||||||
action:
|
action:
|
||||||
@@ -80,7 +76,7 @@ action:
|
|||||||
|
|
||||||
- service: "{{ notify_service }}"
|
- service: "{{ notify_service }}"
|
||||||
data:
|
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
|
- service: input_select.select_option
|
||||||
target:
|
target:
|
||||||
|
|||||||
Reference in New Issue
Block a user