Progress on my status macro

This commit is contained in:
2024-01-08 18:35:59 -05:00
parent 62f5d56476
commit 7936d2a8d8

View File

@ -115,19 +115,33 @@
{{ cleanup(data()) }} {{ cleanup(data()) }}
{% endmacro %} {% endmacro %}
{% macro twitchStreamInfo(type,method) %} {% macro tonyStatusReport(type,method) %}
{% if is_state('input_boolean.tony_streaming_today','on') or calendar_event_today('calendar.tony_s_twitch_schedule') == 'false' %} {% macro data() %}
{% if type == 'full' %}
{% if is_state('input_boolean.tony_awake','on') %}
Tony is awake.
{% else %}
Tony is asleep.
{% endif %}
{% endif %}
{% if type in ['stream','full'] %}
{% if type == 'stream' %}
{% set identTonyStream = 'Tony' %}
{% else %}
{% set identTonyStream = 'He' %}
{% endif %}
{% if is_state('input_boolean.tony_streaming_today','on') or calendar_event_today('calendar.tony_s_twitch_schedule') == 'false' %}
{% set streamstart = state_attr('input_datetime.tony_streaming_start_time','timestamp') | timestamp_custom('%-I:%M %p',false) %} {% set streamstart = state_attr('input_datetime.tony_streaming_start_time','timestamp') | timestamp_custom('%-I:%M %p',false) %}
{% elif calendar_event_today('calendar.tony_s_twitch_schedule') == 'true' %} {% elif calendar_event_today('calendar.tony_s_twitch_schedule') == 'true' %}
{% set streamstart = as_timestamp(state_attr('calendar.tony_s_twitch_schedule','start_time')) | int | timestamp_custom('%-I:%M %p') %} {% set streamstart = as_timestamp(state_attr('calendar.tony_s_twitch_schedule','start_time')) | int | timestamp_custom('%-I:%M %p') %}
{% endif %} {% endif %}
{% set game = state_attr('sensor.twitch_ironnerd24','game') %} {% set game = state_attr('sensor.twitch_ironnerd24','game') %}
{% set viewers = state_attr('sensor.twitch_ironnerd24','viewers') %} {% set viewers = state_attr('sensor.twitch_ironnerd24','viewers') %}
{% if is_state('sensor.twitch_ironnerd24','streaming') %} {% if is_state('sensor.twitch_ironnerd24','streaming') %}
Tony is currently streaming. The current stream category is {{ game }}. The current viewer count is {{ viewers }}. Iron Nerd Gaming is currently streaming {{ game }} to {{ viewers }} viewers.
{% elif is_state('input_boolean.tony_streaming_today','on') or calendar_event_today('calendar.tony_s_twitch_schedule') == 'true' %} {% elif is_state('input_boolean.tony_streaming_today','on') or calendar_event_today('calendar.tony_s_twitch_schedule') == 'true' %}
{% if method == 'tts' %} {% if method == 'tts' %}
Tony {{ identTonyStream }}
{{ [ {{ [
" will be pretending to be a real content creator tonight. ", " will be pretending to be a real content creator tonight. ",
" will be doing his best to defeat his impostor syndrome tonight. ", " will be doing his best to defeat his impostor syndrome tonight. ",
@ -136,27 +150,25 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
" is not really all that funny, but tonight he will present himself to a crowd of questionable individuals who seem to think that he is. " " is not really all that funny, but tonight he will present himself to a crowd of questionable individuals who seem to think that he is. "
] | random }} The studio is scheduled to go online at {{ streamstart }}. " ] | random }} The studio is scheduled to go online at {{ streamstart }}. "
{% elif method == 'text' %} {% elif method == 'text' %}
Tony will be streaming today. Stream starts at {{ streamstart }}. Iron Nerd Gaming will be live today at {{ streamstart }}.
{% endif %} {% endif %}
{% elif state_attr('calendar.tony_s_twitch_schedule','start_time') != none %} {% elif state_attr('calendar.tony_s_twitch_schedule','start_time') != none %}
{% if count_the_days('calendar.tony_s_twitch_schedule','start_time') | int == 1 %} {% if count_the_days('calendar.tony_s_twitch_schedule','start_time') | int == 1 %}
Tony will be streaming at {{ time_from_calendar('calendar.tony_s_twitch_schedule','start_time','read') }} tomorrow. Iron Nerd Gaming will be streaming at {{ time_from_calendar('calendar.tony_s_twitch_schedule','start_time','read') }} tomorrow.
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endmacro %} {% endif %}
{% if type in ['meds','full'] %}
{% macro tony_morning_meds(type,method) %} {% if type == 'meds' %}
{% set streamBlock = twitchStreamInfo(type,method) | trim == '' %} {% set identTonyMeds = 'Tony' %}
{% if type == 'meds' or streamBlock == true %} {% else %}
{% set identTony = 'Tony' %} {% set identTonyMeds = 'He' %}
{% else %} {% endif %}
{% set identTony = 'He' %} {% if is_state('binary_sensor.overnight','off') %}
{% endif %}
{% if is_state('binary_sensor.overnight','off') %}
{% if is_state('input_boolean.tony_morning_meds_taken','on') %} {% if is_state('input_boolean.tony_morning_meds_taken','on') %}
{{ identTony }} took his morning meds at {{ input_datetime_read('input_datetime.tony_morning_meds_taken') | trim }}. {{ identTonyMeds }} took his morning meds at {{ input_datetime_read('input_datetime.tony_morning_meds_taken') | trim }}.
{% elif is_state('input_boolean.tony_morning_meds_taken','off') and ct >= 21600 %} {% elif is_state('input_boolean.tony_morning_meds_taken','off') and is_state('input_boolean.tony_awake','on') %}
{{ identTony }} has not taken his morning meds. {{ identTonyMeds }} has not taken his morning meds.
{% if ct < state_attr('input_datetime.tony_morning_meds_notify','timestamp') | int %} {% if ct < state_attr('input_datetime.tony_morning_meds_notify','timestamp') | int %}
{% if method == 'tts' %} {% if method == 'tts' %}
{{ ['He has a reminder scheduled for', {{ ['He has a reminder scheduled for',
@ -169,21 +181,11 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endmacro %} {% if is_state('input_boolean.tony_afternoon_meds_taken','on') and is_state('input_boolean.tony_awake','on') %}
{{ identTonyMeds }} took his afternoon meds at {{ input_datetime_read('input_datetime.tony_afternoon_meds_taken') | trim }}.
{% macro tony_afternoon_meds(type,method) %} {% elif is_state('input_boolean.tony_afternoon_meds_taken','off') and ct >= 61200 %}
{% set streamBlock = twitchStreamInfo(type,method) | trim == '' %} {{ identTonyMeds }} has not taken his afternoon meds.
{% 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_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 ct < state_attr('input_datetime.tony_afternoon_meds_notify','timestamp') | int %}
{% if method == 'tts' %} {% if method == 'tts' %}
{{ ['He has a reminder scheduled for', {{ ['He has a reminder scheduled for',
@ -195,22 +197,11 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
He will be reminded at {{ input_datetime_read('input_datetime.tony_afternoon_meds_notify') | trim }}. He will be reminded at {{ input_datetime_read('input_datetime.tony_afternoon_meds_notify') | trim }}.
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endmacro %} {% if is_state('input_boolean.tony_night_meds_taken','on') and (is_state('binary_sensor.overnight','on') or ct < 43200) %}
{{ identTonyMeds }} took his night meds at {{ input_datetime_read('input_datetime.tony_night_meds_taken') | trim }}.
{% macro tony_night_meds(type,method) %} {% elif is_state('input_boolean.tony_night_meds_taken','off') and is_state('binary_sensor.overnight','on') %}
{% set streamBlock = twitchStreamInfo(type,method) | trim == '' %} {{ identTonyMeds }} has not taken his night meds.
{% 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) %}
{{ 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') %}
{{ identTony }} has not taken his night meds.
{% if method == 'tts' %} {% if method == 'tts' %}
{{ ['He will be reminded when he goes to bed.', {{ ['He will be reminded when he goes to bed.',
'I will make sure he is reminded when it is time.', 'I will make sure he is reminded when it is time.',
@ -220,26 +211,7 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{% else %} {% else %}
He will be reminded when he goes to bed. He will be reminded when he goes to bed.
{% endif %} {% endif %}
{% endif %}
{% endmacro %}
{% macro medReportTony(type,method) %}
{{ tony_morning_meds(type,method) }}
{{ tony_afternoon_meds(type,method) }}
{{ tony_night_meds(type,method) }}
{% endmacro %}
{% macro tonyStatusReport(type,method) %}
{% macro data() %}
{% if type == 'meds' %}
{{ medReportTony(type,method) }}
{% endif %} {% endif %}
{% if type == 'stream' %}
{{ twitchStreamInfo(type,method) }}
{% endif %}
{% if type == 'full' %}
{{ twitchStreamInfo(type,method) }}
{{ medReportTony(type,method) }}
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{{ cleanup(data()) }} {{ cleanup(data()) }}