blueprints/automation/medication-reminder.yaml hinzugefügt
This commit is contained in:
72
blueprints/automation/medication-reminder.yaml
Normal file
72
blueprints/automation/medication-reminder.yaml
Normal file
@@ -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 }}."
|
||||
Reference in New Issue
Block a user