Pain meds handler for me

This commit is contained in:
2023-12-21 16:19:21 -05:00
parent 0869a4a827
commit cb97978ec7
3 changed files with 455 additions and 0 deletions

View File

@ -4282,3 +4282,66 @@
data: {}
alias: If scheduling has already run, set the new times
mode: restart
- id: '1703110817378'
alias: Tony Pain Meds Handler
description: ''
trigger:
- platform: time
at: input_datetime.tony_ibuprofen_notify
id: ibuprofen-notify
alias: Ibuprofen Notify
- alias: Tylenol Notify
platform: time
at: input_datetime.tony_tylenol_notify
id: tylenol-notify
- platform: state
entity_id:
- input_boolean.tony_ibuprofen_taken
from: 'off'
to: 'on'
id: ibuprofen-taken
alias: Ibuprofen Taken
- alias: Tylenol Taken
platform: state
entity_id:
- input_boolean.tony_tylenol_taken
from: 'off'
to: 'on'
id: tylenol-taken
condition: []
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: trigger
id:
- ibuprofen-notify
- ibuprofen-taken
- condition: state
entity_id: input_boolean.tony_ibuprofen_active
state: 'on'
alias: Ibuprofen
sequence:
- service: script.tony_ibuprofen
data:
reason: '{{ trigger.id }}'
alias: Call ibuprofen script
- conditions:
- condition: and
conditions:
- condition: trigger
id:
- tylenol-notify
- tylenol-taken
- condition: state
entity_id: input_boolean.tony_tylenol_active
state: 'on'
alias: Tylenol
sequence:
- service: script.tony_tylenol
data:
reason: '{{ trigger.id }}'
alias: Call tylenol script
mode: parallel
max: 10

View File

@ -13,6 +13,18 @@ input_boolean:
tony_night_meds_taken:
name: Tony Night Meds Taken
icon: mdi:medication
tony_ibuprofen_active:
name: Tony Ibuprofen Active
icon: mdi:medication
tony_ibuprofen_taken:
name: Tony Ibuprofen Taken
icon: mdi:medication
tony_tylenol_active:
name: Tony Tylenol Active
icon: mdi:medication
tony_tylenol_taken:
name: Tony Tylenol Taken
icon: mdi:medication
tony_custom_meds_tracker_p1:
name: Tony Custom Meds Tracker P1
icon: mdi:medication
@ -69,6 +81,26 @@ input_datetime:
has_date: false
has_time: true
icon: mdi:medication
tony_ibuprofen_taken:
name: Tony Ibuprofen Taken
has_date: true
has_time: true
icon: mdi:medication
tony_ibuprofen_notify:
name: Tony Ibuprofen Notify
has_date: false
has_time: true
icon: mdi:medication
tony_tylenol_taken:
name: Tony Tylenol Taken
has_date: true
has_time: true
icon: mdi:medication
tony_tylenol_notify:
name: Tony Tylenol Notify
has_date: false
has_time: true
icon: mdi:medication
input_number:
tony_afternoon_meds_interval:

View File

@ -2344,3 +2344,363 @@ tony_afternoon_meds:
tag: tony-afternoon-meds
icon: mdi:medication
mode: restart
tony_ibuprofen:
alias: Tony Ibuprofen
sequence:
- alias: Turn off boolean if this is a notification
if:
- condition: template
value_template: '{{ reason != ''ibuprofen-taken'' }}'
alias: If reason is not ibuprofen-taken
then:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.tony_ibuprofen_taken
data: {}
alias: Turn off boolean
- alias: Routing
choose:
- conditions:
- condition: template
value_template: '{{ reason == ''ibuprofen-notify'' }}'
alias: Ibuprofen Notify
sequence:
- service: script.text_notify
data:
type: alert
who: tony
title: Tony Ibuprofen Time
message: It is time to take your next dose of Ibuprofen
tag: tony-ibuprofen
actions:
- action: TONY_IBUPROFEN_TAKEN
title: Taken
- action: TONY_IBUPROFEN_SKIPPED
title: Skipped
- action: TONY_IBUPROFEN_ASK_LATER
title: Ask Later
alias: Send actionable text notification
- wait_for_trigger:
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: TONY_IBUPROFEN_TAKEN
id: ibuprofen-taken
alias: Ibuprofen Taken
- alias: Ibuprofen Skipped
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: TONY_IBUPROFEN_SKIPPED
id: ibuprofen-skipped
- alias: Ibuprofen Ask Later
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: TONY_IBUPROFEN_ASK_LATER
id: ibuprofen-ask-later
- platform: state
entity_id:
- input_boolean.tony_ibuprofen_taken
from: 'off'
to: 'on'
id: ibuprofen-manual
alias: Manual
- platform: state
entity_id:
- input_boolean.tony_ibuprofen_active
from: 'on'
to: 'off'
id: cancel
timeout:
hours: 0
minutes: 30
seconds: 0
milliseconds: 0
continue_on_timeout: true
- choose:
- conditions:
- condition: template
value_template: '{{ wait.trigger.id == ''ibuprofen-taken'' }}'
alias: Ibuprofen Taken
sequence:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.tony_ibuprofen_taken
data: {}
alias: Turn on boolean
- conditions:
- alias: Ibuprofen Skipped
condition: template
value_template: '{{ wait.trigger.id == ''ibuprofen-skipped'' }}'
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_ibuprofen_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(8)
}}
'
alias: Set notification time
- conditions:
- alias: Ibuprofen Ask Later
condition: template
value_template: '{{ wait.trigger.id == ''ibuprofen-ask-later'' }}'
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_ibuprofen_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,30)
}}
'
alias: Set ibuprofen notification time
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_ibuprofen_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(4,30)
}}
'
alias: Set ibuprofen notification time
- conditions:
- condition: template
value_template: '{{ wait.trigger == ''none'' or wait.trigger.idx is undefined
}}'
alias: No response
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_ibuprofen_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,30)
}}
'
alias: Set notification time
alias: Act on wait triggers
- service: script.text_notify
data:
type: alert
who: tony
message: clear_notification
tag: tony-ibuprofen
alias: Clear actionable text notification
- conditions:
- condition: template
value_template: '{{ reason == ''ibuprofen-taken'' }}'
alias: Ibuprofen Taken
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_ibuprofen_taken
data:
datetime: '{% from ''time.jinja'' import current_time %} {{ current_time(''datetime'',24)
}}
'
alias: Set time taken
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_ibuprofen_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(8)
}}
'
alias: Set ibuprofen notification time
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_tylenol_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(4)
}}
'
alias: Set tylenol notification time
mode: queued
icon: mdi:medication
max: 10
tony_tylenol:
alias: Tony Tylenol
sequence:
- alias: Turn off boolean if this is a notification
if:
- condition: template
value_template: '{{ reason != ''tylenol-taken'' }}'
alias: If reason is not tylenol-taken
then:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.tony_tylenol_taken
data: {}
alias: Turn off boolean
- alias: Routing
choose:
- conditions:
- condition: template
value_template: '{{ reason == ''tylenol-notify'' }}'
alias: Tylenol Notify
sequence:
- service: script.text_notify
data:
type: alert
who: tony
title: Tony Tylenol Time
message: It is time to take your next dose of Tylenol
tag: tony-tylenol
actions:
- action: TONY_TYLENOL_TAKEN
title: Taken
- action: TONY_TYLENOL_SKIPPED
title: Skipped
- action: TONY_TYLENOL_ASK_LATER
title: Ask Later
alias: Send actionable text notification
- wait_for_trigger:
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: TONY_TYLENOL_TAKEN
id: tylenol-taken
alias: Tylenol Taken
- alias: Tylenol Skipped
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: TONY_TYLENOL_SKIPPED
id: tylenol-skipped
- alias: Tylenol Ask Later
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: TONY_TYLENOL_ASK_LATER
id: tylenol-ask-later
- platform: state
entity_id:
- input_boolean.tony_tylenol_taken
from: 'off'
to: 'on'
id: tylenol-manual
alias: Manual
- platform: state
entity_id:
- input_boolean.tony_tylenol_active
from: 'on'
to: 'off'
id: cancel
timeout:
hours: 0
minutes: 30
seconds: 0
milliseconds: 0
continue_on_timeout: true
- choose:
- conditions:
- condition: template
value_template: '{{ wait.trigger.id == ''tylenol-taken'' }}'
alias: Tylenol Taken
sequence:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.tony_tylenol_taken
data: {}
alias: Turn on boolean
- conditions:
- alias: Tylenol Skipped
condition: template
value_template: '{{ wait.trigger.id == ''tylenol-skipped'' }}'
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_tylenol_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(8)
}}
'
alias: Set notification time
- conditions:
- alias: Tylenol Ask Later
condition: template
value_template: '{{ wait.trigger.id == ''tylenol-ask-later'' }}'
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_tylenol_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,30)
}}
'
alias: Set tylenol notification time
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_tylenol_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(4,30)
}}
'
alias: Set tylenol notification time
- conditions:
- condition: template
value_template: '{{ wait.trigger == ''none'' or wait.trigger.idx is undefined
}}'
alias: No response
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_tylenol_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,30)
}}
'
alias: Set notification time
alias: Act on wait triggers
- service: script.text_notify
data:
type: alert
who: tony
message: clear_notification
tag: tony-tylenol
alias: Clear actionable text notification
- conditions:
- condition: template
value_template: '{{ reason == ''tylenol-taken'' }}'
alias: Tylenol Taken
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_tylenol_taken
data:
datetime: '{% from ''time.jinja'' import current_time %} {{ current_time(''datetime'',24)
}}
'
alias: Set time taken
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_tylenol_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(8)
}}
'
alias: Set tylenol notification time
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tony_ibuprofen_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(4)
}}
'
alias: Set ibuprofen notification time
mode: queued
icon: mdi:medication
max: 10