Custom med tracker functional for interval meds
This commit is contained in:
@ -2227,10 +2227,6 @@
|
||||
at: input_datetime.tony_night_meds_notify
|
||||
id: night-notify
|
||||
alias: Night Notify
|
||||
- platform: time
|
||||
at: input_datetime.tony_custom_meds_notify_1
|
||||
alias: Custom Notify 1
|
||||
id: custom-1
|
||||
- platform: state
|
||||
entity_id:
|
||||
- input_boolean.tony_morning_meds_taken
|
||||
@ -2245,13 +2241,6 @@
|
||||
alias: Night Taken
|
||||
from: 'off'
|
||||
to: 'on'
|
||||
- platform: state
|
||||
entity_id:
|
||||
- input_boolean.tony_custom_meds_taken_1
|
||||
from: 'off'
|
||||
to: 'on'
|
||||
id: boolean-custom-1
|
||||
alias: Custom 1 Taken
|
||||
- platform: state
|
||||
entity_id:
|
||||
- input_boolean.master_bedroom_sleeping
|
||||
@ -2321,21 +2310,6 @@
|
||||
|
||||
'
|
||||
alias: Set time night meds were taken
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id:
|
||||
- boolean-custom-1
|
||||
alias: Custom 1 Taken
|
||||
sequence:
|
||||
- service: input_datetime.set_datetime
|
||||
data:
|
||||
datetime: '{% from ''time.jinja'' import current_time %} {{ current_time(24,''withdate'')
|
||||
}}
|
||||
|
||||
'
|
||||
target:
|
||||
entity_id: input_datetime.tony_custom_meds_taken_1
|
||||
alias: Set time custom meds 1 were taken
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id: sleep-off
|
||||
@ -2352,7 +2326,7 @@
|
||||
alias: Set time to start notifying for morning meds
|
||||
alias: Routing
|
||||
mode: parallel
|
||||
max: 4
|
||||
max: 10
|
||||
- id: '1696288939707'
|
||||
alias: Tony Stream Today
|
||||
description: ''
|
||||
@ -2706,3 +2680,51 @@
|
||||
entity_id: input_select.kallen_morning_briefing_location
|
||||
alias: Move morning briefing to common areas
|
||||
mode: single
|
||||
- id: '1696539209438'
|
||||
alias: Tony Custom Meds Handler
|
||||
description: ''
|
||||
trigger:
|
||||
- platform: time
|
||||
at: input_datetime.tony_custom_meds_notify_p1
|
||||
alias: Notify 1
|
||||
id: p1-notify
|
||||
- platform: state
|
||||
entity_id:
|
||||
- input_boolean.tony_custom_meds_taken_p1
|
||||
from: 'off'
|
||||
to: 'on'
|
||||
id: p1-taken
|
||||
alias: Taken 1
|
||||
condition: []
|
||||
action:
|
||||
- variables:
|
||||
trigger: '{{ trigger.id }}'
|
||||
num: '{{ trigger[:2] }}'
|
||||
reason: '{{ trigger.split(''-'')[1] }}'
|
||||
- if:
|
||||
- condition: template
|
||||
value_template: '{% set active = ''input_boolean.tony_custom_meds_tracker_''
|
||||
+ num %}
|
||||
|
||||
{{ is_state(active,''on'') }}'
|
||||
alias: Check tracker
|
||||
then:
|
||||
- if:
|
||||
- condition: template
|
||||
value_template: '{{ reason == ''notify'' }}'
|
||||
alias: Is this a notification
|
||||
then:
|
||||
- service: input_boolean.turn_off
|
||||
data: {}
|
||||
target:
|
||||
entity_id: '{{ ''input_boolean.tony_custom_meds_taken_'' + num }}'
|
||||
alias: Turn off "taken" boolean
|
||||
alias: Turn off "taken" boolean if this is a notification
|
||||
- service: script.tony_custom_meds
|
||||
data:
|
||||
num: '{{ num }}'
|
||||
reason: '{{ reason }}'
|
||||
alias: Run custom meds script
|
||||
alias: Run custom meds script if tracker is active
|
||||
mode: parallel
|
||||
max: 10
|
||||
|
@ -10,11 +10,11 @@ input_boolean:
|
||||
tony_night_meds_taken:
|
||||
name: Tony Night Meds Taken
|
||||
icon: mdi:medication
|
||||
tony_custom_meds_tracker_1:
|
||||
name: Tony Custom Meds Tracker 1
|
||||
tony_custom_meds_tracker_p1:
|
||||
name: Tony Custom Meds Tracker P1
|
||||
icon: mdi:medication
|
||||
tony_custom_meds_taken_1:
|
||||
name: Tony Custom Meds Taken 1
|
||||
tony_custom_meds_taken_p1:
|
||||
name: Tony Custom Meds Taken P1
|
||||
icon: mdi:medication
|
||||
|
||||
input_datetime:
|
||||
@ -43,33 +43,33 @@ input_datetime:
|
||||
has_date: false
|
||||
has_time: true
|
||||
icon: mdi:medication
|
||||
tony_custom_meds_taken_1:
|
||||
name: Tony Custom Meds Taken 1
|
||||
tony_custom_meds_taken_p1:
|
||||
name: Tony Custom Meds Taken P1
|
||||
has_date: true
|
||||
has_time: true
|
||||
icon: mdi:medication
|
||||
tony_custom_meds_notify_1:
|
||||
name: Tony Custom Meds Notify 1
|
||||
tony_custom_meds_notify_p1:
|
||||
name: Tony Custom Meds Notify P1
|
||||
has_date: false
|
||||
has_time: true
|
||||
icon: mdi:medication
|
||||
|
||||
input_number:
|
||||
tony_custom_meds_interval_1:
|
||||
name: Tony Custom Meds Interval 1
|
||||
tony_custom_meds_interval_p1:
|
||||
name: Tony Custom Meds Interval P1
|
||||
min: 0
|
||||
max: 24
|
||||
step: 1
|
||||
icon: mdi:medication
|
||||
|
||||
input_text:
|
||||
tony_custom_med_name_1:
|
||||
name: Tony Custom Med Name 1
|
||||
tony_custom_med_name_p1:
|
||||
name: Tony Custom Med Name P1
|
||||
icon: mdi:medication
|
||||
|
||||
input_select:
|
||||
tony_custom_meds_type_1:
|
||||
name: Tony Custom Meds Type 1
|
||||
tony_custom_meds_type_p1:
|
||||
name: Tony Custom Meds Type P1
|
||||
options:
|
||||
- Wakeup
|
||||
- Bedtime
|
||||
|
111
scripts.yaml
111
scripts.yaml
@ -2015,3 +2015,114 @@ timer_modify:
|
||||
entity_id: '{{ timer }}'
|
||||
data:
|
||||
duration: '{{ modify }}'
|
||||
tony_custom_meds:
|
||||
alias: Tony Custom Meds
|
||||
sequence:
|
||||
- variables:
|
||||
reason: '{{ reason }}'
|
||||
num: '{{ num }}'
|
||||
active: '{{ ''input_boolean.tony_custom_meds_tracker_'' + num }}'
|
||||
taken: '{{ ''input_boolean.tony_custom_meds_taken_'' + num }}'
|
||||
taken_at: '{{ ''input_datetime.tony_custom_meds_taken_'' + num }}'
|
||||
notify_at: '{{ ''input_datetime.tony_custom_meds_notify_'' + num }}'
|
||||
type: '{{ states(''input_select.tony_custom_meds_type_'' + num) }}'
|
||||
name: '{{ states(''input_text.tony_custom_med_name_'' + num) }}'
|
||||
interval: '{{ states(''input_number.tony_custom_meds_interval_'' + num) }}'
|
||||
tag: '{{ ''tony-custom-meds-'' + num }}'
|
||||
alias: Set Variables
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ reason == ''notify'' }}'
|
||||
alias: Notify
|
||||
sequence:
|
||||
- service: script.text_notify
|
||||
data:
|
||||
who: tony
|
||||
type: alert
|
||||
title: '{{ name + '' Tracker'' }}'
|
||||
message: You need to take your {{ name }}
|
||||
tag: '{{ tag }}'
|
||||
alias: Send text notification
|
||||
- wait_for_trigger:
|
||||
- platform: state
|
||||
entity_id:
|
||||
- person.tony_stork
|
||||
id: left
|
||||
alias: Left
|
||||
from: home
|
||||
- platform: template
|
||||
value_template: '{{ is_state(taken,''on'') }}'
|
||||
alias: Manual
|
||||
id: manual
|
||||
timeout: 00:30:00
|
||||
continue_on_timeout: true
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ wait.trigger.id in [''manual'',''left''] }}'
|
||||
alias: Manual or Left
|
||||
sequence:
|
||||
- stop: Automation cancelled
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ wait.trigger == ''none'' or wait.trigger.idx is undefined
|
||||
}}'
|
||||
alias: None or undefined
|
||||
sequence:
|
||||
- service: script.text_notify
|
||||
data:
|
||||
who: tony
|
||||
type: alert
|
||||
message: clear_notification
|
||||
tag: '{{ tag }}'
|
||||
alias: Clear Notification
|
||||
- service: input_datetime.set_datetime
|
||||
target:
|
||||
entity_id: input_datetime.tony_custom_meds_notify_p1
|
||||
data:
|
||||
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,1)
|
||||
}}
|
||||
|
||||
'
|
||||
alias: Reset notification time
|
||||
alias: Choose depending on the wait trigger
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ reason == ''taken'' }}'
|
||||
alias: Taken
|
||||
sequence:
|
||||
- service: input_datetime.set_datetime
|
||||
target:
|
||||
entity_id: '{{ taken_at }}'
|
||||
data:
|
||||
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0)
|
||||
}}
|
||||
|
||||
'
|
||||
alias: Set time the meds were taken
|
||||
- if:
|
||||
- condition: template
|
||||
value_template: '{{ type == ''Interval'' }}'
|
||||
alias: Is it an interval med?
|
||||
then:
|
||||
- service: input_datetime.set_datetime
|
||||
target:
|
||||
entity_id: '{{ notify_at }}'
|
||||
data:
|
||||
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(interval)
|
||||
}}
|
||||
|
||||
'
|
||||
alias: Set notification for next dose
|
||||
alias: If an interval med, then set time for next dose
|
||||
- service: script.text_notify
|
||||
data:
|
||||
who: tony
|
||||
type: alert
|
||||
message: clear_notification
|
||||
tag: '{{ tag }}'
|
||||
alias: Clear Notification
|
||||
alias: Routing
|
||||
icon: mdi:medication
|
||||
mode: parallel
|
||||
|
Reference in New Issue
Block a user