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,131 +115,103 @@
{{ 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() %}
{% set streamstart = state_attr('input_datetime.tony_streaming_start_time','timestamp') | timestamp_custom('%-I:%M %p',false) %} {% if type == 'full' %}
{% elif calendar_event_today('calendar.tony_s_twitch_schedule') == 'true' %} {% if is_state('input_boolean.tony_awake','on') %}
{% set streamstart = as_timestamp(state_attr('calendar.tony_s_twitch_schedule','start_time')) | int | timestamp_custom('%-I:%M %p') %} Tony is awake.
{% endif %} {% else %}
{% set game = state_attr('sensor.twitch_ironnerd24','game') %} Tony is asleep.
{% set viewers = state_attr('sensor.twitch_ironnerd24','viewers') %} {% endif %}
{% if is_state('sensor.twitch_ironnerd24','streaming') %}
Tony is currently streaming. The current stream category is {{ game }}. The current viewer count is {{ viewers }}.
{% elif is_state('input_boolean.tony_streaming_today','on') or calendar_event_today('calendar.tony_s_twitch_schedule') == 'true' %}
{% if method == 'tts' %}
Tony
{{ [
" will be pretending to be a real content creator tonight. ",
" will be doing his best to defeat his impostor syndrome tonight. ",
" will be playing video games and yelling into a microphone tonight. ",
" will be scraping out the nickels and dimes tonight for the sake of entertainment. ",
" 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 }}. "
{% elif method == 'text' %}
Tony will be streaming today. Stream starts at {{ streamstart }}.
{% endif %} {% endif %}
{% elif state_attr('calendar.tony_s_twitch_schedule','start_time') != none %} {% if type in ['stream','full'] %}
{% if count_the_days('calendar.tony_s_twitch_schedule','start_time') | int == 1 %} {% if type == 'stream' %}
Tony will be streaming at {{ time_from_calendar('calendar.tony_s_twitch_schedule','start_time','read') }} tomorrow. {% set identTonyStream = 'Tony' %}
{% endif %} {% else %}
{% endif %} {% set identTonyStream = 'He' %}
{% endmacro %} {% endif %}
{% if is_state('input_boolean.tony_streaming_today','on') or calendar_event_today('calendar.tony_s_twitch_schedule') == 'false' %}
{% macro tony_morning_meds(type,method) %} {% set streamstart = state_attr('input_datetime.tony_streaming_start_time','timestamp') | timestamp_custom('%-I:%M %p',false) %}
{% set streamBlock = twitchStreamInfo(type,method) | trim == '' %} {% elif calendar_event_today('calendar.tony_s_twitch_schedule') == 'true' %}
{% if type == 'meds' or streamBlock == true %} {% set streamstart = as_timestamp(state_attr('calendar.tony_s_twitch_schedule','start_time')) | int | timestamp_custom('%-I:%M %p') %}
{% set identTony = 'Tony' %} {% endif %}
{% else %} {% set game = state_attr('sensor.twitch_ironnerd24','game') %}
{% set identTony = 'He' %} {% set viewers = state_attr('sensor.twitch_ironnerd24','viewers') %}
{% endif %} {% if is_state('sensor.twitch_ironnerd24','streaming') %}
{% if is_state('binary_sensor.overnight','off') %} Iron Nerd Gaming is currently streaming {{ game }} to {{ viewers }} viewers.
{% if is_state('input_boolean.tony_morning_meds_taken','on') %} {% elif is_state('input_boolean.tony_streaming_today','on') or calendar_event_today('calendar.tony_s_twitch_schedule') == 'true' %}
{{ identTony }} 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 %}
{{ identTony }} has not taken his morning meds.
{% if ct < state_attr('input_datetime.tony_morning_meds_notify','timestamp') | int %}
{% if method == 'tts' %} {% if method == 'tts' %}
{{ ['He has a reminder scheduled for', {{ identTonyStream }}
'Rest assured that I will pester him mercilessly about this, starting at', {{ [
'This is absolutely essential, and I will remind him to do it at', " will be pretending to be a real content creator tonight. ",
'Since nobody including Tony himself likes him without his meds, I will remind him at', " will be doing his best to defeat his impostor syndrome tonight. ",
] | random }} {{ input_datetime_read('input_datetime.tony_morning_meds_notify') | trim }}. " will be playing video games and yelling into a microphone tonight. ",
{% else %} " will be scraping out the nickels and dimes tonight for the sake of entertainment. ",
He will be reminded at {{ input_datetime_read('input_datetime.tony_morning_meds_notify') | trim }}. " 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 }}. "
{% elif method == 'text' %}
Iron Nerd Gaming will be live today at {{ streamstart }}.
{% endif %}
{% elif state_attr('calendar.tony_s_twitch_schedule','start_time') != none %}
{% if count_the_days('calendar.tony_s_twitch_schedule','start_time') | int == 1 %}
Iron Nerd Gaming will be streaming at {{ time_from_calendar('calendar.tony_s_twitch_schedule','start_time','read') }} tomorrow.
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %} {% if type in ['meds','full'] %}
{% endmacro %} {% if type == 'meds' %}
{% set identTonyMeds = 'Tony' %}
{% macro tony_afternoon_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_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 method == 'tts' %}
{{ ['He has a reminder scheduled for',
'Rest assured that I will pester him mercilessly about this, starting at',
'This is absolutely essential, and I will remind him to do it at',
'Since nobody including Tony himself likes him without his meds, I will remind him at',
] | random }} {{ input_datetime_read('input_datetime.tony_afternoon_meds_notify') | trim }}.
{% else %} {% else %}
He will be reminded at {{ input_datetime_read('input_datetime.tony_afternoon_meds_notify') | trim }}. {% set identTonyMeds = 'He' %}
{% endif %}
{% if is_state('binary_sensor.overnight','off') %}
{% if is_state('input_boolean.tony_morning_meds_taken','on') %}
{{ 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 is_state('input_boolean.tony_awake','on') %}
{{ identTonyMeds }} 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',
'Rest assured that I will pester him mercilessly about this, starting at',
'This is absolutely essential, and I will remind him to do it at',
'Since nobody including Tony himself likes him without his meds, I will remind him at',
] | random }} {{ input_datetime_read('input_datetime.tony_morning_meds_notify') | trim }}.
{% else %}
He will be reminded at {{ input_datetime_read('input_datetime.tony_morning_meds_notify') | trim }}.
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% 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 }}.
{% elif is_state('input_boolean.tony_afternoon_meds_taken','off') and ct >= 61200 %}
{{ identTonyMeds }} has not taken his afternoon meds.
{% if ct < state_attr('input_datetime.tony_afternoon_meds_notify','timestamp') | int %}
{% if method == 'tts' %}
{{ ['He has a reminder scheduled for',
'Rest assured that I will pester him mercilessly about this, starting at',
'This is absolutely essential, and I will remind him to do it at',
'Since nobody including Tony himself likes him without his meds, I will remind him at',
] | random }} {{ input_datetime_read('input_datetime.tony_afternoon_meds_notify') | trim }}.
{% else %}
He will be reminded at {{ input_datetime_read('input_datetime.tony_afternoon_meds_notify') | trim }}.
{% endif %}
{% endif %}
{% endif %}
{% 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 }}.
{% elif is_state('input_boolean.tony_night_meds_taken','off') and is_state('binary_sensor.overnight','on') %}
{{ identTonyMeds }} 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.',
'This will be rectified whenever he drags his ass to bed.',
'All in due time, of course.'
] | random }}
{% else %}
He will be reminded when he goes to bed.
{% endif %}
{% endif %} {% endif %}
{% endif %}
{% endif %}
{% endmacro %}
{% macro tony_night_meds(type,method) %}
{% set streamBlock = twitchStreamInfo(type,method) | trim == '' %}
{% 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' %}
{{ ['He will be reminded when he goes to bed.',
'I will make sure he is reminded when it is time.',
'This will be rectified whenever he drags his ass to bed.',
'All in due time, of course.'
] | random }}
{% else %}
He will be reminded when he goes to bed.
{% 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 %}
{% if type == 'stream' %}
{{ twitchStreamInfo(type,method) }}
{% endif %}
{% if type == 'full' %}
{{ twitchStreamInfo(type,method) }}
{{ medReportTony(type,method) }}
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{{ cleanup(data()) }} {{ cleanup(data()) }}