Tweaks to E's med tracker involving sleep/wake times #130

This commit is contained in:
2023-09-19 12:57:11 -04:00
parent 5997f2b3ae
commit 430df31d6d
2 changed files with 35 additions and 21 deletions

View File

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