Afternoon meds added to meds tracker
This commit is contained in:
@ -2360,12 +2360,16 @@
|
|||||||
mode: single
|
mode: single
|
||||||
- id: '1696288846954'
|
- id: '1696288846954'
|
||||||
alias: Tony Meds Handler
|
alias: Tony Meds Handler
|
||||||
description: Make sure Tony has taken his meds in the morning and at night
|
description: Make sure Tony has taken his meds at the scheduled times
|
||||||
trigger:
|
trigger:
|
||||||
- platform: time
|
- platform: time
|
||||||
at: input_datetime.tony_morning_meds_notify
|
at: input_datetime.tony_morning_meds_notify
|
||||||
id: morning-notify
|
id: morning-notify
|
||||||
alias: Morning Notify
|
alias: Morning Notify
|
||||||
|
- platform: time
|
||||||
|
at: input_datetime.tony_afternoon_meds_notify
|
||||||
|
id: afternoon-notify
|
||||||
|
alias: Afternoon Notify
|
||||||
- platform: time
|
- platform: time
|
||||||
at: input_datetime.tony_night_meds_notify
|
at: input_datetime.tony_night_meds_notify
|
||||||
id: night-notify
|
id: night-notify
|
||||||
@ -2377,6 +2381,13 @@
|
|||||||
id: boolean-morning
|
id: boolean-morning
|
||||||
alias: Morning Taken
|
alias: Morning Taken
|
||||||
from: 'off'
|
from: 'off'
|
||||||
|
- platform: state
|
||||||
|
entity_id:
|
||||||
|
- input_boolean.tony_afternoon_meds_taken
|
||||||
|
id: boolean-afternoon
|
||||||
|
from: 'off'
|
||||||
|
to: 'on'
|
||||||
|
alias: Afternoon Taken
|
||||||
- platform: state
|
- platform: state
|
||||||
entity_id:
|
entity_id:
|
||||||
- input_boolean.tony_night_meds_taken
|
- input_boolean.tony_night_meds_taken
|
||||||
@ -2393,7 +2404,8 @@
|
|||||||
to: 'off'
|
to: 'off'
|
||||||
condition: []
|
condition: []
|
||||||
action:
|
action:
|
||||||
- choose:
|
- alias: Routing
|
||||||
|
choose:
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: and
|
- condition: and
|
||||||
conditions:
|
conditions:
|
||||||
@ -2409,6 +2421,20 @@
|
|||||||
entity_id: script.tony_morning_meds
|
entity_id: script.tony_morning_meds
|
||||||
data: {}
|
data: {}
|
||||||
alias: Run morning meds script
|
alias: Run morning meds script
|
||||||
|
- conditions:
|
||||||
|
- alias: Afternoon Notify
|
||||||
|
condition: and
|
||||||
|
conditions:
|
||||||
|
- condition: trigger
|
||||||
|
id:
|
||||||
|
- afternoon-notify
|
||||||
|
- condition: state
|
||||||
|
entity_id: input_boolean.tony_afternoon_meds_taken
|
||||||
|
state: 'off'
|
||||||
|
sequence:
|
||||||
|
- service: script.tony_afternoon_meds
|
||||||
|
data: {}
|
||||||
|
alias: Run afternoon meds script
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: and
|
- condition: and
|
||||||
conditions:
|
conditions:
|
||||||
@ -2439,6 +2465,30 @@
|
|||||||
|
|
||||||
'
|
'
|
||||||
alias: Set time morning meds were taken
|
alias: Set time morning meds were taken
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.tony_afternoon_meds_notify
|
||||||
|
data:
|
||||||
|
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(6)
|
||||||
|
}}
|
||||||
|
|
||||||
|
'
|
||||||
|
alias: Adjust afternoon meds reminder
|
||||||
|
- conditions:
|
||||||
|
- condition: trigger
|
||||||
|
id:
|
||||||
|
- boolean-afternoon
|
||||||
|
alias: Afternoon Taken
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.tony_afternoon_meds_taken
|
||||||
|
data:
|
||||||
|
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0)
|
||||||
|
}}
|
||||||
|
|
||||||
|
'
|
||||||
|
alias: Set time afternoon meds were taken
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: trigger
|
- condition: trigger
|
||||||
id: boolean-night
|
id: boolean-night
|
||||||
@ -2467,7 +2517,6 @@
|
|||||||
|
|
||||||
'
|
'
|
||||||
alias: Set time to start notifying for morning meds
|
alias: Set time to start notifying for morning meds
|
||||||
alias: Routing
|
|
||||||
mode: parallel
|
mode: parallel
|
||||||
max: 10
|
max: 10
|
||||||
- id: '1696288939707'
|
- id: '1696288939707'
|
||||||
@ -2564,12 +2613,6 @@
|
|||||||
value: '{{ states(''input_number.tomorrow_corrected_high_temp'') | int }}'
|
value: '{{ states(''input_number.tomorrow_corrected_high_temp'') | int }}'
|
||||||
target:
|
target:
|
||||||
entity_id: input_number.today_corrected_high_temp
|
entity_id: input_number.today_corrected_high_temp
|
||||||
- conditions:
|
|
||||||
- condition: trigger
|
|
||||||
id: audible-off
|
|
||||||
sequence:
|
|
||||||
- service: script.reset_annc_switches
|
|
||||||
data: {}
|
|
||||||
- service: input_number.set_value
|
- service: input_number.set_value
|
||||||
target:
|
target:
|
||||||
entity_id:
|
entity_id:
|
||||||
@ -2578,6 +2621,12 @@
|
|||||||
- input_number.basement_studio_door_opened_today
|
- input_number.basement_studio_door_opened_today
|
||||||
data:
|
data:
|
||||||
value: 0
|
value: 0
|
||||||
|
- conditions:
|
||||||
|
- condition: trigger
|
||||||
|
id: audible-off
|
||||||
|
sequence:
|
||||||
|
- service: script.reset_annc_switches
|
||||||
|
data: {}
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: trigger
|
- condition: trigger
|
||||||
id: school-end
|
id: school-end
|
||||||
@ -2603,6 +2652,7 @@
|
|||||||
- input_boolean.kallen_night_meds_taken
|
- input_boolean.kallen_night_meds_taken
|
||||||
- input_boolean.tony_morning_meds_taken
|
- input_boolean.tony_morning_meds_taken
|
||||||
- input_boolean.tina_morning_meds_taken
|
- input_boolean.tina_morning_meds_taken
|
||||||
|
- input_boolean.tony_afternoon_meds_taken
|
||||||
data: {}
|
data: {}
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: trigger
|
- condition: trigger
|
||||||
|
@ -172,7 +172,7 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro tony_night_meds(type,method) %}
|
{% macro tony_afternoon_meds(type,method) %}
|
||||||
{% set streamBlock = twitchStreamInfo(type,method) | trim == '' %}
|
{% set streamBlock = twitchStreamInfo(type,method) | trim == '' %}
|
||||||
{% set morningBlock = tony_morning_meds(type,method) | trim != '' %}
|
{% set morningBlock = tony_morning_meds(type,method) | trim != '' %}
|
||||||
{% if type == 'meds' or streamBlock == true or morningBlock == true %}
|
{% if type == 'meds' or streamBlock == true or morningBlock == true %}
|
||||||
@ -180,6 +180,33 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
|
|||||||
{% else %}
|
{% else %}
|
||||||
{% set identTony = 'He' %}
|
{% set identTony = 'He' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if is_state('input_boolean.tony_afternoon_meds_taken','on') and is_state('input_boolean.tony_awake','on') %}
|
||||||
|
{{ identTony }} took his afternoon meds at {{ input_datetime_read('input_datetime.tony_afternoon_meds_taken') | trim }}.
|
||||||
|
{% elif is_state('input_boolean.tony_afternoon_meds_taken','off') and ct >= 61200 %}
|
||||||
|
{{ identTony }} has not taken his afternoon meds.
|
||||||
|
{% if ct < state_attr('input_datetime.tony_afternoon_meds_notify','timestamp') | int %}
|
||||||
|
{% if method == 'tts' %}
|
||||||
|
{{ ['He has a reminder scheduled for',
|
||||||
|
'Rest assured that I will pester him mercilessly about this, starting at',
|
||||||
|
'This is absolutely essential, and I will remind him to do it at',
|
||||||
|
'Since nobody including Tony himself likes him without his meds, I will remind him at',
|
||||||
|
] | random }} {{ input_datetime_read('input_datetime.tony_afternoon_meds_notify') | trim }}.
|
||||||
|
{% else %}
|
||||||
|
He will be reminded at {{ input_datetime_read('input_datetime.tony_afternoon_meds_notify') | trim }}.
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro tony_night_meds(type,method) %}
|
||||||
|
{% set streamBlock = twitchStreamInfo(type,method) | trim == '' %}
|
||||||
|
{% set morningBlock = tony_morning_meds(type,method) | trim != '' %}
|
||||||
|
{% set afternoonBlock = tony_afternoon_meds(type,method) | trim != '' %}
|
||||||
|
{% if type == 'meds' or streamBlock == true or (morningBlock == true and afternoonBlock == true) %}
|
||||||
|
{% set identTony = 'Tony' %}
|
||||||
|
{% else %}
|
||||||
|
{% set identTony = 'He' %}
|
||||||
|
{% endif %}
|
||||||
{% if is_state('input_boolean.tony_night_meds_taken','on') and (is_state('binary_sensor.overnight','on') or ct < 43200) %}
|
{% if is_state('input_boolean.tony_night_meds_taken','on') and (is_state('binary_sensor.overnight','on') or ct < 43200) %}
|
||||||
{{ identTony }} took his night meds at {{ input_datetime_read('input_datetime.tony_night_meds_taken') | trim }}.
|
{{ identTony }} took his night meds at {{ input_datetime_read('input_datetime.tony_night_meds_taken') | trim }}.
|
||||||
{% elif is_state('input_boolean.tony_night_meds_taken','off') and is_state('binary_sensor.overnight','on') %}
|
{% elif is_state('input_boolean.tony_night_meds_taken','off') and is_state('binary_sensor.overnight','on') %}
|
||||||
@ -198,6 +225,7 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
|
|||||||
|
|
||||||
{% macro medReportTony(type,method) %}
|
{% macro medReportTony(type,method) %}
|
||||||
{{ tony_morning_meds(type,method) }}
|
{{ tony_morning_meds(type,method) }}
|
||||||
|
{{ tony_afternoon_meds(type,method) }}
|
||||||
{{ tony_night_meds(type,method) }}
|
{{ tony_night_meds(type,method) }}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
@ -567,6 +567,11 @@ script:
|
|||||||
entity_id: input_datetime.tony_morning_meds_notify
|
entity_id: input_datetime.tony_morning_meds_notify
|
||||||
data:
|
data:
|
||||||
time: "{{ states('input_datetime.master_bedroom_wakeup') }}"
|
time: "{{ states('input_datetime.master_bedroom_wakeup') }}"
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.tony_afternoon_meds_notify
|
||||||
|
data:
|
||||||
|
time: "{{ (state_attr('input_datetime.master_bedroom_wakeup','timestamp') | int + 21600) | timestamp_custom('%H:%M', false)}}"
|
||||||
- service: input_datetime.set_datetime
|
- service: input_datetime.set_datetime
|
||||||
target:
|
target:
|
||||||
entity_id: input_datetime.tina_morning_meds_notify
|
entity_id: input_datetime.tina_morning_meds_notify
|
||||||
|
@ -7,6 +7,9 @@ input_boolean:
|
|||||||
tony_morning_meds_taken:
|
tony_morning_meds_taken:
|
||||||
name: Tony Morning Meds Taken
|
name: Tony Morning Meds Taken
|
||||||
icon: mdi:medication
|
icon: mdi:medication
|
||||||
|
tony_afternoon_meds_taken:
|
||||||
|
name: Tony Afternoon Meds Taken
|
||||||
|
icon: mdi:medication
|
||||||
tony_night_meds_taken:
|
tony_night_meds_taken:
|
||||||
name: Tony Night Meds Taken
|
name: Tony Night Meds Taken
|
||||||
icon: mdi:medication
|
icon: mdi:medication
|
||||||
@ -31,6 +34,11 @@ input_datetime:
|
|||||||
has_date: true
|
has_date: true
|
||||||
has_time: true
|
has_time: true
|
||||||
icon: mdi:medication
|
icon: mdi:medication
|
||||||
|
tony_afternoon_meds_taken:
|
||||||
|
name: Tony Afternoon Meds Taken
|
||||||
|
has_date: true
|
||||||
|
has_time: true
|
||||||
|
icon: mdi:medication
|
||||||
tony_night_meds_taken:
|
tony_night_meds_taken:
|
||||||
name: Tony Night Meds Taken
|
name: Tony Night Meds Taken
|
||||||
has_date: true
|
has_date: true
|
||||||
@ -41,6 +49,11 @@ input_datetime:
|
|||||||
has_date: false
|
has_date: false
|
||||||
has_time: true
|
has_time: true
|
||||||
icon: mdi:medication
|
icon: mdi:medication
|
||||||
|
tony_afternoon_meds_notify:
|
||||||
|
name: Tony Afternoon Meds Notify
|
||||||
|
has_date: false
|
||||||
|
has_time: true
|
||||||
|
icon: mdi:medication
|
||||||
tony_night_meds_notify:
|
tony_night_meds_notify:
|
||||||
name: Tony Night Meds Notify
|
name: Tony Night Meds Notify
|
||||||
has_date: false
|
has_date: false
|
||||||
|
106
scripts.yaml
106
scripts.yaml
@ -2175,3 +2175,109 @@ tony_custom_meds:
|
|||||||
alias: Routing
|
alias: Routing
|
||||||
icon: mdi:medication
|
icon: mdi:medication
|
||||||
mode: parallel
|
mode: parallel
|
||||||
|
tony_afternoon_meds:
|
||||||
|
alias: Tony Afternoon Meds
|
||||||
|
sequence:
|
||||||
|
- service: script.text_notify
|
||||||
|
data:
|
||||||
|
who: tony
|
||||||
|
type: alert
|
||||||
|
title: Afternoon Meds
|
||||||
|
message: You need to take your afternoon meds
|
||||||
|
tag: tony-afternoon-meds
|
||||||
|
actions:
|
||||||
|
- action: TONY_AFTERNOON_MEDS_TAKEN
|
||||||
|
title: Taken
|
||||||
|
- action: TONY_AFTERNOON_MEDS_SKIPPED
|
||||||
|
title: Skip
|
||||||
|
- action: TONY_AFTERNOON_MEDS_ASK_LATER
|
||||||
|
title: Ask Later
|
||||||
|
- wait_for_trigger:
|
||||||
|
- alias: Taken
|
||||||
|
platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: TONY_AFTERNOON_MEDS_TAKEN
|
||||||
|
id: taken
|
||||||
|
- alias: Skipped
|
||||||
|
platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: TONY_AFTERNOON_MEDS_SKIPPED
|
||||||
|
id: skipped
|
||||||
|
- alias: Ask Later
|
||||||
|
platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: TONY_AFTERNOON_MEDS_ASK_LATER
|
||||||
|
id: ask-later
|
||||||
|
- platform: state
|
||||||
|
entity_id: person.tony_stork
|
||||||
|
from: home
|
||||||
|
id: left
|
||||||
|
alias: Left
|
||||||
|
- alias: Manual
|
||||||
|
platform: state
|
||||||
|
entity_id:
|
||||||
|
- input_boolean.tony_afternoon_meds_taken
|
||||||
|
to: 'on'
|
||||||
|
id: manual
|
||||||
|
from: 'off'
|
||||||
|
timeout: 00:30:00
|
||||||
|
continue_on_timeout: true
|
||||||
|
- choose:
|
||||||
|
- conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: '{{ wait.trigger.id in [''taken'',''manual''] }}'
|
||||||
|
alias: Taken, Manual
|
||||||
|
sequence:
|
||||||
|
- service: input_boolean.turn_on
|
||||||
|
data: {}
|
||||||
|
target:
|
||||||
|
entity_id: input_boolean.tony_afternoon_meds_taken
|
||||||
|
- conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: '{{ wait.trigger.id == ''ask-later'' }}'
|
||||||
|
alias: Ask Later
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.tony_afternoon_meds_notify
|
||||||
|
data:
|
||||||
|
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,30)
|
||||||
|
}}
|
||||||
|
|
||||||
|
'
|
||||||
|
- conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: '{{ wait.trigger.id == ''left'' }}'
|
||||||
|
alias: Left
|
||||||
|
sequence:
|
||||||
|
- service: script.text_notify
|
||||||
|
data:
|
||||||
|
who: tony
|
||||||
|
type: critical
|
||||||
|
title: HEY DUMBASS
|
||||||
|
message: YOU FORGOT TO TAKE YOUR AFTERNOON MEDS!!!!!
|
||||||
|
- conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: '{{ wait.trigger == ''none'' or wait.trigger.idx is undefined
|
||||||
|
}}'
|
||||||
|
alias: None or undefined
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.tony_afternoon_meds_notify
|
||||||
|
data:
|
||||||
|
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,1)
|
||||||
|
}}
|
||||||
|
|
||||||
|
'
|
||||||
|
- service: script.text_notify
|
||||||
|
data:
|
||||||
|
type: alert
|
||||||
|
who: tony
|
||||||
|
message: clear_notification
|
||||||
|
tag: tony-afternoon-meds
|
||||||
|
icon: mdi:medication
|
||||||
|
mode: restart
|
||||||
|
Reference in New Issue
Block a user