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