Complete overhaul of E's med handling, close #130
This commit is contained in:
@ -546,12 +546,55 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro medReportEmma(type,method) %}
|
||||||
|
{% set tylenol_taken = input_datetime_read('input_datetime.emma_tylenol','withdate') | trim %}
|
||||||
|
{% set ibuprofen_taken = input_datetime_read('input_datetime.emma_ibuprofen','withdate') | trim %}
|
||||||
|
{% set cough_meds_taken = input_datetime_read('input_datetime.emma_cough_meds','withdate') | trim %}
|
||||||
|
{% set tylenol_next = input_datetime_read('input_datetime.emma_tylenol_notify','nodate') | trim %}
|
||||||
|
{% set ibuprofen_next = input_datetime_read('input_datetime.emma_ibuprofen_notify','nodate') | trim %}
|
||||||
|
{% set cough_meds_next = input_datetime_read('input_datetime.emma_cough_meds_notify','nodate') | trim %}
|
||||||
|
{% if is_state('input_boolean.emma_alternating_meds_active','on') and
|
||||||
|
is_state('input_boolean.emma_cough_meds_active','on') and
|
||||||
|
is_state('input_boolean.emma_tylenol','off') and
|
||||||
|
is_state('input_boolean.emma_ibuprofen','off') and
|
||||||
|
is_state('input_boolean.emma_cough_meds','off') %}
|
||||||
|
Emma has not taken her ibuprofen, tylenol, or cough meds.
|
||||||
|
{% else %}
|
||||||
|
{% if is_state('input_boolean.emma_alternating_meds_active','on') %}
|
||||||
|
{% if is_state('input_boolean.emma_tylenol','off') and is_state('input_boolean.emma_ibuprofen','off') %}
|
||||||
|
Emma has not taken her ibuprofen or her tylenol.
|
||||||
|
{% else %}
|
||||||
|
{% if is_state('input_boolean.emma_tylenol','on') %}
|
||||||
|
Emma has taken her tylenol. Her most recent dose was at {{ tylenol_taken }}. Her next dose is at {{ tylenol_next }}.
|
||||||
|
{% else %}
|
||||||
|
Emma has not taken her tylenol.
|
||||||
|
{% endif %}
|
||||||
|
{% if is_state('input_boolean.emma_ibuprofen','on') %}
|
||||||
|
Emma has taken her ibuprofen. Her most recent dose was at {{ ibuprofen_taken }}. Her next dose is at {{ ibuprofen_next }}.
|
||||||
|
{% else %}
|
||||||
|
Emma has not taken her ibuprofen.
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if is_state('input_boolean.emma_cough_meds_active','on') %}
|
||||||
|
{% if is_state('input_boolean.emma_cough_meds','on') %}
|
||||||
|
Emma has taken her cough meds. Her most recent dose was at {{ cough_meds_taken }}. Her next dose is at {{ cough_meds_next }}.
|
||||||
|
{% else %}
|
||||||
|
Emma has not taken her cough meds.
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro emmaStatusReport(type,method) %}
|
{% macro emmaStatusReport(type,method) %}
|
||||||
{% macro data() %}
|
{% macro data() %}
|
||||||
{% if type == 'sleep' %}
|
{% if type == 'sleep' %}
|
||||||
{{ emma_sleep(type,method) }}
|
{{ emma_sleep(type,method) }}
|
||||||
|
{% elif type == 'meds' %}
|
||||||
|
{{ medReportEmma(type,method) }}
|
||||||
{% elif type == 'full' %}
|
{% elif type == 'full' %}
|
||||||
{{ emma_sleep(type,method) }}
|
{{ emma_sleep(type,method) }}
|
||||||
|
{{ medReportEmma(type,method) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
{{ cleanup(data()) }}
|
{{ cleanup(data()) }}
|
||||||
|
@ -7,8 +7,11 @@ input_boolean:
|
|||||||
emma_has_napped:
|
emma_has_napped:
|
||||||
name: Emma Has Napped
|
name: Emma Has Napped
|
||||||
icon: mdi:check
|
icon: mdi:check
|
||||||
emma_meds_active:
|
emma_alternating_meds_active:
|
||||||
name: Emma Meds Active
|
name: Emma Alternating Meds Active
|
||||||
|
icon: mdi:medical-bag
|
||||||
|
emma_cough_meds_active:
|
||||||
|
name: Emma Cough Meds Active
|
||||||
icon: mdi:medical-bag
|
icon: mdi:medical-bag
|
||||||
emma_ibuprofen:
|
emma_ibuprofen:
|
||||||
name: Emma Ibuprofen
|
name: Emma Ibuprofen
|
||||||
@ -16,6 +19,9 @@ input_boolean:
|
|||||||
emma_tylenol:
|
emma_tylenol:
|
||||||
name: Emma Tylenol
|
name: Emma Tylenol
|
||||||
icon: mdi:medical-bag
|
icon: mdi:medical-bag
|
||||||
|
emma_cough_meds:
|
||||||
|
name: Emma Cough Meds
|
||||||
|
icon: mdi:medical-bag
|
||||||
emma_alarm_clock:
|
emma_alarm_clock:
|
||||||
name: Emma Alarm Clock
|
name: Emma Alarm Clock
|
||||||
icon: mdi:alarm
|
icon: mdi:alarm
|
||||||
@ -57,11 +63,31 @@ input_datetime:
|
|||||||
has_date: true
|
has_date: true
|
||||||
has_time: true
|
has_time: true
|
||||||
icon: mdi:medical-bag
|
icon: mdi:medical-bag
|
||||||
|
emma_ibuprofen_notify:
|
||||||
|
name: Emma Ibuprofen Notify
|
||||||
|
has_date: false
|
||||||
|
has_time: true
|
||||||
|
icon: mdi:medical-bag
|
||||||
emma_tylenol:
|
emma_tylenol:
|
||||||
name: Emma Tylenol
|
name: Emma Tylenol
|
||||||
has_date: true
|
has_date: true
|
||||||
has_time: true
|
has_time: true
|
||||||
icon: mdi:medical-bag
|
icon: mdi:medical-bag
|
||||||
|
emma_tylenol_notify:
|
||||||
|
name: Emma Tylenol Notify
|
||||||
|
has_date: false
|
||||||
|
has_time: true
|
||||||
|
icon: mdi:medical-bag
|
||||||
|
emma_cough_meds:
|
||||||
|
name: Emma Cough Meds
|
||||||
|
has_date: true
|
||||||
|
has_time: true
|
||||||
|
icon: mdi:medical-bag
|
||||||
|
emma_cough_meds_notify:
|
||||||
|
name: Emma Cough Meds Notify
|
||||||
|
has_date: false
|
||||||
|
has_time: true
|
||||||
|
icon: mdi:medical-bag
|
||||||
emma_alarm_clock:
|
emma_alarm_clock:
|
||||||
name: Emma Alarm Clock
|
name: Emma Alarm Clock
|
||||||
has_date: false
|
has_date: false
|
||||||
@ -413,332 +439,482 @@ automation:
|
|||||||
alias: Emma Meds Handler
|
alias: Emma Meds Handler
|
||||||
description: Handles reminders for Emma taking her meds when sick or teething
|
description: Handles reminders for Emma taking her meds when sick or teething
|
||||||
mode: parallel
|
mode: parallel
|
||||||
max: 20
|
max: 30
|
||||||
trigger:
|
trigger:
|
||||||
- platform: state
|
- platform: state
|
||||||
entity_id: input_boolean.emma_meds_active
|
entity_id: input_boolean.emma_alternating_meds_active
|
||||||
from: 'off'
|
from: 'off'
|
||||||
to: 'on'
|
to: 'on'
|
||||||
id: active
|
id: alt-active
|
||||||
- platform: state
|
- platform: state
|
||||||
entity_id: input_boolean.emma_meds_active
|
entity_id: input_boolean.emma_alternating_meds_active
|
||||||
from: 'on'
|
from: 'on'
|
||||||
to: 'off'
|
to: 'off'
|
||||||
id: inactive
|
id: alt-inactive
|
||||||
|
- platform: state
|
||||||
|
entity_id: input_boolean.emma_cough_meds_active
|
||||||
|
from: 'off'
|
||||||
|
to: 'on'
|
||||||
|
id: cough-active
|
||||||
|
- platform: state
|
||||||
|
entity_id: input_boolean.emma_cough_meds_active
|
||||||
|
from: 'on'
|
||||||
|
to: 'off'
|
||||||
|
id: cough-inactive
|
||||||
- platform: time
|
- platform: time
|
||||||
at: input_datetime.emma_ibuprofen
|
at: input_datetime.emma_ibuprofen_notify
|
||||||
id: ibuprofen
|
id: ibuprofen-notify
|
||||||
- platform: time
|
- platform: time
|
||||||
at: input_datetime.emma_tylenol
|
at: input_datetime.emma_tylenol_notify
|
||||||
id: tylenol
|
id: tylenol-notify
|
||||||
|
- platform: time
|
||||||
|
at: input_datetime.emma_cough_meds_notify
|
||||||
|
id: cough-notify
|
||||||
condition:
|
condition:
|
||||||
- condition: state
|
- condition: or
|
||||||
entity_id: input_boolean.emma_meds_active
|
conditions:
|
||||||
state: 'on'
|
- condition: state
|
||||||
|
entity_id: input_boolean.emma_alternating_meds_active
|
||||||
|
state: 'on'
|
||||||
|
- condition: state
|
||||||
|
entity_id: input_boolean.emma_cough_meds_active
|
||||||
|
state: 'on'
|
||||||
action:
|
action:
|
||||||
- choose:
|
- choose:
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: trigger
|
- condition: trigger
|
||||||
id:
|
id:
|
||||||
- active
|
- alt-active
|
||||||
- reset
|
- alt-inactive
|
||||||
sequence:
|
|
||||||
- service: script.turn_on
|
|
||||||
target:
|
|
||||||
entity_id: script.emma_meds_active
|
|
||||||
- conditions:
|
|
||||||
- condition: trigger
|
|
||||||
id: ibuprofen
|
|
||||||
sequence:
|
|
||||||
- service: script.turn_on
|
|
||||||
target:
|
|
||||||
entity_id: script.emma_ibuprofen
|
|
||||||
- conditions:
|
|
||||||
- condition: trigger
|
|
||||||
id: tylenol
|
|
||||||
sequence:
|
|
||||||
- service: script.turn_on
|
|
||||||
target:
|
|
||||||
entity_id: script.emma_tylenol
|
|
||||||
- conditions:
|
|
||||||
- condition: trigger
|
|
||||||
id: inactive
|
|
||||||
sequence:
|
sequence:
|
||||||
- service: input_boolean.turn_off
|
- service: input_boolean.turn_off
|
||||||
target:
|
target:
|
||||||
entity_id:
|
entity_id:
|
||||||
- input_boolean.emma_ibuprofen
|
- input_boolean.emma_tylenol
|
||||||
- input_boolean.emma_tylenol
|
- input_boolean.emma_ibuprofen
|
||||||
|
- conditions:
|
||||||
script:
|
- condition: trigger
|
||||||
emma_meds_active:
|
id:
|
||||||
alias: Emma Meds Active
|
- cough-active
|
||||||
icon: mdi:medical-bag
|
- cough-inactive
|
||||||
mode: restart
|
|
||||||
sequence:
|
|
||||||
- service: input_boolean.turn_off
|
|
||||||
target:
|
|
||||||
entity_id:
|
|
||||||
- input_boolean.emma_ibuprofen
|
|
||||||
- input_coolean.emma_tylenol
|
|
||||||
- service: script.text_notify
|
|
||||||
data:
|
|
||||||
who: >
|
|
||||||
{% if states('person.christina_stork') in ['Bob Evans','BobEvans'] %}
|
|
||||||
tony
|
|
||||||
{% else %}
|
|
||||||
parents
|
|
||||||
{% endif %}
|
|
||||||
type: alert
|
|
||||||
title: Emma Meds Activated
|
|
||||||
message: Which meds are we starting with?
|
|
||||||
tag: emma-meds-active
|
|
||||||
actions:
|
|
||||||
- action: "EMMA_MEDS_START_IBUPROFEN"
|
|
||||||
title: Ibuprofen
|
|
||||||
- action: "EMMA_MEDS_START_TYLENOL"
|
|
||||||
title: Tylenol
|
|
||||||
- wait_for_trigger:
|
|
||||||
- platform: event
|
|
||||||
event_type: ios.notification_action_fired
|
|
||||||
event_data:
|
|
||||||
actionName: "EMMA_MEDS_START_IBUPROFEN"
|
|
||||||
id: ibuprofen
|
|
||||||
- platform: event
|
|
||||||
event_type: ios.notification_action_fired
|
|
||||||
event_data:
|
|
||||||
actionName: "EMMA_MEDS_START_TYLENOL"
|
|
||||||
id: tylenol
|
|
||||||
- platform: state
|
|
||||||
entity_id: input_boolean.emma_meds_active
|
|
||||||
to: 'off'
|
|
||||||
id: cancel
|
|
||||||
timeout: "00:10:00"
|
|
||||||
continue_on_timeout: true
|
|
||||||
- choose:
|
|
||||||
- conditions: "{{ wait.trigger.id == 'ibuprofen' }}"
|
|
||||||
sequence:
|
|
||||||
- service: input_datetime.set_datetime
|
|
||||||
target:
|
|
||||||
entity_id: input_datetime.emma_ibuprofen
|
|
||||||
data:
|
|
||||||
datetime: >
|
|
||||||
{% from 'time.jinja' import set_datetime %}
|
|
||||||
{{ set_datetime(8) }}
|
|
||||||
- service: input_datetime.set_datetime
|
|
||||||
target:
|
|
||||||
entity_id: input_datetime.emma_tylenol
|
|
||||||
data:
|
|
||||||
datetime: >
|
|
||||||
{% from 'time.jinja' import set_datetime %}
|
|
||||||
{{ set_datetime(4) }}
|
|
||||||
- service: input_boolean.turn_on
|
|
||||||
target:
|
|
||||||
entity_id: input_boolean.emma_ibuprofen
|
|
||||||
- conditions: "{{ wait.trigger.id == 'tylenol' }}"
|
|
||||||
sequence:
|
|
||||||
- service: input_datetime.set_datetime
|
|
||||||
target:
|
|
||||||
entity_id: input_datetime.emma_tylenol
|
|
||||||
data:
|
|
||||||
datetime: >
|
|
||||||
{% from 'time.jinja' import set_datetime %}
|
|
||||||
{{ set_datetime(8) }}
|
|
||||||
- service: input_datetime.set_datetime
|
|
||||||
target:
|
|
||||||
entity_id: input_datetime.emma_ibuprofen
|
|
||||||
data:
|
|
||||||
datetime: >
|
|
||||||
{% from 'time.jinja' import set_datetime %}
|
|
||||||
{{ set_datetime(4) }}
|
|
||||||
- service: input_boolean.turn_on
|
|
||||||
target:
|
|
||||||
entity_id: input_boolean.emma_tylenol
|
|
||||||
- conditions: "{{ wait.trigger.id == 'cancel' or wait.trigger == 'none' or wait.trigger.idx is undefined }}"
|
|
||||||
sequence:
|
sequence:
|
||||||
- service: input_boolean.turn_off
|
- service: input_boolean.turn_off
|
||||||
target:
|
target:
|
||||||
entity_id: input_boolean.emma_meds_active
|
entity_id: input_boolean.emma_cough_meds
|
||||||
- service: script.text_notify
|
- conditions:
|
||||||
data:
|
- condition: and
|
||||||
type: alert
|
conditions:
|
||||||
who: parents
|
- condition: trigger
|
||||||
message: clear_notification
|
id:
|
||||||
tag: emma-meds-active
|
- ibuprofen-notify
|
||||||
|
- ibuprofen-on
|
||||||
|
- condition: state
|
||||||
|
entity_id: input_boolean.emma_alternating_meds_active
|
||||||
|
state: 'on'
|
||||||
|
sequence:
|
||||||
|
- service: script.emma_ibuprofen
|
||||||
|
data:
|
||||||
|
reason: "{{ trigger.id }}"
|
||||||
|
- conditions:
|
||||||
|
- condition: and
|
||||||
|
conditions:
|
||||||
|
- condition: trigger
|
||||||
|
id:
|
||||||
|
- tylenol-notify
|
||||||
|
- tylenol-on
|
||||||
|
- condition: state
|
||||||
|
entity_id: input_boolean.emma_alternating_meds_active
|
||||||
|
state: 'on'
|
||||||
|
sequence:
|
||||||
|
- service: script.emma_tylenol
|
||||||
|
data:
|
||||||
|
reason: "{{ trigger.id }}"
|
||||||
|
- conditions:
|
||||||
|
- condition: and
|
||||||
|
conditions:
|
||||||
|
- condition: trigger
|
||||||
|
id:
|
||||||
|
- cough-notify
|
||||||
|
- cough-on
|
||||||
|
- condition: state
|
||||||
|
entity_id: input_boolean.emma_cough_meds_active
|
||||||
|
state: 'on'
|
||||||
|
sequence:
|
||||||
|
- service: script.emma_cough_meds
|
||||||
|
data:
|
||||||
|
reason: "{{ trigger.id }}"
|
||||||
|
|
||||||
|
script:
|
||||||
emma_ibuprofen:
|
emma_ibuprofen:
|
||||||
alias: Emma Ibuprofen
|
alias: Emma Ibuprofen
|
||||||
icon: mdi:medical-bag
|
icon: mdi:medical-bag
|
||||||
mode: restart
|
mode: queued
|
||||||
|
max: 10
|
||||||
sequence:
|
sequence:
|
||||||
- service: input_boolean.turn_off
|
|
||||||
target:
|
|
||||||
entity_id: input_boolean.emma_ibuprofen
|
|
||||||
- service: script.text_notify
|
|
||||||
data:
|
|
||||||
who: >
|
|
||||||
{% if states('person.christina_stork') in ['Bob Evans','BobEvans'] %}
|
|
||||||
tony
|
|
||||||
{% else %}
|
|
||||||
parents
|
|
||||||
{% endif %}
|
|
||||||
type: alert
|
|
||||||
title: Emma Ibuprofen Time
|
|
||||||
message: It is time to give Emma her next dose of ibuprofen
|
|
||||||
tag: emma-ibuprofen
|
|
||||||
actions:
|
|
||||||
- action: "EMMA_IBUPROFEN_GIVEN"
|
|
||||||
name: Given
|
|
||||||
- action: "EMMA_IBUPROFEN_SKIPPED"
|
|
||||||
name: Skipped
|
|
||||||
- action: "EMMA_IBUPROFEN_ASK_LATER"
|
|
||||||
name: Ask Later
|
|
||||||
- wait_for_trigger:
|
|
||||||
- platform: event
|
|
||||||
event_type: ios.notification_action_fired
|
|
||||||
event_data:
|
|
||||||
actionName: "EMMA_IBUPROFEN_GIVEN"
|
|
||||||
id: ibuprofen-given
|
|
||||||
- platform: event
|
|
||||||
event_type: ios.notification_action_fired
|
|
||||||
event_data:
|
|
||||||
actionName: "EMMA_IBUPROFEN_SKIPPED"
|
|
||||||
id: ibuprofen-skipped
|
|
||||||
- platform: event
|
|
||||||
event_type: ios.notification_action_fired
|
|
||||||
event_data:
|
|
||||||
actionName: "EMMA_IBUPROFEN_ASK_LATER"
|
|
||||||
id: ibuprofen-ask-later
|
|
||||||
- platform: state
|
|
||||||
entity_id: input_boolean.emma_meds_active
|
|
||||||
to: 'off'
|
|
||||||
id: cancel
|
|
||||||
timeout: "00:30:00"
|
|
||||||
continue_on_timeout: true
|
|
||||||
- choose:
|
- choose:
|
||||||
- conditions: "{{ wait.trigger.id == 'ibuprofen-given' }}"
|
- conditions: "{{ reason == 'ibuprofen-notify' }}"
|
||||||
sequence:
|
sequence:
|
||||||
- service: input_datetime.set_datetime
|
- service: input_boolean.turn_off
|
||||||
target:
|
|
||||||
entity_id: input_datetime.emma_ibuprofen
|
|
||||||
data:
|
|
||||||
datetime: >
|
|
||||||
{% from 'time.jinja' import set_datetime %}
|
|
||||||
{{ set_datetime(8) }}
|
|
||||||
- service: input_boolean.turn_on
|
|
||||||
target:
|
target:
|
||||||
entity_id: input_boolean.emma_ibuprofen
|
entity_id: input_boolean.emma_ibuprofen
|
||||||
- conditions: "{{ wait.trigger.id == 'ibuprofen-skipped' }}"
|
- service: script.text_notify
|
||||||
|
data:
|
||||||
|
who: >
|
||||||
|
{% if states('person.christina_stork') in ['Bob Evans','BobEvans'] %}
|
||||||
|
tony
|
||||||
|
{% else %}
|
||||||
|
parents
|
||||||
|
{% endif %}
|
||||||
|
type: alert
|
||||||
|
title: Emma Ibuprofen Time
|
||||||
|
message: It is time to give Emma her next dose of ibuprofen
|
||||||
|
tag: emma-ibuprofen
|
||||||
|
actions:
|
||||||
|
- action: "EMMA_IBUPROFEN_GIVEN"
|
||||||
|
name: Given
|
||||||
|
- action: "EMMA_IBUPROFEN_SKIPPED"
|
||||||
|
name: Skipped
|
||||||
|
- action: "EMMA_IBUPROFEN_ASK_LATER"
|
||||||
|
name: Ask Later
|
||||||
|
- wait_for_trigger:
|
||||||
|
- platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: "EMMA_IBUPROFEN_GIVEN"
|
||||||
|
id: ibuprofen-given
|
||||||
|
- platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: "EMMA_IBUPROFEN_SKIPPED"
|
||||||
|
id: ibuprofen-skipped
|
||||||
|
- platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: "EMMA_IBUPROFEN_ASK_LATER"
|
||||||
|
id: ibuprofen-ask-later
|
||||||
|
- platform: state
|
||||||
|
entity_id: input_boolean.emma_ibuprofen
|
||||||
|
from: 'off'
|
||||||
|
to: 'on'
|
||||||
|
id: ibuprofen-manual
|
||||||
|
- platform: state
|
||||||
|
entity_id: input_boolean.emma_alternating_meds_active
|
||||||
|
to: 'off'
|
||||||
|
id: cancel
|
||||||
|
timeout: "00:30:00"
|
||||||
|
continue_on_timeout: true
|
||||||
|
- choose:
|
||||||
|
- conditions: "{{ wait.trigger.id == 'ibuprofen-given' }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_boolean.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: input_boolean.emma_ibuprofen
|
||||||
|
- conditions: "{{ wait.trigger.id == 'ibuprofen-skipped' }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_ibuprofen_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(8) }}
|
||||||
|
- conditions: "{{ wait.trigger.id == 'ibuprofen-ask-later' }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_ibuprofen_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(0,30) }}
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_tylenol_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(4,30) }}
|
||||||
|
- conditions: "{{ wait.trigger == 'none' or wait.trigger.idx is undefined }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_ibuprofen_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(0,30) }}
|
||||||
|
- service: script.text_notify
|
||||||
|
data:
|
||||||
|
who: parents
|
||||||
|
type: alert
|
||||||
|
message: clear_notification
|
||||||
|
tag: emma-ibuprofen
|
||||||
|
- conditions: "{{ reason == 'ibuprofen-on' }}"
|
||||||
sequence:
|
sequence:
|
||||||
- service: input_datetime.set_datetime
|
- service: input_datetime.set_datetime
|
||||||
target:
|
target:
|
||||||
entity_id: input_datetime.emma_ibuprofen
|
entity_id: input_datetime.emma_ibuprofen
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(0) }}
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_ibuprofen_notify
|
||||||
data:
|
data:
|
||||||
datetime: >
|
datetime: >
|
||||||
{% from 'time.jinja' import set_datetime %}
|
{% from 'time.jinja' import set_datetime %}
|
||||||
{{ set_datetime(8) }}
|
{{ set_datetime(8) }}
|
||||||
- conditions: "{{ wait.trigger.id == 'ibuprofen-ask-later' or wait.trigger == 'none' or wait.trigger.idx is undefined }}"
|
|
||||||
sequence:
|
|
||||||
- service: input_datetime.set_datetime
|
- service: input_datetime.set_datetime
|
||||||
target:
|
target:
|
||||||
entity_id: input_datetime.emma_ibuprofen
|
entity_id: input_datetime.emma_tylenol_notify
|
||||||
data:
|
data:
|
||||||
datetime: >
|
datetime: >
|
||||||
{% from 'time.jinja' import set_datetime %}
|
{% from 'time.jinja' import set_datetime %}
|
||||||
{{ set_datetime(0,30) }}
|
{{ set_datetime(4) }}
|
||||||
- service: script.text_notify
|
|
||||||
data:
|
|
||||||
who: parents
|
|
||||||
type: alert
|
|
||||||
message: clear_notification
|
|
||||||
tag: emma-ibuprofen
|
|
||||||
|
|
||||||
emma_tylenol:
|
emma_tylenol:
|
||||||
alias: Emma Tylenol
|
alias: Emma Tylenol
|
||||||
icon: mdi:medical-bag
|
icon: mdi:medical-bag
|
||||||
mode: restart
|
mode: queued
|
||||||
|
max: 10
|
||||||
sequence:
|
sequence:
|
||||||
- service: input_boolean.turn_off
|
|
||||||
target:
|
|
||||||
entity_id: input_boolean.emma_tylenol
|
|
||||||
- service: script.text_notify
|
|
||||||
data:
|
|
||||||
who: >
|
|
||||||
{% if states('person.christina_stork') in ['Bob Evans','BobEvans'] %}
|
|
||||||
tony
|
|
||||||
{% else %}
|
|
||||||
parents
|
|
||||||
{% endif %}
|
|
||||||
type: alert
|
|
||||||
title: Emma Tylenol Time
|
|
||||||
message: It is time to give Emma her next dose of tylenol
|
|
||||||
tag: emma-tylenol
|
|
||||||
actions:
|
|
||||||
- action: "EMMA_TYLENOL_GIVEN"
|
|
||||||
name: Given
|
|
||||||
- action: "EMMA_TYLENOL_SKIPPED"
|
|
||||||
name: Skipped
|
|
||||||
- action: "EMMA_TYLENOL_ASK_LATER"
|
|
||||||
name: Ask Later
|
|
||||||
- wait_for_trigger:
|
|
||||||
- platform: event
|
|
||||||
event_type: ios.notification_action_fired
|
|
||||||
event_data:
|
|
||||||
actionName: "EMMA_TYLENOL_GIVEN"
|
|
||||||
id: tylenol-given
|
|
||||||
- platform: event
|
|
||||||
event_type: ios.notification_action_fired
|
|
||||||
event_data:
|
|
||||||
actionName: "EMMA_TYLENOL_SKIPPED"
|
|
||||||
id: tylenol-skipped
|
|
||||||
- platform: event
|
|
||||||
event_type: ios.notification_action_fired
|
|
||||||
event_data:
|
|
||||||
actionName: "EMMA_TYLENOL_ASK_LATER"
|
|
||||||
id: tylenol-ask-later
|
|
||||||
- platform: state
|
|
||||||
entity_id: input_boolean.emma_meds_active
|
|
||||||
to: 'off'
|
|
||||||
id: cancel
|
|
||||||
timeout: "00:30:00"
|
|
||||||
continue_on_timeout: true
|
|
||||||
- choose:
|
- choose:
|
||||||
- conditions: "{{ wait.trigger.id == 'tylenol-given' }}"
|
- conditions: "{{ reason == 'tylenol-notify' }}"
|
||||||
sequence:
|
sequence:
|
||||||
- service: input_datetime.set_datetime
|
- service: input_boolean.turn_off
|
||||||
target:
|
|
||||||
entity_id: input_datetime.emma_tylenol
|
|
||||||
data:
|
|
||||||
datetime: >
|
|
||||||
{% from 'time.jinja' import set_datetime %}
|
|
||||||
{{ set_datetime(8) }}
|
|
||||||
- service: input_boolean.turn_on
|
|
||||||
target:
|
target:
|
||||||
entity_id: input_boolean.emma_tylenol
|
entity_id: input_boolean.emma_tylenol
|
||||||
- conditions: "{{ wait.trigger.id == 'tylenol-skipped' }}"
|
- service: script.text_notify
|
||||||
|
data:
|
||||||
|
who: >
|
||||||
|
{% if states('person.christina_stork') in ['Bob Evans','BobEvans'] %}
|
||||||
|
tony
|
||||||
|
{% else %}
|
||||||
|
parents
|
||||||
|
{% endif %}
|
||||||
|
type: alert
|
||||||
|
title: Emma Tylenol Time
|
||||||
|
message: It is time to give Emma her next dose of tylenol
|
||||||
|
tag: emma-tylenol
|
||||||
|
actions:
|
||||||
|
- action: "EMMA_TYLENOL_GIVEN"
|
||||||
|
name: Given
|
||||||
|
- action: "EMMA_TYLENOL_SKIPPED"
|
||||||
|
name: Skipped
|
||||||
|
- action: "EMMA_TYLENOL_ASK_LATER"
|
||||||
|
name: Ask Later
|
||||||
|
- wait_for_trigger:
|
||||||
|
- platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: "EMMA_TYLENOL_GIVEN"
|
||||||
|
id: tylenol-given
|
||||||
|
- platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: "EMMA_TYLENOL_SKIPPED"
|
||||||
|
id: tylenol-skipped
|
||||||
|
- platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: "EMMA_TYLENOL_ASK_LATER"
|
||||||
|
id: tylenol-ask-later
|
||||||
|
- platform: state
|
||||||
|
entity_id: input_boolean.emma_tylenol
|
||||||
|
from: 'off'
|
||||||
|
to: 'on'
|
||||||
|
id: tylenol-manual
|
||||||
|
- platform: state
|
||||||
|
entity_id: input_boolean.emma_alternating_meds_active
|
||||||
|
to: 'off'
|
||||||
|
id: cancel
|
||||||
|
timeout: "00:30:00"
|
||||||
|
continue_on_timeout: true
|
||||||
|
- choose:
|
||||||
|
- conditions: "{{ wait.trigger.id == 'tylenol-given' }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_boolean.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: input_boolean.emma_tylenol
|
||||||
|
- conditions: "{{ wait.trigger.id == 'tylenol-skipped' }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_tylenol_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(8) }}
|
||||||
|
- conditions: "{{ wait.trigger.id == 'tylenol-ask-later' }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_tylenol_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(0,30) }}
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_ibuprofen_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(4,30) }}
|
||||||
|
- conditions: "{{ wait.trigger == 'none' or wait.trigger.idx is undefined }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_tylenol_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(0,30) }}
|
||||||
|
- service: script.text_notify
|
||||||
|
data:
|
||||||
|
who: parents
|
||||||
|
type: alert
|
||||||
|
message: clear_notification
|
||||||
|
tag: emma-tylenol
|
||||||
|
- conditions: "{{ reason == 'tylenol-on' }}"
|
||||||
sequence:
|
sequence:
|
||||||
- service: input_datetime.set_datetime
|
- service: input_datetime.set_datetime
|
||||||
target:
|
target:
|
||||||
entity_id: input_datetime.emma_tylenol
|
entity_id: input_datetime.emma_tylenol
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(0) }}
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_tylenol_notify
|
||||||
data:
|
data:
|
||||||
datetime: >
|
datetime: >
|
||||||
{% from 'time.jinja' import set_datetime %}
|
{% from 'time.jinja' import set_datetime %}
|
||||||
{{ set_datetime(8) }}
|
{{ set_datetime(8) }}
|
||||||
- conditions: "{{ wait.trigger.id == 'tylenol-ask-later' or wait.trigger == 'none' or wait.trigger.idx is undefined }}"
|
|
||||||
sequence:
|
|
||||||
- service: input_datetime.set_datetime
|
- service: input_datetime.set_datetime
|
||||||
target:
|
target:
|
||||||
entity_id: input_datetime.emma_tylenol
|
entity_id: input_datetime.emma_ibuprofen_notify
|
||||||
data:
|
data:
|
||||||
datetime: >
|
datetime: >
|
||||||
{% from 'time.jinja' import set_datetime %}
|
{% from 'time.jinja' import set_datetime %}
|
||||||
{{ set_datetime(0,30) }}
|
{{ set_datetime(4) }}
|
||||||
- service: script.text_notify
|
|
||||||
data:
|
emma_cough_meds:
|
||||||
who: parents
|
alias: Emma Cough Meds
|
||||||
type: alert
|
icon: mdi:medical-bag
|
||||||
message: clear_notification
|
mode: queued
|
||||||
tag: emma-tylenol
|
max: 10
|
||||||
|
sequence:
|
||||||
|
- choose:
|
||||||
|
- conditions: "{{ reason == 'cough-notify' }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_boolean.turn_off
|
||||||
|
target:
|
||||||
|
entity_id: input_boolean.emma_cough_meds
|
||||||
|
- service: script.text_notify
|
||||||
|
data:
|
||||||
|
who: >
|
||||||
|
{% if states('person.christina_stork') in ['Bob Evans','BobEvans'] %}
|
||||||
|
tony
|
||||||
|
{% else %}
|
||||||
|
parents
|
||||||
|
{% endif %}
|
||||||
|
type: alert
|
||||||
|
title: Emma Cough Meds Time
|
||||||
|
message: It is time to give Emma her next dose of cough meds
|
||||||
|
tag: emma-cough
|
||||||
|
actions:
|
||||||
|
- action: "EMMA_COUGH_GIVEN"
|
||||||
|
name: Given
|
||||||
|
- action: "EMMA_COUGH_SKIPPED"
|
||||||
|
name: Skipped
|
||||||
|
- action: "EMMA_COUGH_ASK_LATER"
|
||||||
|
name: Ask Later
|
||||||
|
- wait_for_trigger:
|
||||||
|
- platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: "EMMA_COUGH_GIVEN"
|
||||||
|
id: cough-given
|
||||||
|
- platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: "EMMA_COUGH_SKIPPED"
|
||||||
|
id: cough-skipped
|
||||||
|
- platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: "EMMA_COUGH_ASK_LATER"
|
||||||
|
id: cough-ask-later
|
||||||
|
- platform: state
|
||||||
|
entity_id: input_boolean.emma_cough_meds
|
||||||
|
from: 'off'
|
||||||
|
to: 'on'
|
||||||
|
id: cough-manual
|
||||||
|
- platform: state
|
||||||
|
entity_id: input_boolean.emma_cough_meds_active
|
||||||
|
to: 'off'
|
||||||
|
id: cancel
|
||||||
|
timeout: "00:30:00"
|
||||||
|
continue_on_timeout: true
|
||||||
|
- choose:
|
||||||
|
- conditions: "{{ wait.trigger.id == 'cough-given' }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_boolean.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: input_boolean.emma_cough_meds
|
||||||
|
- conditions: "{{ wait.trigger.id == 'cough-skipped' }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_cough_meds_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(4) }}
|
||||||
|
- conditions: "{{ wait.trigger.id == 'cough-ask-later' }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_cough_meds_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(0,30) }}
|
||||||
|
- conditions: "{{ wait.trigger == 'none' or wait.trigger.idx is undefined }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_cough_meds_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(0,30) }}
|
||||||
|
- service: script.text_notify
|
||||||
|
data:
|
||||||
|
who: parents
|
||||||
|
type: alert
|
||||||
|
message: clear_notification
|
||||||
|
tag: emma-cough
|
||||||
|
- conditions: "{{ reason == 'cough-on' }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_cough_meds
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(0) }}
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.emma_cough_meds_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(4) }}
|
||||||
|
|
||||||
emma_sleep:
|
emma_sleep:
|
||||||
alias: 'Emma Sleep'
|
alias: 'Emma Sleep'
|
||||||
|
Reference in New Issue
Block a user