Files
Home-Assistant-Configs/packages/scheduling.yaml
Tony Stork f5b8390ec1 School cancel and delay entities back to generalized form
No need for them to be individualized since all schools in the same district follow the same calls...
2023-03-09 18:07:14 -05:00

587 lines
22 KiB
YAML

input_datetime:
good_morning:
name: Good Morning
has_date: false
has_time: true
icon: mdi:weather-sunset-up
good_night_routine:
name: Good Night Routine
has_date: false
has_time: true
icon: mdi:weather-night
kallen_bedtime:
name: Kallen Bedtime
has_date: false
has_time: true
icon: mdi:weather-night
kallen_wakeup_time:
name: Kallen Wake-up Time
has_date: false
has_time: true
icon: mdi:bell-alert
kallen_fan:
name: Kallen Fan
has_date: false
has_time: true
icon: mdi:fan-auto
master_bedroom_cooling:
name: Master Bedroom Cooling
has_date: false
has_time: true
icon: mdi:fan-auto
master_bedroom_fan:
name: Master Bedroom Fan
has_date: false
has_time: true
icon: mdi:fan-auto
master_bedroom_wakeup:
name: Master Bedroom Wakeup
has_date: false
has_time: true
icon: mdi:fan-off
emma_bedtime:
name: Emma Bedtime
has_date: false
has_time: true
icon: mdi:fan-auto
emma_wakeup:
name: Emma Wakeup
has_date: false
has_time: true
icon: mdi:fan-off
tony_streaming_start_time:
name: Tony Streaming Start Time
has_date: false
has_time: true
icon: mdi:twitch
################################################
# Current order of operations is as follows: #
# #
# Morning: #
# - Work Today #
# - School Today #
# - Kallen Scheduling #
# - House Scheduling #
# - Emma Bedroom Scheduling #
# - Master Bedroom Scheduling #
# #
# Evening: #
# - Kallen Scheduling #
# - House Scheduling #
# - Master Bedroom Scheduling #
# - Emma Bedroom Scheduling #
################################################
automation:
- id: c772b54d-6448-4d74-a0c2-32998f49b17c
alias: Kallen Scheduling
trigger:
- platform: time
at: '04:01:00'
id: kallen-morning
- platform: time
at: '16:00:00'
id: kallen-evening
action:
- if:
- condition: trigger
id: kallen-morning
then:
- service: script.kallen_scheduling_morning
- if:
- condition: trigger
id: kallen-evening
then:
- service: script.kallen_scheduling_evening
- id: 1c9f7e4b-2d5a-4b95-bd80-d9aa2244a6db
alias: House Scheduling
trigger:
- platform: time
at: '04:01:10'
id: house-morning
- platform: time
at: '16:00:10'
id: house-evening
action:
- if:
- condition: trigger
id: house-morning
then:
- service: script.house_scheduling_morning
- service: script.security_scheduling
- if:
- condition: trigger
id: house-evening
then:
- service: script.house_scheduling_evening
- id: 89470712-f94d-4c01-8215-ed15b3bc799a
alias: Master Bedroom Scheduling
trigger:
- platform: time
at: '04:02:00'
id: mrbedroom-morning
- platform: time
at: '16:00:20'
id: mrbedroom-evening
action:
- if:
- condition: trigger
id: mrbedroom-morning
then:
- service: script.master_bedroom_scheduling_morning
- if:
- condition: trigger
id: mrbedroom-evening
then:
- service: script.master_bedroom_scheduling_evening
- id: a69d3d36-09d6-4ef3-a245-c564c7cb577c
alias: Emma Bedroom Scheduling
trigger:
- platform: time
at: '04:02:10'
id: emma-morning
- platform: time
at: '16:00:30'
id: emma-evening
action:
- if:
- condition: trigger
id: emma-morning
then:
- service: script.emma_bedroom_scheduling_morning
- if:
- condition: trigger
id: emma-evening
then:
- service: script.emma_bedroom_scheduling_evening
script:
kallen_scheduling_morning:
alias: 'Kallen Scheduling Morning'
sequence:
- service: input_datetime.set_datetime
entity_id: input_datetime.kallen_school_day_start
data:
time: >
{% if is_state('input_boolean.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:
time: >
{% if is_state('input_boolean.kallen_school_today', 'on') %}
{% if is_state('input_boolean.two_hour_delay','on') %}
09:30
{% else %}
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') - 5400) | timestamp_custom('%H:%M', false) }}
{% endif %}
{% else %}
10:00
{% endif %}
- service: input_select.select_option
target:
entity_id: input_select.kallen_morning_briefing_location
data:
option: >
{% if is_state('input_boolean.kallen_school_today','on') %}
{% if is_state('input_boolean.two_hour_delay','on') %}
Common Areas
{% else %}
Kallen Bedroom
{% endif %}
{% else %}
Common Areas
{% endif %}
- service: input_datetime.set_datetime
entity_id: input_datetime.kallen_morning_briefing
data:
time: >
{% if is_state('input_boolean.kallen_school_today', 'on') %}
{% if is_state('input_boolean.two_hour_delay','on') %}
09:40
{% else %}
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') - 4800) | timestamp_custom('%H:%M', false) }}
{% endif %}
{% else %}
10:00
{% endif %}
- service: input_datetime.set_datetime
entity_id: input_datetime.kallen_school_day_start_reminder
data:
time: >
{% if is_state('input_boolean.two_hour_delay','on') %}
10:00
{% else %}
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') - 3600) | timestamp_custom('%H:%M', false) }}
{% endif %}
- service: input_datetime.set_datetime
entity_id: input_datetime.kallen_school_day_end_reminder
data:
time: >
{% if is_state('input_boolean.kallen_school_early_release','on') %}
13:30
{% else %}
14:00
{% endif %}
kallen_scheduling_evening:
alias: 'Kallen Scheduling Evening'
sequence:
- service: input_datetime.set_datetime
entity_id: input_datetime.kallen_bedtime
data:
time: >
{% if is_state('sensor.kallen_school_tomorrow', 'on') %}
21:00
{% else %}
22:00
{% endif %}
- service: input_datetime.set_datetime
entity_id: input_datetime.kallen_nightly_briefing
data:
time: >
{% if is_state('sensor.kallen_school_tomorrow', 'on') %}
20:40
{% else %}
21:40
{% endif %}
- service: input_select.select_option
target:
entity_id: input_select.scheduled_climate_mode_kallen_fan
data:
option: >
{% if is_state('input_boolean.kallen_overnight','on') %}
N/A
{% elif (states('sensor.tonights_low_temp') | int) >= (states('input_number.kallen_fan_threshold') | int) %}
Fan
{% else %}
White Noise
{% endif %}
- delay:
seconds: 1
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.kallen_fan
data:
time: >
{% if is_state('input_boolean.hot_day','on') %}
{{ (state_attr('input_datetime.kallen_bedtime','timestamp') - 3600) | timestamp_custom('%H:%M', false) }}
{% else %}
{{ state_attr('input_datetime.kallen_bedtime','timestamp') | timestamp_custom('%H:%M', false) }}
{% endif %}
house_scheduling_morning:
alias: 'House Scheduling Morning'
sequence:
- service: input_datetime.set_datetime
entity_id: input_datetime.audible_notification_on
data:
time: >
{% if is_state('input_boolean.kallen_school_today','on') %}
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') - 5400) | timestamp_custom('%H:%M', false) }}
{% else %}
09:00
{% endif %}
- service: input_datetime.set_datetime
entity_id: input_datetime.morning_briefing
data:
time: >
{% if is_state('input_boolean.kallen_school_today','on') %}
{% if is_state('input_boolean.two_hour_delay','on') %}
10:20
{% else %}
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') - 2400) | timestamp_custom('%H:%M', false) }}
{% endif %}
{% elif is_state('input_boolean.work_today','on') and is_state('input_boolean.kallen_school_today','off') %}
{% if (state_attr('input_datetime.tina_workday_start','timestamp')) > 43200 %}
12:00
{% elif (state_attr('input_datetime.tina_workday_start','timestamp') - 1500 ) > (state_attr('input_datetime.audible_notification_on','timestamp')) %}
{{ (state_attr('input_datetime.tina_workday_start', 'timestamp') - 1500) | timestamp_custom('%H:%M', false) }}
{% else %}
10:00
{% endif %}
{% else %}
12:00
{% endif %}
- service: input_datetime.set_datetime
entity_id: input_datetime.daily_briefing
data:
time: >
{% if is_state('input_boolean.kallen_school_today','on') %}
{% if is_state('input_boolean.kallen_school_early_release','on') %}
13:15
{% else %}
14:15
{% endif %}
{% elif is_state('input_boolean.kallen_school_today','off') and is_state('input_boolean.work_today','off') %}
15:00
{% else %}
{% if (state_attr('input_datetime.tina_workday_end','timestamp')) > 61200 %}
16:00
{% else %}
{{ (state_attr('input_datetime.tina_workday_end', 'timestamp') + 3600) | timestamp_custom('%H:%M', false) }}
{% endif %}
{% endif %}
- if:
- condition: template
value_template: >
{% if states('sensor.todays_high_temp') | int >= states('input_number.hot_day_threshold') | int %}
true
{% else %}
false
{% endif %}
then:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.hot_day
else:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.hot_day
- if:
- condition: template
value_template: >
{% if states('sensor.todays_high_temp') | int <= states('input_number.cold_day_threshold') | int %}
true
{% else %}
false
{% endif %}
then:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.cold_day
else:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.cold_day
house_scheduling_evening:
alias: 'House Scheduling Evening'
sequence:
- service: input_datetime.set_datetime
entity_id: input_datetime.nightly_briefing
data:
time: >
{{ (state_attr('input_datetime.kallen_bedtime','timestamp') - 3600) | timestamp_custom('%H:%M', false) }}
- service: input_datetime.set_datetime
entity_id: input_datetime.audible_notification_off
data:
time: >
{% if is_state('sensor.kallen_school_tomorrow','on') %}
22:00
{% else %}
23:00
{% endif %}
master_bedroom_scheduling_morning:
alias: 'Master Bedroom Scheduling Morning'
sequence:
- service: input_datetime.set_datetime
entity_id: input_datetime.master_bedroom_wakeup
data:
time: >
{% if is_state('input_boolean.kallen_school_today','on') %}
{% if is_state('input_boolean.kallen_school_early_release','on') %}
12:30
{% else %}
13:30
{% endif %}
{% else %}
13:00
{% endif %}
master_bedroom_scheduling_evening:
alias: 'Master Bedroom Scheduling Evening'
sequence:
- service: input_datetime.set_datetime
entity_id: input_datetime.master_bedroom_cooling
data:
time: >
{% set low = states('sensor.tonights_low_temp') | int %}
{% 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.kallen_school_tomorrow','off') %}
21:00
{% elif low >= 56 and low <= 60 %}
22:30
{% elif low > 60 %}
21:30
{% else %}
00:00
{% endif %}
- service: input_datetime.set_datetime
entity_id: input_datetime.master_bedroom_fan
data:
time: >
{% set low = states('sensor.tonights_low_temp') | int %}
{% set high = states('sensor.todays_high_temp') | int %}
{% if low > 60 or is_state('input_boolean.hot_day','on') %}
22:30
{% elif low <= 60 and low >= 50 %}
23:30
{% elif low >= states('input_number.master_bedroom_fan_threshold') | int and high > 60 %}
00:00
{% else %}
06:00
{% endif %}
- service: input_select.select_option
target:
entity_id: input_select.scheduled_climate_mode_master_bedroom_aircon
data:
option: >
{% if is_state('input_boolean.master_bedroom_aircon_installed','off') %}
N/A
{% elif (states('sensor.tonights_low_temp') | int) >= (states('input_number.master_bedroom_aircon_run_threshold') | int) %}
{% if (states('sensor.tonights_low_temp') | int) >= (states('input_number.master_bedroom_aircon_mode_threshold') | int) %}
AC
{% else %}
Fan
{% endif %}
{% else %}
N/A
{% endif %}
- service: input_select.select_option
target:
entity_id: input_select.scheduled_climate_mode_master_bedroom_fan
data:
option: >
{% if (states('sensor.tonights_low_temp') | int) >= (states('input_number.master_bedroom_fan_threshold') | int) %}
Fan
{% else %}
N/A
{% endif %}
# For now, this just ties her wakeup time to the master bedroom wakeup time. In the future this will have more conditions and be independent of other rooms.
emma_bedroom_scheduling_morning:
alias: 'Emma Bedroom Scheduling Morning'
sequence:
- service: input_datetime.set_datetime
entity_id: input_datetime.emma_wakeup
data:
time: "{{ states('input_datetime.master_bedroom_wakeup') }}"
emma_bedroom_scheduling_evening:
alias: 'Emma Bedroom Scheduling Evening'
sequence:
- service: input_datetime.set_datetime
entity_id: input_datetime.emma_bedtime
data:
time: >
{% set high = states('sensor.todays_high_temp') | int %}
{% set low = states('sensor.tonights_low_temp') | int %}
{% if is_state('input_boolean.hot_day','on') %}
22:00
{% elif high >= 80 or low >= 60 %}
23:00
{% else %}
23:45
{% endif %}
- service: input_select.select_option
target:
entity_id: input_select.scheduled_climate_mode_emma_aircon
data:
option: >
{% if is_state('input_boolean.emma_bedroom_aircon_installed','on') %}
{% if (states('sensor.tonights_low_temp') | int) >= (states('input_number.emma_aircon_threshold') | int) %}
AC
{% else %}
White Noise
{% endif %}
{% else %}
White Noise
{% endif %}
security_scheduling:
alias: Security Scheduling
sequence:
- service: input_datetime.set_datetime
entity_id: input_datetime.morning_alarm_disarm
data:
time: >
{% set ct = ((now().hour * 60 + now().minute) * 60 ) %}
{% if is_state('input_boolean.work_today','on') and is_state('input_boolean.kallen_school_today','on') %}
{% if ct > state_attr('input_datetime.kallen_school_day_start','timestamp') %}
{{ (state_attr('input_datetime.tina_workday_start','timestamp') - 1800) | timestamp_custom('%H:%M', false) }}
{% elif ct > state_attr('input_datetime.tina_workday_start','timestamp') and ct < state_attr('input_datetime.kallen_school_day_start','timestamp') %}
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') - 2700) | timestamp_custom('%H:%M', false) }}
{% elif state_attr('input_datetime.tina_workday_start','timestamp') < (state_attr('input_datetime.kallen_school_day_start','timestamp')) %}
{{ (state_attr('input_datetime.tina_workday_start','timestamp') - 1800) | timestamp_custom('%H:%M', false) }}
{% else %}
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') - 2700) | timestamp_custom('%H:%M', false) }}
{% endif %}
{% elif is_state('input_boolean.work_today','on') and is_state('input_boolean.kallen_school_today','off') %}
{{ (state_attr('input_datetime.tina_workday_start', 'timestamp') - 1800) | timestamp_custom('%H:%M', false) }}
{% elif is_state('input_boolean.kallen_school_today','on') %}
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') - 2700) | timestamp_custom('%H:%M', false) }}
{% else %}
11:00
{% endif %}
- service: input_datetime.set_datetime
entity_id: input_datetime.morning_alarm_rearm
data:
time: >
{% set ct = ((now().hour * 60 + now().minute) * 60 ) %}
{% if is_state('input_boolean.work_today','on') and is_state('input_boolean.kallen_school_today','off') %}
{{ (state_attr('input_datetime.tina_workday_start','timestamp') + 900) | timestamp_custom('%H:%M', false) }}
{% elif is_state('input_boolean.kallen_school_today','on') and is_state('input_boolean.work_today','off') %}
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') + 3600) | timestamp_custom('%H:%M', false) }}
{% elif is_state('input_boolean.work_today','on') and is_state('input_boolean.kallen_school_today','on') %}
{% if ct > state_attr('input_datetime.kallen_school_day_start','timestamp') %}
{{ (state_attr('input_datetime.tina_workday_start','timestamp') + 900) | timestamp_custom('%H:%M', false) }}
{% elif ct > state_attr('input_datetime.tina_workday_start','timestamp') and ct < state_attr('input_datetime.kallen_school_day_start','timestamp') %}
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') - 2700) | timestamp_custom('%H:%M', false) }}
{% elif state_attr('input_datetime.tina_workday_start','timestamp') < state_attr('input_datetime.kallen_school_day_start','timestamp') %}
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') + 1800) | timestamp_custom('%H:%M', false) }}
{% else %}
{% if (state_attr('input_datetime.tina_workday_start','timestamp') - state_attr('input_datetime.kallen_school_day_start','timestamp')) > 5400 %}
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') + 1800) | timestamp_custom('%H:%M', false) }}
{% else %}
{{ (state_attr('input_datetime.tina_workday_start','timestamp') + 900) | timestamp_custom('%H:%M', false) }}
{% endif %}
{% endif %}
{% else %}
12:00
{% endif %}
rerun_all_scheduling_morning:
alias: 'Rerun All Scheduling - Morning'
sequence:
- service: script.kallen_scheduling_morning
- delay:
seconds: 1
- service: script.house_scheduling_morning
- delay:
seconds: 1
- service: script.emma_bedroom_scheduling_morning
- delay:
seconds: 1
- service: script.master_bedroom_scheduling_morning
- delay:
seconds: 1
- service: script.security_scheduling
rerun_all_scheduling_evening:
alias: 'Rerun All Scheduling - Evening'
sequence:
- service: script.kallen_scheduling_evening
- delay:
seconds: 1
- service: script.house_scheduling_evening
- delay:
seconds: 1
- service: script.master_bedroom_scheduling_evening
- delay:
seconds: 1
- service: script.emma_bedroom_scheduling_evening
- delay:
seconds: 1
- service: script.security_scheduling