From bea0809a89c614f59274d656717e8f6f18712fb5 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 26 Sep 2022 15:06:55 -0400 Subject: [PATCH] Scheduling changes to account for K's morning band practices #45 --- packages/events.yaml | 54 +++++++++++++++++++++++----------------- packages/scheduling.yaml | 28 +++++++++++---------- 2 files changed, 46 insertions(+), 36 deletions(-) diff --git a/packages/events.yaml b/packages/events.yaml index 95de7d2..1911326 100644 --- a/packages/events.yaml +++ b/packages/events.yaml @@ -20,6 +20,9 @@ input_boolean: kallen_school_cancelled: name: Kallen School Cancelled icon: mdi:calendar-remove + kallen_band_practice: + name: Kallen Band Practice + icon: mdi:trumpet input_datetime: school_first_day: @@ -236,18 +239,11 @@ automation: script: kallen_school_today: sequence: - - choose: - - conditions: + - if: - condition: template value_template: > {{ 'Early Release' in states('sensor.school_event') }} - sequence: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.school_day_start - data: - time: > - {{ as_timestamp(strptime(state_attr('calendar.kallen_school_days','start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }} + then: - service: input_boolean.turn_on entity_id: input_boolean.school_early_release - service: input_datetime.set_datetime @@ -255,25 +251,35 @@ script: entity_id: input_datetime.school_day_end data: time: "14:45:00" - default: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.school_day_start - data: - time: > - {{ as_timestamp(strptime(state_attr('calendar.kallen_school_days','start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }} - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.school_day_end - data: - time: > - {{ as_timestamp(strptime(state_attr('calendar.kallen_school_days','end_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }} + else: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.school_day_end + data: + time: > + {{ as_timestamp(strptime(state_attr('calendar.kallen_school_days','end_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }} + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.school_day_start + data: + time: > + {{ as_timestamp(strptime(state_attr('calendar.kallen_school_days','start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }} - service: input_boolean.turn_on entity_id: - input_boolean.school_today - input_boolean.school_today_extended - service: script.turn_on entity_id: script.school_in_session + - delay: + seconds: 1 + - if: + - condition: template + value_template: > + {{ state_attr('input_datetime.school_day_start','timestamp') == 28800 }} + then: + - service: input_boolean.turn_on + entity_id: input_boolean.kallen_band_practice + kallen_school_reset: sequence: @@ -286,7 +292,9 @@ script: kallen_school_reset_late: sequence: - service: input_boolean.turn_off - entity_id: input_boolean.school_today_extended + entity_id: + - input_boolean.school_today_extended + - input_boolean.kallen_band_practice tina_work_today: sequence: diff --git a/packages/scheduling.yaml b/packages/scheduling.yaml index 332d197..b7bf6b3 100644 --- a/packages/scheduling.yaml +++ b/packages/scheduling.yaml @@ -121,6 +121,17 @@ automation: script: kallen_scheduling_morning: sequence: + - service: input_datetime.set_datetime + entity_id: input_datetime.school_day_start + data_template: + time: > + {% if is_state('input_boolean.kallen_two_hour_delay','on') %} + 11:00 + {% else %} + {{ as_timestamp(strptime(state_attr('calendar.kallen_school_days','start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }} + {% endif %} + - delay: + seconds: 1 - service: input_datetime.set_datetime entity_id: input_datetime.kallen_wakeup_time data_template: @@ -129,20 +140,11 @@ script: {% if is_state('input_boolean.kallen_two_hour_delay','on') %} 09:30 {% else %} - 07:30 + {{ (state_attr('input_datetime.school_day_start','timestamp') - 5400) | timestamp_custom('%H:%M', false) }} {% endif %} {% else %} 10:00 {% endif %} - - service: input_datetime.set_datetime - entity_id: input_datetime.school_day_start - data_template: - time: > - {% if is_state('input_boolean.kallen_two_hour_delay','on') %} - 11:00 - {% else %} - 09:00 - {% endif %} - service: input_select.select_option target: entity_id: input_select.kallen_morning_briefing_location @@ -165,7 +167,7 @@ script: {% if is_state('input_boolean.kallen_two_hour_delay','on') %} 09:40 {% else %} - 07:40 + {{ (state_attr('input_datetime.school_day_start','timestamp') - 4800) | timestamp_custom('%H:%M', false) }} {% endif %} {% else %} 10:00 @@ -177,7 +179,7 @@ script: {% if is_state('input_boolean.kallen_two_hour_delay','on') %} 10:00 {% else %} - 08:00 + {{ (state_attr('input_datetime.school_day_start','timestamp') - 3600) | timestamp_custom('%H:%M', false) }} {% endif %} - service: input_datetime.set_datetime entity_id: input_datetime.school_day_end_reminder @@ -229,7 +231,7 @@ script: {% if is_state('input_boolean.kallen_two_hour_delay','on') %} 10:20 {% else %} - 08:20 + {{ (state_attr('input_datetime.school_day_start','timestamp') - 2400) | timestamp_custom('%H:%M', false) }} {% endif %} {% elif is_state('input_boolean.work_today','on') and is_state('input_boolean.school_today','off') %} {% if (state_attr('input_datetime.tina_workday_start','timestamp')) > 43200 %}