Consolidate set/read from calendars into one macro
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
{% from 'time.jinja' import input_datetime_read, ct, next_twitch_stream, calendar_event_today, read_time_from_calendar %}
|
{% 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 'easy_time.jinja' import count_the_days, custom_time, custom_time_between, clock %}
|
||||||
{% set ct = ct() | int %}
|
{% set ct = ct() | int %}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
|
|||||||
{% 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 {{ read_time_from_calendar('calendar.tony_s_twitch_schedule','start_time') }} tomorrow.
|
Tony will be streaming at {{ time_from_calendar('calendar.tony_s_twitch_schedule','start_time','read') }} tomorrow.
|
||||||
{% else %}
|
{% else %}
|
||||||
Tony does not have a stream scheduled today. The next scheduled stream is in {{ next_twitch_stream() }} approximately.
|
Tony does not have a stream scheduled today. The next scheduled stream is in {{ next_twitch_stream() }} approximately.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -38,12 +38,12 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro set_time_from_calendar(calendar,start_or_end) %}
|
{% macro time_from_calendar(calendar,start_or_end,action) %}
|
||||||
|
{% if action == 'set' %}
|
||||||
{{ as_timestamp(strptime(state_attr(calendar,start_or_end), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }}
|
{{ as_timestamp(strptime(state_attr(calendar,start_or_end), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }}
|
||||||
{% endmacro %}
|
{% elif action == 'read' %}
|
||||||
|
|
||||||
{% macro read_time_from_calendar(calendar,start_or_end) %}
|
|
||||||
{{ as_timestamp(strptime(state_attr(calendar,start_or_end), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%-I:%M %p") }}
|
{{ as_timestamp(strptime(state_attr(calendar,start_or_end), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%-I:%M %p") }}
|
||||||
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro set_datetime(hours,minutes,seconds) %}
|
{% macro set_datetime(hours,minutes,seconds) %}
|
||||||
|
@ -176,11 +176,11 @@ script:
|
|||||||
entity_id: input_datetime.kallen_school_day_start
|
entity_id: input_datetime.kallen_school_day_start
|
||||||
data:
|
data:
|
||||||
time: >
|
time: >
|
||||||
{% from 'time.jinja' import set_time_from_calendar %}
|
{% from 'time.jinja' import time_from_calendar %}
|
||||||
{% if is_state('input_boolean.two_hour_delay','on') %}
|
{% if is_state('input_boolean.two_hour_delay','on') %}
|
||||||
10:00
|
10:00
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ set_time_from_calendar('calendar.kallen_school_days','start_time') }}
|
{{ time_from_calendar('calendar.kallen_school_days','start_time','set') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
- delay:
|
- delay:
|
||||||
seconds: 1
|
seconds: 1
|
||||||
|
@ -408,15 +408,15 @@ script:
|
|||||||
entity_id: input_datetime.kallen_school_day_end
|
entity_id: input_datetime.kallen_school_day_end
|
||||||
data:
|
data:
|
||||||
time: >
|
time: >
|
||||||
{% from 'time.jinja' import set_time_from_calendar %}
|
{% from 'time.jinja' import time_from_calendar %}
|
||||||
{{ set_time_from_calendar('calendar.kallen_school_days','end_time') }}
|
{{ time_from_calendar('calendar.kallen_school_days','end_time','set') }}
|
||||||
- service: input_datetime.set_datetime
|
- service: input_datetime.set_datetime
|
||||||
target:
|
target:
|
||||||
entity_id: input_datetime.kallen_school_day_start
|
entity_id: input_datetime.kallen_school_day_start
|
||||||
data:
|
data:
|
||||||
time: >
|
time: >
|
||||||
{% from 'time.jinja' import set_time_from_calendar %}
|
{% from 'time.jinja' import time_from_calendar %}
|
||||||
{{ set_time_from_calendar('calendar.kallen_school_days','start_time') }}
|
{{ time_from_calendar('calendar.kallen_school_days','start_time','set') }}
|
||||||
- service: input_boolean.turn_on
|
- service: input_boolean.turn_on
|
||||||
entity_id:
|
entity_id:
|
||||||
- input_boolean.kallen_school_today
|
- input_boolean.kallen_school_today
|
||||||
|
@ -141,15 +141,15 @@ script:
|
|||||||
entity_id: input_datetime.tina_workday_start
|
entity_id: input_datetime.tina_workday_start
|
||||||
data:
|
data:
|
||||||
time: >
|
time: >
|
||||||
{% from 'time.jinja' import set_time_from_calendar %}
|
{% from 'time.jinja' import time_from_calendar %}
|
||||||
{{ set_time_from_calendar('calendar.family_tinawork','start_time') }}
|
{{ time_from_calendar('calendar.family_tinawork','start_time','set') }}
|
||||||
- service: input_datetime.set_datetime
|
- service: input_datetime.set_datetime
|
||||||
target:
|
target:
|
||||||
entity_id: input_datetime.tina_workday_end
|
entity_id: input_datetime.tina_workday_end
|
||||||
data:
|
data:
|
||||||
time: >
|
time: >
|
||||||
{% from 'time.jinja' import set_time_from_calendar %}
|
{% from 'time.jinja' import time_from_calendar %}
|
||||||
{{ set_time_from_calendar('calendar.family_tinawork','end_time') }}
|
{{ time_from_calendar('calendar.family_tinawork','end_time','set') }}
|
||||||
- service: input_boolean.turn_on
|
- service: input_boolean.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id:
|
entity_id:
|
||||||
|
@ -392,8 +392,8 @@ script:
|
|||||||
entity_id: input_datetime.tony_streaming_start_time
|
entity_id: input_datetime.tony_streaming_start_time
|
||||||
data:
|
data:
|
||||||
time: >
|
time: >
|
||||||
{% from 'time.jinja' import set_time_from_calendar %}
|
{% from 'time.jinja' import time_from_calendar %}
|
||||||
{{ set_time_from_calendar('calendar.tony_s_twitch_schedule','start_time') }}
|
{{ time_from_calendar('calendar.tony_s_twitch_schedule','start_time','set') }}
|
||||||
- service: input_boolean.turn_on
|
- service: input_boolean.turn_on
|
||||||
entity_id: input_boolean.tony_streaming_today
|
entity_id: input_boolean.tony_streaming_today
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{# Nightly Briefing #}
|
{# Nightly Briefing #}
|
||||||
{%- macro getReport() -%}
|
{%- macro getReport() -%}
|
||||||
{% from 'speech.jinja' import greeting, dadjoke, inspirational_quote %}
|
{% from 'speech.jinja' import greeting, dadjoke, inspirational_quote %}
|
||||||
{% from 'time.jinja' import input_datetime_read, read_time_from_calendar, next_twitch_stream %}
|
{% from 'time.jinja' import input_datetime_read, time_from_calendar, next_twitch_stream %}
|
||||||
{% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %}
|
{% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %}
|
||||||
{% from 'easy_time.jinja' import count_the_days %}
|
{% from 'easy_time.jinja' import count_the_days %}
|
||||||
{% from 'weather.jinja' import weatherReport %}
|
{% from 'weather.jinja' import weatherReport %}
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<p>
|
<p>
|
||||||
{{ tonyStatusReport('stream','tts') }}
|
{{ tonyStatusReport('stream','tts') }}
|
||||||
{% if is_state('binary_sensor.kallen_school_tomorrow','on') %}
|
{% if is_state('binary_sensor.kallen_school_tomorrow','on') %}
|
||||||
"Collin has school tomorrow at {{ read_time_from_calendar('calendar.kallen_school_days','start_time') }}. "
|
"Collin has school tomorrow at {{ time_from_calendar('calendar.kallen_school_days','start_time','read') }}. "
|
||||||
{% else %}
|
{% else %}
|
||||||
"Collin does not have school tomorrow. "
|
"Collin does not have school tomorrow. "
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Reference in New Issue
Block a user