Custom med tracker functional for interval meds

This commit is contained in:
2023-10-05 18:46:58 -04:00
parent 31d17c7168
commit 963ef0cb78
3 changed files with 174 additions and 41 deletions

View File

@ -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