Messing with a new way of dealing with variable identification #97

This commit is contained in:
2023-08-28 12:20:09 -04:00
parent 3214c1c460
commit 8ee86c1e90

View File

@ -106,11 +106,16 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{% macro tony_morning_meds(type,method) %}
{% set streamBlock = twitchStreamInfo(type,method) | trim == '' %}
{% if type == 'meds' or streamBlock == true %}
{% set identTony = 'Tony' %}
{% else %}
{% set identTony = 'He' %}
{% endif %}
{% if is_state('binary_sensor.overnight','off') %}
{% if is_state('input_boolean.tony_morning_meds_taken','on') %}
{% if type == 'meds' or streamBlock == true %}Tony{% else %}He{% endif %} took his morning meds at {{ input_datetime_read('input_datetime.tony_morning_meds_taken','withdate') | trim }}.
{{ identTony }} took his morning meds at {{ input_datetime_read('input_datetime.tony_morning_meds_taken','withdate') | trim }}.
{% elif is_state('input_boolean.tony_morning_meds_taken','off') and ct >= 21600 %}
{% if type == 'meds' or streamBlock == true %}Tony{% else %}He{% endif %} has not taken his morning meds.
{{ identTony }} has not taken his morning meds.
{% if ct < state_attr('input_datetime.tony_morning_meds_notify','timestamp') | int %}
{% if method == 'tts' %}
{{ ['He has a reminder scheduled for',
@ -129,10 +134,15 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{% macro tony_night_meds(type,method) %}
{% set streamBlock = twitchStreamInfo(type,method) | trim == '' %}
{% set morningBlock = tony_morning_meds(type,method) | trim != '' %}
{% if type == 'meds' or streamBlock == true or morningBlock == 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 type == 'meds' or streamBlock == true or morningBlock == true %}Tony{% else %}He{% endif %} took his night meds at {{ input_datetime_read('input_datetime.tony_night_meds_taken','withdate') | trim }}.
{{ identTony }} took his night meds at {{ input_datetime_read('input_datetime.tony_night_meds_taken','withdate') | trim }}.
{% elif is_state('input_boolean.tony_night_meds_taken','off') and is_state('binary_sensor.overnight','on') %}
{% if type == 'meds' or streamBlock == true or morningBlock == true %}Tony{% else %}He{% endif %} has not taken his night meds.
{{ identTony }} has not taken his night meds.
{% if method == 'tts' %}
{{ ['He will be reminded when he goes to bed.',
'I will make sure he is reminded when it is time.',
@ -294,11 +304,16 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{% else %}
{% set bedtime = state_attr('input_datetime.kallen_bedtime','timestamp') | int - 900 %}
{% endif %}
{% if type == 'meds' %}
{% set identKallen = 'Kallen' %}
{% else %}
{% set identKallen = 'He' %}
{% endif %}
{% if wakeup <= ct <= bedtime %}
{% if is_state('input_boolean.kallen_morning_meds_taken','on') %}
{% if type == 'meds' %}Kallen{% else %}He{% endif %} took his morning meds at {{ input_datetime_read('input_datetime.kallen_morning_meds_taken','withdate') | trim }}.
{{ identKallen }} took his morning meds at {{ input_datetime_read('input_datetime.kallen_morning_meds_taken','withdate') | trim }}.
{% else %}
{% if type == 'meds' %}Kallen{% else %}He{% endif %} has not taken his morning meds.
{{ identKallen }} has not taken his morning meds.
{% if ct < state_attr('input_datetime.kallen_morning_meds_notify','timestamp') | int %}
{{ ['He has a reminder scheduled for',
'Rest assured that I will pester him mercilessly about this, starting at',
@ -317,13 +332,18 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{% set bedtime = state_attr('input_datetime.kallen_bedtime','timestamp') | int - 900 %}
{% endif %}
{% set diff = bedtime - ct %}
{% if type == 'meds' %}
{% set identKallen = 'Kallen' %}
{% else %}
{% set identKallen = 'He' %}
{% endif %}
{% if is_state('input_boolean.kallen_night_meds_taken','on') %}
{% if (ct >= bedtime) or (ct < wakeup) %}
{% if type == 'meds' %}Kallen{% else %}He{% endif %} took his night meds at {{ input_datetime_read('input_datetime.kallen_night_meds_taken','withdate') | trim }}.
{{ identKallen }} took his night meds at {{ input_datetime_read('input_datetime.kallen_night_meds_taken','withdate') | trim }}.
{% endif %}
{% else %}
{% if diff <= 3600 %}
{% if type == 'meds' %}Kallen{% else %}He{% endif %} has not taken his night meds.
{{ identKallen }} has not taken his night meds.
{% if method == 'tts' %}
{{ ['He will be reminded when he goes to bed.',
'I will make sure he is reminded when it is time.',
@ -336,7 +356,12 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{% macro medReportKallen(type,method) %}
{% if is_state('input_boolean.kallen_overnight','on') %}
{% if type == 'meds' %}Kallen{% else %}He{% endif %} is staying elsewhere overnight, so no med tracking is available.
{% if type == 'meds' %}
{% set identKallen = 'Kallen' %}
{% else %}
{% set identKallen = 'He' %}
{% endif %}
{{ identKallen }} is staying elsewhere overnight, so no med tracking is available.
{% else %}
{{ kallen_morning_meds(type,method) }}
{{ kallen_night_meds(type,method) }}
@ -413,12 +438,17 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
Today is the first day of Summer Break!
{%- endif %}
{% elif method == 'text' %}
{% if type == 'school' %}
{% set identKallen = 'Kallen' %}
{% else %}
{% set identKallen = 'He' %}
{% endif %}
{% if is_state('input_boolean.school_in_session','on') %}
{% if is_state('input_boolean.kallen_school_today','on') %}
{% if is_state('input_boolean.two_hour_delay','on') %}
School is currently under a two hour delay.
{% elif is_state('input_boolean.kallen_at_school','on') %}
{% if type == 'school' %}Kallen{% else %}He{% endif %} is at school right now.
{{ identKallen }} is at school right now.
{% if is_state('input_boolean.kallen_alternate_pickup','on') %}
{{ states('input_text.kallen_pickup') }} will be picking him up from school today.
{% elif is_state('input_boolean.kallen_school_early_release','on') %}
@ -427,16 +457,18 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
His pickup time is {{ input_datetime_read('input_datetime.kallen_school_day_end') | trim }}.
{% endif %}
{% else %}
{% if type == 'school' %}Kallen{% else %}He{% endif %} has school at {{ input_datetime_read('input_datetime.kallen_school_day_start') | trim }} today.
{{ identKallen }} has school at {{ input_datetime_read('input_datetime.kallen_school_day_start') | trim }} today.
{% endif %}
{% elif is_state('input_boolean.school_cancelled','on') %}
School is cancelled today.
{% elif is_state('input_boolean.kallen_school_today_extended','on') and is_state('input_boolean.kallen_school_today','off') %}
{% if (ct > wakeup) and (ct < bedtime) %}
{% if type == 'school' %}Kallen{% else %}He{% endif %} has finished his school day.
{{ identKallen }} has finished his school day.
{% endif %}
{% else %}
{% if type == 'school' %}Kallen{% else %}He{% endif %} does not have school today.
{% elif is_state ('binary_sensor.early_night_mode','on') and is_state('binary_sensor.kallen_school_tomorrow','on') %}
{{ identKallen }} has school tomorrow.
{% elif is_state('binary_sensor.after_midnight','off') %}
{{ identKallen }} does not have school today.
{% endif %}
{% endif %}
{% endif %}