694 lines
33 KiB
Django/Jinja
694 lines
33 KiB
Django/Jinja
{% from 'formatting.jinja' import cleanup %}
|
|
{% from 'time.jinja' import input_datetime_read, ct, next_twitch_stream, calendar_event_today, time_from_calendar %}
|
|
{% from 'easy_time.jinja' import count_the_days, custom_time, custom_time_between, clock %}
|
|
{% from 'lighting.jinja' import lights_on %}
|
|
{% set ct = ct() | int %}
|
|
{% set workTodayRan = is_state('input_boolean.work_today_ran','on') %}
|
|
{% set schoolTodayRan = is_state('input_boolean.school_today_ran','on') %}
|
|
{% set kallenMorningRan = is_state('input_boolean.kallen_scheduling_morning_ran','on') %}
|
|
{% set houseMorningRan = is_state('input_boolean.house_scheduling_morning_ran','on') %}
|
|
{% set emmaMorningRan = is_state('input_boolean.emma_scheduling_morning_ran','on') %}
|
|
{% set masterBedroomMorningRan = is_state('input_boolean.master_bedroom_scheduling_morning','on') %}
|
|
{% set kallenEveningRan = is_state('input_boolean.kallen_scheduling_evening_ran','on') %}
|
|
{% set houseEveningRan = is_state('input_boolean.house_scheduling_evening_ran','on') %}
|
|
{% set masterBedroomEveningRan = is_state('input_boolean.master_bedroom_scheduling_evening_ran','on') %}
|
|
{% set emmaEveningRan = is_state('input_boolean.emma_scheduling_evening_ran','on') %}
|
|
{% set kallenMorningAnnc = is_state('input_boolean.kallen_morning_announcements','on') %}
|
|
{% set kallenText = 'Kallen' %}
|
|
{% set kallenTTS = 'Collin' %}
|
|
|
|
{% macro morning_annc(type,method) %}
|
|
{% if method == 'text' %}
|
|
{% set identKallen = kallenText %}
|
|
{% elif method == 'tts' %}
|
|
{% set identKallen = kallenTTS %}
|
|
{% endif %}
|
|
{% if kallenMorningAnnc %}
|
|
First things first, we have some announcements for {{ identKallen }}. {{ states('input_text.kallen_morning_announcements') }}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro laundry_report(type,method) %}
|
|
{% macro data() %}
|
|
{% set washerTimer = states('timer.washer_timer') %}
|
|
{% set dryerTimer = states('timer.dryer_timer') %}
|
|
{% set washerFinished = states('input_boolean.washer_finished') %}
|
|
{% set dryerFinished = states('input_boolean.dryer_finished') %}
|
|
{% set washerDateTime = 'input_datetime.washer_finished' %}
|
|
{% set dryerDateTime = 'input_datetime.dryer_finished' %}
|
|
{% set w = state_attr('timer.washer_timer','finishes_at') %}
|
|
{% set d = state_attr('timer.dryer_timer','finishes_at') %}
|
|
{% set wH = 0 if w == none else (as_datetime(w) - now()).total_seconds() | timestamp_custom('%H', false) | int %}
|
|
{% set dH = 0 if d == none else (as_datetime(d) - now()).total_seconds() | timestamp_custom('%H', false) | int %}
|
|
{% set wM = 0 if w == none else (as_datetime(w) - now()).total_seconds() | timestamp_custom('%M', false) | int %}
|
|
{% set dM = 0 if d == none else (as_datetime(d) - now()).total_seconds() | timestamp_custom('%M', false) | int %}
|
|
{% if wH > 0 %}
|
|
{% set washerStr = wH ~ ' hour and ' ~ wM ~ ' minutes' %}
|
|
{% else %}
|
|
{% set washerStr = wM ~ ' minutes' %}
|
|
{% endif %}
|
|
{% if dH > 0 %}
|
|
{% set dryerStr = dH ~ ' hour and ' ~ dM ~ ' minutes' %}
|
|
{% else %}
|
|
{% set dryerStr = dM ~ ' minutes' %}
|
|
{% endif %}
|
|
{% if washerTimer == 'active' and dryerTimer == 'active' %}
|
|
The washer and dryer are both running. The washer finishes in {{ washerStr }}. The dryer finishes in {{ dryerStr }}.
|
|
{% elif washerTimer == 'active' %}
|
|
The washer is running. It will finish in {{ washerStr }}.
|
|
{% elif dryerTimer == 'active' %}
|
|
The dryer is running. It will finish in {{ dryerStr }}.
|
|
{% endif %}
|
|
{% if washerFinished == 'on' %}
|
|
The washer finished its cycle at {{ input_datetime_read(washerDateTime) | trim }}.
|
|
{% endif %}
|
|
{% if dryerFinished == 'on' %}
|
|
The dryer finished its cycle at {{ input_datetime_read(dryerDateTime) | trim }}.
|
|
{% endif %}
|
|
{% endmacro %}
|
|
{{ cleanup(data()) }}
|
|
{% endmacro %}
|
|
|
|
{% macro climate_devices(type,method) %}
|
|
{% set total = states('sensor.climate_devices_running') | int %}
|
|
{% set fans = states('sensor.fans_running') | int %}
|
|
{% set aircons = states('sensor.aircons_running') | int %}
|
|
{% if total > 0 %}
|
|
{% if fans > 0 and aircons > 0 %}
|
|
There are currently {{ fans }} {% if fans > 1 %}fans {% else %}fan {% endif %}running and {{ aircons }} {% if aircons > 1 %}air conditioners {% else %}air conditioner {%endif%}running.
|
|
{% else %}
|
|
{% if fans > 0 %}
|
|
There {% if fans > 1 %}are {% else %}is {% endif %}{{ fans }} {% if fans > 1 %}fans {% else %}fan {% endif %}running.
|
|
{% endif %}
|
|
{% if aircons > 0 %}
|
|
There {% if aircons > 1 %}are {% else %}is {% endif %}{{ aircons }} {% if aircons > 1 %}air conditioners {% else %}air conditioner {% endif %}running.
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro air_leaks(type,method) %}
|
|
{% set windows = states('sensor.windows_open') %}
|
|
{% set doors = states('sensor.doors_open') %}
|
|
{% if states('sensor.air_leaks') > '0' %}
|
|
{% if method == 'tts' %}
|
|
{% if type == 'full' %}
|
|
{% if states('sensor.air_leaks') > '0' %}
|
|
"Additionally, "
|
|
{% if windows > '0' and doors > '0' %}
|
|
"There are currently {{ states('sensor.windows_open') }} {% if windows == '1' %}window {% else %}windows {% endif %}and {{ states('sensor.doors_open') }} {% if doors == '1' %}door {% else %}doors {% endif %}open. "
|
|
{% else %}
|
|
{% if windows > '0' %}
|
|
"There {% if windows == '1' %}is {% else %}are {% endif %}currently {{ states('sensor.windows_open') }} {% if windows == '1' %}window {% else %}windows {% endif %}open. "
|
|
{% endif %}
|
|
{% if doors > '0' %}
|
|
"There {% if doors == '1' %}is {% else %}are {% endif %}currently {{ states('sensor.doors_open') }} {% if doors == '1' %}door {% else %}doors {% endif %}open. "
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% elif method == 'text' %}
|
|
{% if windows > '0' and doors > '0' %}
|
|
There are currently {{ states('sensor.windows_open') }} {% if windows == '1' %}window {% else %}windows {% endif %}and {{ states('sensor.doors_open') }} {% if doors == '1' %}door {% else %}doors {% endif %}open.
|
|
{% else %}
|
|
{% if windows > '0' %}
|
|
There {% if windows == '1' %}is {% else %}are {% endif %}currently {{ states('sensor.windows_open') }} {% if windows == '1' %}window {% else %}windows {% endif %}open.
|
|
{% endif %}
|
|
{% if doors > '0' %}
|
|
There {% if doors == '1' %}is {% else %}are {% endif %}currently {{ states('sensor.doors_open') }} {% if doors == '1' %}door {% else %}doors {% endif %}open.
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro house_status_report(type,method) %}
|
|
{% macro data() %}
|
|
{% if type == 'climate_devices' %}
|
|
{{ climate_devices(type,method) }}
|
|
{% elif type == 'air_leaks' %}
|
|
{{ air_leaks(type,method) }}
|
|
{% elif type == 'lights' %}
|
|
{{ lights_on(type,method) }}
|
|
{% elif type == 'full' %}
|
|
{{ climate_devices(type,method) }}
|
|
{{ lights_on(type,method) }}
|
|
{{ air_leaks(type,method) }}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
{{ cleanup(data()) }}
|
|
{% endmacro %}
|
|
|
|
{% macro tony_status_report(type,method) %}
|
|
{% 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 identTony = 'Tony' %}
|
|
{% else %}
|
|
{% set identTony = '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) %}
|
|
{% 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') %}
|
|
{% endif %}
|
|
{% set game = state_attr('sensor.twitch_ironnerd24','game') %}
|
|
{% set viewers = state_attr('sensor.twitch_ironnerd24','viewers') %}
|
|
{% if is_state('sensor.twitch_ironnerd24','streaming') %}
|
|
{{ identTony }} is currently streaming {{ game }} to {{ viewers }} viewers.
|
|
{% set identTony = 'He' %}
|
|
{% elif is_state('input_boolean.tony_streaming_today','on') or calendar_event_today('calendar.tony_s_twitch_schedule') == 'true' %}
|
|
{% if method == 'tts' %}
|
|
{{ identTony }}
|
|
{{ [
|
|
" 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' %}
|
|
{{ identTony }} will be live today at {{ streamstart }}.
|
|
{% endif %}
|
|
{% set identTony = 'He' %}
|
|
{% else %}
|
|
{% set identTony = 'Tony' %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if type in ['meds','full'] %}
|
|
{% if type == 'meds' %}
|
|
{% set identTony = 'Tony' %}
|
|
{% else %}
|
|
{% set identTony = 'He' %}
|
|
{% endif %}
|
|
{% set morningNotifyTimestamp = state_attr('input_datetime.tony_morning_meds_notify','timestamp') | int %}
|
|
{% if is_state('binary_sensor.overnight','off') and is_state('input_boolean.tony_awake','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 }}.
|
|
{% elif is_state('input_boolean.tony_morning_meds_taken','off') %}
|
|
{{ identTony }} has not taken his morning meds.
|
|
{% if ct < morningNotifyTimestamp %}
|
|
{% 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 %}
|
|
{% set identTony = 'He' %}
|
|
{% else %}
|
|
{% set identTony = 'Tony' %}
|
|
{% endif %}
|
|
{% set afternoonNotifyTimestamp = state_attr('input_datetime.tony_afternoon_meds_notify','timestamp') | int %}
|
|
{% 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 (0 < (afternoonNotifyTimestamp - ct) < 3600 or ct > afternoonNotifyTimestamp) %}
|
|
{{ identTony }} has not taken his afternoon meds.
|
|
{% if ct < afternoonNotifyTimestamp %}
|
|
{% 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 %}
|
|
{% set identTony = 'He' %}
|
|
{% else %}
|
|
{% set identTony = 'Tony' %}
|
|
{% endif %}
|
|
{% if is_state('input_boolean.tony_night_meds_taken','on') and (is_state('input_boolean.tony_awake','off') or is_state('input_boolean.night_mode','on')) %}
|
|
{{ 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('input_boolean.night_mode','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 %}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
{{ cleanup(data()) }}
|
|
{% endmacro %}
|
|
|
|
{% macro tina_morning_meds(type,method) %}
|
|
{% if is_state('binary_sensor.overnight','off') %}
|
|
{% if is_state('input_boolean.tina_morning_meds_taken','on') %}
|
|
Tina took her morning meds at {{ input_datetime_read('input_datetime.tina_morning_meds_taken') | trim }}.
|
|
{% elif is_state('input_boolean.tina_morning_meds_taken','off') and is_state('binary_sensor.after_midnight','off') %}
|
|
Tina has not taken her morning meds.
|
|
{% if ct < state_attr('input_datetime.tina_morning_meds_notify','timestamp') | int %}
|
|
{% if method == 'tts' %}
|
|
{{ ['She has a reminder scheduled for',
|
|
'Rest assured that I will pester her mercilessly about this, starting at',
|
|
'This is absolutely essential, and I will remind her to do it at',
|
|
'Her blood pressure is very important, so I will remind her at',
|
|
] | random }} {{ input_datetime_read('input_datetime.tina_morning_meds_notify') | trim }}.
|
|
{% else %}
|
|
She will be reminded at {{ input_datetime_read('input_datetime.tina_morning_meds_notify') | trim }}.
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro tina_night_meds(type,method) %}
|
|
{% if is_state('input_boolean.tina_night_meds_taken','on') and (is_state('binary_sensor.overnight','on') or ct < 43200) %}
|
|
Tina took her night meds at {{ input_datetime_read('input_datetime.tina_night_meds_taken') | trim }}.
|
|
{% elif is_state('input_boolean.tina_night_meds_taken','off') and is_state('binary_sensor.overnight','on') %}
|
|
Tina has not taken her night meds.
|
|
{% if method == 'tts' %}
|
|
{{ ['She will be reminded when she goes to bed.',
|
|
'I will make sure she is reminded when it is time.',
|
|
'All in due time, of course.'
|
|
] | random }}
|
|
{% else %}
|
|
She will be reminded when she goes to bed.
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro work_report_tina(type,method) %}
|
|
{% set tina = states.person.christina_stork.state %}
|
|
{% set start = (state_attr('binary_sensor.tina_work_tomorrow','start_timestamp') | int) // 1000 %}
|
|
{% set tmrw = (as_timestamp(states('sensor.date')) + 86400) | int %}
|
|
{% set diff = (start - tmrw) %}
|
|
{% if method == 'tts' %}
|
|
{% if is_state('input_boolean.work_today','on') and tina in ['Bob Evans','BobEvans'] %}
|
|
{{ [
|
|
"Tina is still at work right now, ",
|
|
"Tina has not yet been released from work, ",
|
|
"Tina is still at the thankless idiot scape known as work, ",
|
|
"Tina is still consumed by the gods of capitalism, ",
|
|
] | random }} she will be done at approximately {{ input_datetime_read('input_datetime.tina_workday_end') }}.
|
|
{% elif is_state('binary_sensor.evening','on') %}
|
|
{% if is_state('binary_sensor.tina_work_tomorrow','on') %}
|
|
{{ [
|
|
"Tina must go and please the food gods tomorrow ",
|
|
"Tomorrow, Tina must go and entertain the gremlins known as her customers and coworkers ",
|
|
"Tomorrow, Tina will be owned by our lovely lord and savior capitalism ",
|
|
] | random }} at {{ diff | timestamp_custom('%-I:%M %p',false) }}. "
|
|
{% elif is_state('binary_sensor.tina_work_tomorrow','off') %}
|
|
{{ [
|
|
"Tina seems to have been granted a reprieve from her endless torture tomorrow. ",
|
|
"The powers that be have decided that Tina deserves a break from work tomorrow. ",
|
|
"Tina has been granted time off from the hellscape of work tomorrow. ",
|
|
"Tina will not be attending the gathering of tormented souls known as work tomorrow. ",
|
|
"The scheduling gods have decided that Tina's services will not be required tomorrow. "
|
|
"Tina gets a break tomorrow from grinding it out for the gods of capitalism. ",
|
|
"Tina will not be at the thankless idiot scape known as work tomorrow. ",
|
|
] | random }}
|
|
{% endif %}
|
|
{% elif is_state('input_boolean.work_today','on') %}
|
|
{{ [
|
|
"Tina must go and please the food gods today ",
|
|
"Today, Tina must go and entertain the gremlins known as her customers and coworkers ",
|
|
"Today, Tina will be owned and operated by our lovely lord and savior capitalism starting ",
|
|
"Tina will attempt to satiate the patron saint of capitalism today "
|
|
] | random }} at {{ input_datetime_read('input_datetime.tina_workday_start') }}.
|
|
{% else %}
|
|
{{ [
|
|
"Tina seems to have been granted a reprieve from her endless torture today. ",
|
|
"The powers that be have decided that Tina deserves a break from work today. ",
|
|
"Tina has been granted time off from the hellscape of work today. ",
|
|
"Tina will not be attending the gathering of tormented souls known as work today. ",
|
|
"The scheduling gods have decided that Tina's services will not be required today. "
|
|
"Tina gets a break today from grinding it out for the gods of capitalism. ",
|
|
"Tina will not be at the thankless idiot scape known as work today. ",
|
|
] | random }}
|
|
{% endif %}
|
|
{% elif method == 'text' %}
|
|
{% if tina in ['Bob Evans','BobEvans'] and is_state('input_boolean.work_today','on') %}
|
|
Tina is at work right now. She will be done at approximately {{ input_datetime_read('input_datetime.tina_workday_end') | trim }}.
|
|
{% elif is_state('input_boolean.work_today','on') %}
|
|
Tina has work at {{ input_datetime_read('input_datetime.tina_workday_start') | trim }}.
|
|
{% elif is_state('input_boolean.work_today_extended','on') and is_state('input_boolean.work_today','off') %}
|
|
Tina has finished work for the day.
|
|
{% if is_state('binary_sensor.tina_work_tomorrow','on') %}
|
|
Tina has work tomorrow at {{ diff | timestamp_custom('%-I:%M %p',false) }}.
|
|
{% endif %}
|
|
{% else %}
|
|
Tina has today off from work.
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro meds_report_tina(type,method) %}
|
|
{{ tina_morning_meds(type,method) }}
|
|
{{ tina_night_meds(type,method) }}
|
|
{% endmacro %}
|
|
|
|
{% macro tina_status_report(type,method) %}
|
|
{% macro data() %}
|
|
{% if type == 'work' %}
|
|
{{ work_report_tina(type,method) }}
|
|
{% elif type == 'meds' %}
|
|
{{ work_report_tina(type,method) }}
|
|
{% elif type == 'full' %}
|
|
{{ work_report_tina(type,method) }}
|
|
{{ meds_report_tina(type,method) }}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
{{ cleanup(data()) }}
|
|
{% endmacro %}
|
|
|
|
{% macro kallen_morning_meds(type,method) %}
|
|
{% set wakeup = state_attr('input_datetime.kallen_awake_at','timestamp') | int %}
|
|
{% if state_attr('input_datetime.kallen_bedtime','timestamp') | int <= 7200 %}
|
|
{% set bedtime = 86340 %}
|
|
{% else %}
|
|
{% set bedtime = state_attr('input_datetime.kallen_bedtime','timestamp') | int - 900 %}
|
|
{% endif %}
|
|
{% if type == 'meds' %}
|
|
{% if method == 'text' %}
|
|
{% set identKallen = kallenText %}
|
|
{% elif method == 'tts' %}
|
|
{% set identKallen = kallenTTS %}
|
|
{% endif %}
|
|
{% else %}
|
|
{% set identKallen = 'He' %}
|
|
{% endif %}
|
|
{% if wakeup <= ct <= bedtime %}
|
|
{% if is_state('input_boolean.kallen_morning_meds_taken','on') %}
|
|
{{ identKallen }} took his morning meds at {{ input_datetime_read('input_datetime.kallen_morning_meds_taken') | trim }}.
|
|
{% else %}
|
|
{{ 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',
|
|
'This is absolutely essential, and I will remind him to do it at',
|
|
] | random }} {{ input_datetime_read('input_datetime.kallen_morning_meds_notify') | trim }}.
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro kallen_night_meds(type,method) %}
|
|
{% set wakeup = state_attr('input_datetime.kallen_awake_at','timestamp') | int %}
|
|
{% if 0 <= state_attr('input_datetime.kallen_asleep_at','timestamp') | int <= 7200 %}
|
|
{% set bedtime = 85440 %}
|
|
{% else %}
|
|
{% set bedtime = state_attr('input_datetime.kallen_bedtime','timestamp') | int - 900 %}
|
|
{% endif %}
|
|
{% set diff = bedtime - ct %}
|
|
{% if type == 'meds' %}
|
|
{% if method == 'text' %}
|
|
{% set identKallen = kallenText %}
|
|
{% elif method == 'tts' %}
|
|
{% set identKallen = kallenTTS %}
|
|
{% endif %}
|
|
{% else %}
|
|
{% set identKallen = 'He' %}
|
|
{% endif %}
|
|
{% if is_state('input_boolean.kallen_night_meds_taken','on') %}
|
|
{% if (ct >= bedtime) or (ct < wakeup) %}
|
|
{{ identKallen }} took his night meds at {{ input_datetime_read('input_datetime.kallen_night_meds_taken') | trim }}.
|
|
{% endif %}
|
|
{% else %}
|
|
{% if diff <= 3600 %}
|
|
{{ 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.',
|
|
'All in due time, of course.'
|
|
] | random }}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro med_report_kallen(type,method) %}
|
|
{% if is_state('input_boolean.kallen_overnight','on') %}
|
|
{% if type == 'meds' %}
|
|
{% if method == 'text' %}
|
|
{% set identKallen = kallenText %}
|
|
{% elif method == 'tts' %}
|
|
{% set identKallen = kallenTTS %}
|
|
{% endif %}
|
|
{% 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) }}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro school_report_kallen(type,method) %}
|
|
{% set wakeup = state_attr('input_datetime.kallen_wakeup_time','timestamp') %}
|
|
{% set bedtime = state_attr('input_datetime.kallen_bedtime','timestamp') %}
|
|
{% if method == 'tts' %}
|
|
{% if is_state('input_boolean.kallen_school_today', 'on') %}
|
|
{% if is_state('sensor.school_start_days2go', '0') %}
|
|
Today is the first day of school! The last day is in {{ custom_time('input_datetime.school_last_day','month,week,day') }}.
|
|
{% else %}
|
|
{{ [ 'Today is a school day.',
|
|
'Collin has school today.',
|
|
'It is a school day. '
|
|
] | random }}
|
|
{% if is_state('input_boolean.two_hour_delay','on') %}
|
|
'But there was a two hour delay. '
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if is_state('input_boolean.kallen_btb','on') %}
|
|
Collin has Beyond The Bells today after school.
|
|
{% endif %}
|
|
{% if is_state('input_boolean.kallen_alternate_pickup','on') %}
|
|
{{ states('input_text.kallen_pickup') }} will be picking Collin up from school today.
|
|
{% else %}
|
|
Pickup today will be at {{ input_datetime_read('input_datetime.kallen_school_day_end') | trim }}.
|
|
{% if is_state('input_boolean.kallen_school_early_release','on') %}
|
|
And It is early release!
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if states('sensor.windows_open') | int > 0 %}
|
|
'I detect that there are windows open. Make sure you close them before you leave, or else the security system will not arm. '
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if is_state('input_boolean.school_cancelled','on') %}
|
|
'School has been cancelled for today. '
|
|
{% endif %}
|
|
{% if (count_the_days('input_datetime.thanksgiving_break_start') | int <= 14) and (count_the_days('input_datetime.thanksgiving_break_start') | int > 0) %}
|
|
{{ [ 'Oh, and look at that.',
|
|
'For those trying to keep count. ',
|
|
'In case you were wondering.',
|
|
'Also, did you know.'
|
|
] | random }}
|
|
'Thanksgiving break starts in {{ custom_time('input_datetime.thanksgiving_break_start','week,day') }}!'
|
|
{% endif %}
|
|
{% if (count_the_days('input_datetime.christmas_break_start') | int <= 14) and (count_the_days('input_datetime.christmas_break_start') | int > 0) %}
|
|
{{ [ 'Oh, and look at that.',
|
|
'For those trying to keep count. ',
|
|
'In case you were wondering.',
|
|
'Also, did you know.'
|
|
] | random }}
|
|
'Christmas break starts in {{ custom_time('input_datetime.christmas_break_start','week,day') }}!'
|
|
{% endif %}
|
|
{% if (count_the_days('input_datetime.spring_break_start') | int <= 14) and (count_the_days('input_datetime.spring_break_start') | int > 0) %}
|
|
{{ [ 'Oh, and look at that.',
|
|
'For those trying to keep count. ',
|
|
'In case you were wondering.',
|
|
'Also, did you know.'
|
|
] | random }}
|
|
'Spring break starts in {{ custom_time('input_datetime.spring_break_start','week,day') }}!'
|
|
{% endif %}
|
|
{% if (count_the_days('input_datetime.school_last_day') | int <= 35) and (count_the_days('input_datetime.school_last_day') | int > 0) %}
|
|
{{ [ 'Oh, and look at that.',
|
|
'For those trying to keep count. ',
|
|
'In case you were wondering.',
|
|
'Also, did you know.'
|
|
] | random }}
|
|
The school year ends in {{ custom_time('input_datetime.school_last_day','week,day') }}.
|
|
{% endif %}
|
|
{% if count_the_days('input_datetime.school_last_day') | int == 0 %}
|
|
Congratulations, today is the last day of school! Have an awesome day!
|
|
{% endif %}
|
|
{% if count_the_days('input_datetime.school_last_day') | int == -1 -%}
|
|
Today is the first day of Summer Break!
|
|
{%- endif %}
|
|
{% elif method == 'text' %}
|
|
{% if type == 'school' %}
|
|
{% set identKallen = kallenText %}
|
|
{% else %}
|
|
{% set identKallen = 'He' %}
|
|
{% endif %}
|
|
{% if is_state('input_boolean.school_in_session','off') and is_state('input_boolean.kallen_btb','on') %}
|
|
{{ identKallen }} has Beyond The Bells today. It is scheduled to end at {{ input_datetime_read('input_datetime.kallen_school_day_end') | trim }}.
|
|
{% elif 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') %}
|
|
{{ identKallen }} is at school right now.
|
|
{% if is_state('input_boolean.kallen_btb','on') %}
|
|
{{ identKallen }} has Beyond The Bells after school today.
|
|
{% endif %}
|
|
{% 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') %}
|
|
The school is on an early release schedule, pickup is at {{ input_datetime_read('input_datetime.kallen_school_day_end') | trim }}.
|
|
{% else %}
|
|
His pickup time is {{ input_datetime_read('input_datetime.kallen_school_day_end') | trim }}.
|
|
{% endif %}
|
|
{% else %}
|
|
{{ 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) %}
|
|
{{ identKallen }} has finished his school day.
|
|
{% endif %}
|
|
{% elif is_state ('binary_sensor.early_night_mode','on') and is_state('binary_sensor.kallen_school_tomorrow','on') %}
|
|
{{ identKallen }} has school tomorrow.
|
|
{% if is_state('binary_sensor.kallen_btb_tomorrow','on') %}
|
|
{{ identKallen }} will have BTB tomorrow after school.
|
|
{% endif %}
|
|
{% elif is_state('binary_sensor.after_midnight','off') %}
|
|
{{ identKallen }} does not have school today.
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro kallen_sleep(type,method) %}
|
|
{% set bedtimestamp = state_attr('input_datetime.kallen_bedtime','timestamp') | int %}
|
|
{% if is_state('input_boolean.kallen_sleeping','on') %}
|
|
Kallen went to bed at {{ input_datetime_read('input_datetime.kallen_asleep_at') | trim }}.
|
|
{% if kallenMorningRan == true and ct < bedtimestamp %}
|
|
His scheduled wakeup time is {{ input_datetime_read('input_datetime.kallen_wakeup_time') | trim }}.
|
|
{% endif %}
|
|
{% else %}
|
|
Kallen woke up at {{ input_datetime_read('input_datetime.kallen_awake_at') | trim }}.
|
|
{% if kallenEveningRan %}
|
|
His scheduled bedtime is {{ input_datetime_read('input_datetime.kallen_bedtime') | trim }}.
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro kallen_status_report(type,method) %}
|
|
{% macro data() %}
|
|
{% if type == 'meds' %}
|
|
{{ med_report_kallen(type,method) }}
|
|
{% elif type == 'school' %}
|
|
{{ school_report_kallen(type,method) }}
|
|
{% elif type == 'sleep' %}
|
|
{{ kallen_sleep(type,method)}}
|
|
{% elif type == 'full' %}
|
|
{{ kallen_sleep(type,method) }}
|
|
{{ med_report_kallen(type,method) }}
|
|
{{ school_report_kallen(type,method) }}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
{{ cleanup(data()) }}
|
|
{% endmacro %}
|
|
|
|
{% macro emma_sleep(type,method) %}
|
|
{% if is_state('input_boolean.emma_sleeping','on') %}
|
|
{% if is_state('binary_sensor.early_night_mode','on') %}
|
|
Emma is asleep for the night. She went to bed at {{ input_datetime_read('input_datetime.emma_asleep_at') | trim }}.
|
|
{% else %}
|
|
Emma has not yet awoken for the day. She went to bed at {{ input_datetime_read('input_datetime.emma_asleep_at') | trim }}. Her wakeup time is scheduled for {{ input_datetime_read('input_datetime.emma_wakeup') | trim }}.
|
|
{% endif %}
|
|
{% else %}
|
|
Emma is awake. She woke up at {{ input_datetime_read('input_datetime.emma_awake_at') | trim }}.
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro emma_sleep_notification(type,method) %}
|
|
{% if is_state('input_boolean.emma_sleeping','off') %}
|
|
Emma has awoken for the day at {{ clock('12-hr') }}
|
|
{% elif is_state('input_boolean.emma_sleeping','on') %}
|
|
Emma is asleep for the night (or at least, her sleep switch is active) at {{ clock('12-hr') }}
|
|
{% else %}
|
|
This notification is confused and should not be here. Blame Tony.
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro med_report_emma(type,method) %}
|
|
{% set tylenol_taken = input_datetime_read('input_datetime.emma_tylenol') | trim %}
|
|
{% set ibuprofen_taken = input_datetime_read('input_datetime.emma_ibuprofen') | trim %}
|
|
{% set cough_meds_taken = input_datetime_read('input_datetime.emma_cough_meds') | trim %}
|
|
{% set tylenol_next = input_datetime_read('input_datetime.emma_tylenol_notify') | trim %}
|
|
{% set ibuprofen_next = input_datetime_read('input_datetime.emma_ibuprofen_notify') | trim %}
|
|
{% set cough_meds_next = input_datetime_read('input_datetime.emma_cough_meds_notify') | trim %}
|
|
{% set tylenol_ts = state_attr('input_datetime.emma_tylenol','timestamp') | int %}
|
|
{% set ibuprofen_ts = state_attr('input_datetime.emma_ibuprofen','timestamp') | int %}
|
|
{% set cough_ts = state_attr('input_datetime.emma_cough_meds','timestamp') | int %}
|
|
{% set current = as_timestamp(now()) | int %}
|
|
{% 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') %}
|
|
{{ 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.
|
|
{% if (is_state('input_boolean.emma_alternating_meds_active','on') and ((current - tylenol_ts >= 28800) or (current - ibuprofen_ts >= 28800))) or
|
|
(is_state('input_boolean.emma_cough_meds_active','on') and current - cough_ts >= 14400) %}
|
|
Emma will need meds when she wakes up.
|
|
{% endif %}
|
|
{% 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') %}
|
|
{{ identEmma }} has not taken her ibuprofen or her tylenol.
|
|
{% else %}
|
|
{% if is_state('input_boolean.emma_tylenol','on') %}
|
|
{{ identEmma }} has taken her tylenol. Her most recent dose was at {{ tylenol_taken }}. Her next dose is at {{ tylenol_next }}.
|
|
{% else %}
|
|
{{ identEmma }} has not taken her tylenol.
|
|
{% endif %}
|
|
{% if is_state('input_boolean.emma_ibuprofen','on') %}
|
|
{{ identEmma }} has taken her ibuprofen. Her most recent dose was at {{ ibuprofen_taken }}. Her next dose is at {{ ibuprofen_next }}.
|
|
{% else %}
|
|
{{ 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') %}
|
|
{{ identEmma }} has taken her cough meds. Her most recent dose was at {{ cough_meds_taken }}. Her next dose is at {{ cough_meds_next }}.
|
|
{% else %}
|
|
{{ identEmma }} has not taken her cough meds.
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro emma_status_report(type,method) %}
|
|
{% macro data() %}
|
|
{% if type == 'sleep' %}
|
|
{{ emma_sleep(type,method) }}
|
|
{% elif type == 'meds' %}
|
|
{{ med_report_emma(type,method) }}
|
|
{% elif type == 'full' %}
|
|
{{ emma_sleep(type,method) }}
|
|
{{ med_report_emma(type,method) }}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
{{ cleanup(data()) }}
|
|
{% endmacro %} |