From 203c507a5325a1677e10f0d930a7b4e81755ca6e Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 1 Feb 2023 18:03:28 -0500 Subject: [PATCH] More improvements for #53 --- packages/scheduling.yaml | 10 ++++----- packages/school.yaml | 22 +++++++++++++++++++ sensors/time.yaml | 20 ----------------- templates/speech/kallen_nightly_briefing.yaml | 4 ++-- templates/speech/nightly_briefing.yaml | 4 ++-- 5 files changed, 31 insertions(+), 29 deletions(-) diff --git a/packages/scheduling.yaml b/packages/scheduling.yaml index 55f624d..0cf2285 100644 --- a/packages/scheduling.yaml +++ b/packages/scheduling.yaml @@ -235,7 +235,7 @@ script: entity_id: input_datetime.kallen_bedtime data_template: time: > - {% if is_state('sensor.school_tomorrow', 'on') %} + {% if is_state('sensor.kallen_school_tomorrow', 'on') %} 21:00 {% else %} 22:00 @@ -244,7 +244,7 @@ script: entity_id: input_datetime.kallen_nightly_briefing data_template: time: > - {% if is_state('sensor.school_tomorrow', 'on') %} + {% if is_state('sensor.kallen_school_tomorrow', 'on') %} 20:40 {% else %} 21:40 @@ -359,7 +359,7 @@ script: entity_id: input_datetime.audible_notification_off data_template: time: > - {% if is_state('sensor.school_tomorrow','on') %} + {% if is_state('sensor.kallen_school_tomorrow','on') %} 22:00 {% else %} 23:00 @@ -390,9 +390,9 @@ script: data_template: time: > {% set low = state_attr('sensor.current_forecast','overnight_low') | float %} - {% if is_state('input_boolean.hot_day','on') and is_state('sensor.school_tomorrow','on') %} + {% if is_state('input_boolean.hot_day','on') and is_state('sensor.kallen_school_tomorrow','on') %} 20:00 - {% elif is_state('input_boolean.hot_day','on') and is_state('sensor.school_tomorrow','off') %} + {% elif is_state('input_boolean.hot_day','on') and is_state('sensor.kallen_school_tomorrow','off') %} 21:00 {% elif low >= 56 and low <= 60 %} 22:30 diff --git a/packages/school.yaml b/packages/school.yaml index 0d41af5..604375d 100644 --- a/packages/school.yaml +++ b/packages/school.yaml @@ -94,6 +94,28 @@ sensor: spring_break_days2go: value_template: "{{ ((state_attr('input_datetime.spring_break_start', 'timestamp')-as_timestamp(now())) | int /60/1440) | round(0) }}" unit_of_measurement: 'Days' + kallen_school_tomorrow: + unique_id: 0a1b81bc-2080-4006-b0f1-270af904d411 + friendly_name: 'Kallen School Tomorrow' + value_template: >- + {%- set test=(as_timestamp(now())+ (86400)) | timestamp_custom("%Y-%m-%d",true) %} + {% if states.calendar.kallen_school_days.attributes.start_time == test + " 09:00:00" %} + on + {% elif states.calendar.kallen_school_days.attributes.start_time == test + " 08:00:00" %} + on + {% else %} + off + {% endif %} + kallen_band_tomorrow: + unique_id: 2906baeb-98ec-4215-8043-e223f2759ed7 + friendly_name: 'Kallen Band Tomorrow' + value_template: >- + {%- set test=(as_timestamp(now())+ (86400)) | timestamp_custom("%Y-%m-%d",true) %} + {% if states.calendar.kallen_school_days.attributes.start_time == test + " 08:00:00" %} + on + {% else %} + off + {% endif %} lunch_menu_week: friendly_name: Lunch Menu Week value_template: > diff --git a/sensors/time.yaml b/sensors/time.yaml index 3b2a85b..99ca666 100644 --- a/sensors/time.yaml +++ b/sensors/time.yaml @@ -6,26 +6,6 @@ month_is: friendly_name: 'Month is' value_template: "{{ ['January','February','March','April','May','June','August','September','October','November','December'][now().month-1] }}" - school_tomorrow: - friendly_name: 'School Tomorrow' - value_template: >- - {%- set test=(as_timestamp(now())+ (86400)) | timestamp_custom("%Y-%m-%d",true) %} - {% if states.calendar.kallen_school_days.attributes.start_time == test + " 09:00:00" %} - on - {% elif states.calendar.kallen_school_days.attributes.start_time == test + " 08:00:00" %} - on - {% else %} - off - {% endif %} - band_tomorrow: - friendly_name: 'Band Tomorrow' - value_template: >- - {%- set test=(as_timestamp(now())+ (86400)) | timestamp_custom("%Y-%m-%d",true) %} - {% if states.calendar.kallen_school_days.attributes.start_time == test + " 08:00:00" %} - on - {% else %} - off - {% endif %} kallen_timer_remaining_minutes: friendly_name: 'Kallen Timer Remaining Minutes' value_template: >- diff --git a/templates/speech/kallen_nightly_briefing.yaml b/templates/speech/kallen_nightly_briefing.yaml index 0a4e8ac..e7f2563 100644 --- a/templates/speech/kallen_nightly_briefing.yaml +++ b/templates/speech/kallen_nightly_briefing.yaml @@ -11,12 +11,12 @@ 'The count down clock until bedtime has started. Time to get cleaned up, get your pajamas on, and head for your bedroom.', 'Its the final countdown until bedtime, silly. Time to get ready to head that way!' ] | random }} - {% if is_state('sensor.school_tomorrow', 'on') %} + {% if is_state('sensor.kallen_school_tomorrow', 'on') %} {{ [ 'Because you have school tomorrow. ', 'Because you have to get up early tomorrow for school.', 'Because you want to be ready for school tomorrow.' ] | random }} - {% if is_state('sensor.band_tomorrow','on') %} + {% if is_state('sensor.kallen_band_tomorrow','on') %} {{ [ 'And you have band practice in the morning. ', 'And you have a date with a trombone first thing in the morning. ', diff --git a/templates/speech/nightly_briefing.yaml b/templates/speech/nightly_briefing.yaml index d737bea..48f2cfe 100644 --- a/templates/speech/nightly_briefing.yaml +++ b/templates/speech/nightly_briefing.yaml @@ -9,8 +9,8 @@ {% if is_state('input_boolean.tony_streaming_today','on') %} "Tony will be streaming tonight. The studio is scheduled to go online at {{ (state_attr('input_datetime.tony_streaming_start_time','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " {% endif %} - {% if is_state('sensor.school_tomorrow','on') %} - {% if is_state('sensor.band_tomorrow','on') %} + {% if is_state('sensor.kallen_school_tomorrow','on') %} + {% if is_state('sensor.kallen_band_tomorrow','on') %} "Collin has school tomorrow, and there will be band practice in the morning at {{ as_timestamp(strptime(state_attr('calendar.kallen_school_days','start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%I:%M %p") }}. " {% else %} "Collin has school tomorrow at {{ as_timestamp(strptime(state_attr('calendar.kallen_school_days','start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%I:%M %p") }}. "