Tweaks to E's med tracker involving sleep/wake times #130
This commit is contained in:
@ -506,7 +506,7 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
|
||||
{{ cleanup(data()) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro emma_sleep(type,method) %}
|
||||
{% macro emmaSleep(type,method) %}
|
||||
{% set asleep = state_attr('input_datetime.emma_down_for_nap','timestamp') | int %}
|
||||
{% set wakeup = state_attr('input_datetime.emma_up_from_nap','timestamp') | int %}
|
||||
{% set day = now().strftime("%-d") %}
|
||||
@ -553,34 +553,41 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
|
||||
{% 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 type == 'meds' %}
|
||||
{% set identEmma = 'Emma' %}
|
||||
{% else %}
|
||||
{% set identEmma = 'She' %}
|
||||
{% endif %}
|
||||
{% 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.
|
||||
{{ identEmma }} has not taken her ibuprofen, tylenol, or cough meds.
|
||||
{% elif (is_state('input_boolean.emma_alternating_meds_active','on') or is_state('input_boolean.emma_cough_meds_active','on')) and is_state('input_boolean.emma_sleeping','on') %}
|
||||
Med tracking is paused during sleep.
|
||||
{% 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.
|
||||
{{ identEmma }} 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 }}.
|
||||
{{ identEmma }} 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.
|
||||
{{ identEmma }} 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 }}.
|
||||
{{ identEmma }} 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.
|
||||
{{ identEmma }} 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 }}.
|
||||
{{ identEmma }} 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.
|
||||
{{ identEmma }} has not taken her cough meds.
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
@ -589,11 +596,11 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
|
||||
{% macro emmaStatusReport(type,method) %}
|
||||
{% macro data() %}
|
||||
{% if type == 'sleep' %}
|
||||
{{ emma_sleep(type,method) }}
|
||||
{{ emmaSleep(type,method) }}
|
||||
{% elif type == 'meds' %}
|
||||
{{ medReportEmma(type,method) }}
|
||||
{% elif type == 'full' %}
|
||||
{{ emma_sleep(type,method) }}
|
||||
{{ emmaSleep(type,method) }}
|
||||
{{ medReportEmma(type,method) }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
@ -556,13 +556,13 @@ script:
|
||||
icon: mdi:medical-bag
|
||||
mode: queued
|
||||
max: 10
|
||||
sequence:
|
||||
- choose:
|
||||
- conditions: "{{ reason == 'ibuprofen-notify' and is_state('input_boolean.emma_sleeping','off') }}"
|
||||
sequence:
|
||||
- service: input_boolean.turn_off
|
||||
target:
|
||||
entity_id: input_boolean.emma_ibuprofen
|
||||
- choose:
|
||||
- conditions: "{{ reason == 'ibuprofen-notify' and is_state('input_boolean.emma_sleeping','off') }}"
|
||||
sequence:
|
||||
- service: script.text_notify
|
||||
data:
|
||||
who: >
|
||||
@ -685,13 +685,13 @@ script:
|
||||
icon: mdi:medical-bag
|
||||
mode: queued
|
||||
max: 10
|
||||
sequence:
|
||||
- choose:
|
||||
- conditions: "{{ reason == 'tylenol-notify' and is_state('input_boolean.emma_sleeping','off') }}"
|
||||
sequence:
|
||||
- service: input_boolean.turn_off
|
||||
target:
|
||||
entity_id: input_boolean.emma_tylenol
|
||||
- choose:
|
||||
- conditions: "{{ reason == 'tylenol-notify' and is_state('input_boolean.emma_sleeping','off') }}"
|
||||
sequence:
|
||||
- service: script.text_notify
|
||||
data:
|
||||
who: >
|
||||
@ -813,13 +813,13 @@ script:
|
||||
icon: mdi:medical-bag
|
||||
mode: queued
|
||||
max: 10
|
||||
sequence:
|
||||
- choose:
|
||||
- conditions: "{{ reason == 'cough-notify' and is_state('input_boolean.emma_sleeping','off') }}"
|
||||
sequence:
|
||||
- service: input_boolean.turn_off
|
||||
target:
|
||||
entity_id: input_boolean.emma_cough_meds
|
||||
- choose:
|
||||
- conditions: "{{ reason == 'cough-notify' and is_state('input_boolean.emma_sleeping','off') }}"
|
||||
sequence:
|
||||
- service: script.text_notify
|
||||
data:
|
||||
who: >
|
||||
@ -933,6 +933,13 @@ script:
|
||||
before: '16:00:00'
|
||||
then:
|
||||
- service: script.emma_bedroom_scheduling_evening
|
||||
# Meds
|
||||
- service: script.turn_off
|
||||
target:
|
||||
entity_id:
|
||||
- script.emma_ibuprofen
|
||||
- script.emma_tylenol
|
||||
- script.emma_cough_meds
|
||||
# Lighting
|
||||
- choose:
|
||||
- conditions:
|
||||
@ -1066,7 +1073,7 @@ script:
|
||||
data:
|
||||
datetime: >
|
||||
{% from 'time.jinja' import set_datetime %}
|
||||
{{ set_datetime(0,1) }}
|
||||
{{ set_datetime(0,5) }}
|
||||
- if:
|
||||
- condition: state
|
||||
entity_id: binary_sensor.basement_occupied
|
||||
|
Reference in New Issue
Block a user