867 lines
36 KiB
YAML
867 lines
36 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
|
|
|
|
input_boolean:
|
|
# Turned on when scheduling automations run, reset at midnight
|
|
# This tracks whether scheduling has already been run, to be used as conditions in automations/scripts
|
|
work_today_ran:
|
|
name: Work Today Ran
|
|
icon: mdi:clock-outline
|
|
school_today_ran:
|
|
name: School Today Ran
|
|
icon: mdi:clock-outline
|
|
kallen_scheduling_morning_ran:
|
|
name: Kallen Scheduling Morning Ran
|
|
icon: mdi:clock-outline
|
|
kallen_scheduling_evening_ran:
|
|
name: Kallen Scheduling Evening Ran
|
|
icon: mdi:clock-outline
|
|
house_scheduling_morning_ran:
|
|
name: House Scheduling Morning Ran
|
|
icon: mdi:clock-outline
|
|
house_scheduling_evening_ran:
|
|
name: House Scheduling Evening Ran
|
|
icon: mdi:clock-outline
|
|
emma_scheduling_morning_ran:
|
|
name: Emma Scheduling Morning Ran
|
|
icon: mdi:clock-outline
|
|
emma_scheduling_evening_ran:
|
|
name: Emma Scheduling Evening Ran
|
|
icon: mdi:clock-outline
|
|
master_bedroom_scheduling_morning_ran:
|
|
name: Master Bedroom Scheduling Morning Ran
|
|
icon: mdi:clock-outline
|
|
master_bedroom_scheduling_evening_ran:
|
|
name: Master Bedroom Scheduling Evening Ran
|
|
icon: mdi:clock-outline
|
|
# Overrides
|
|
# These will prevent certain schedules from being modified by the scripts, in case you want to set them yourself
|
|
kallen_wakeup_override:
|
|
name: Kallen Wakeup Override
|
|
icon: mdi:plus-circle-outline
|
|
kallen_bedtime_override:
|
|
name: Kallen Bedtime Override
|
|
icon: mdi:plus-circle-outline
|
|
emma_wakeup_override:
|
|
name: Emma Wakeup Override
|
|
icon: mdi:plus-circle-outline
|
|
emma_bedtime_override:
|
|
name: Emma Bedtime Override
|
|
icon: mdi:plus-circle-outline
|
|
master_bedroom_wakeup_override:
|
|
name: Master Bedroom Wakeup Override
|
|
icon: mdi:plus-circle-outline
|
|
tina_work_schedule_override:
|
|
name: Tina Work Schedule Override
|
|
icon: mdi:plus-circle-outline
|
|
house_briefing_times_override:
|
|
name: House Briefing Times Override
|
|
icon: mdi:plus-circle-outline
|
|
kallen_briefing_times_override:
|
|
name: Kallen Briefing Times Override
|
|
icon: mdi:plus-circle-outline
|
|
master_bedroom_climate_override:
|
|
name: Master Bedroom Climate Override
|
|
icon: mdi:plus-circle-outline
|
|
kallen_bedroom_climate_override:
|
|
name: Kallen Bedroom Climate Override
|
|
icon: mdi:plus-circle-outline
|
|
emma_bedroom_climate_override:
|
|
name: Emma Bedroom Climate Override
|
|
icon: mdi:plus-circle-outline
|
|
|
|
input_text:
|
|
kallen_pickup:
|
|
name: Kallen Pickup
|
|
icon: mdi:car
|
|
|
|
################################################
|
|
# 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: 82a3bfde-0c51-47cf-be17-aaf4fea47ee6
|
|
alias: Scheduler
|
|
trigger:
|
|
- platform: time
|
|
at: '04:00:00'
|
|
id: morning-scheduling
|
|
- platform: time
|
|
at: '17:05:00'
|
|
id: evening-scheduling
|
|
action:
|
|
- choose:
|
|
- conditions:
|
|
- condition: trigger
|
|
id: morning-scheduling
|
|
sequence:
|
|
- service: script.kallen_scheduling_morning
|
|
- delay:
|
|
seconds: 1
|
|
- service: script.house_scheduling_morning
|
|
- delay:
|
|
seconds: 1
|
|
- service: script.master_bedroom_scheduling_morning
|
|
- delay:
|
|
seconds: 1
|
|
- service: script.emma_bedroom_scheduling_morning
|
|
- delay:
|
|
seconds: 1
|
|
- service: script.security_scheduling
|
|
- conditions:
|
|
- condition: trigger
|
|
id: evening-scheduling
|
|
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
|
|
|
|
script:
|
|
kallen_scheduling_morning:
|
|
alias: 'Kallen Scheduling Morning'
|
|
sequence:
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.kallen_school_today
|
|
state: 'on'
|
|
then:
|
|
- service: input_datetime.set_datetime
|
|
entity_id: input_datetime.kallen_school_day_start
|
|
data:
|
|
time: >
|
|
{% from 'time.jinja' import time_from_calendar %}
|
|
{% if is_state('input_boolean.two_hour_delay','on') %}
|
|
{{ time_from_calendar('calendar.kallen_school_days','start_time','set','add',2)}}
|
|
{% else %}
|
|
{{ time_from_calendar('calendar.kallen_school_days','start_time','set') }}
|
|
{% endif %}
|
|
- delay:
|
|
seconds: 1
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.kallen_wakeup_override
|
|
state: 'off'
|
|
then:
|
|
- 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') %}
|
|
08:30
|
|
{% else %}
|
|
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') - 5400) | timestamp_custom('%H:%M', false) }}
|
|
{% endif %}
|
|
{% else %}
|
|
12: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 %}
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.kallen_briefing_times_override
|
|
state: 'off'
|
|
then:
|
|
- 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') %}
|
|
08:40
|
|
{% else %}
|
|
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') - 4800) | timestamp_custom('%H:%M', false) }}
|
|
{% endif %}
|
|
{% else %}
|
|
12:00
|
|
{% endif %}
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.kallen_school_today
|
|
state: 'on'
|
|
then:
|
|
- 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') %}
|
|
09: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:00
|
|
{% else %}
|
|
{{ (state_attr('input_datetime.kallen_school_day_start','timestamp') - 5400) | timestamp_custom('%H:%M', false) }}
|
|
{% endif %}
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.kallen_morning_meds_notify
|
|
data:
|
|
datetime: >
|
|
{% set date = now().strftime('%Y-%m-%d') %}
|
|
{% set wakeup = state_attr('input_datetime.kallen_wakeup_time','timestamp') | int %}
|
|
{% set wakeup_mod = (wakeup + 600) | timestamp_custom('%T',false) %}
|
|
{% if is_state('input_boolean.kallen_school_today','on') %}
|
|
{{ date + ' ' + wakeup_mod }}
|
|
{% else %}
|
|
{{ date + ' ' + states('input_datetime.kallen_wakeup_time') }}
|
|
{% endif %}
|
|
- service: input_boolean.turn_on
|
|
target:
|
|
entity_id: input_boolean.kallen_scheduling_morning_ran
|
|
|
|
kallen_scheduling_evening:
|
|
alias: 'Kallen Scheduling Evening'
|
|
sequence:
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.kallen_bedtime_override
|
|
state: 'off'
|
|
then:
|
|
- service: input_datetime.set_datetime
|
|
entity_id: input_datetime.kallen_bedtime
|
|
data:
|
|
time: >
|
|
{% if is_state('input_boolean.school_in_session','on') %}
|
|
{% if is_state('binary_sensor.kallen_school_tomorrow', 'on') %}
|
|
22:00
|
|
{% else %}
|
|
23:00
|
|
{% endif %}
|
|
{% else %}
|
|
{% if is_state('binary_sensor.kallen_btb_tomorrow','on') %}
|
|
23:00
|
|
{% else %}
|
|
00:00
|
|
{% endif %}
|
|
{% endif %}
|
|
- delay:
|
|
seconds: 1
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.kallen_briefing_times_override
|
|
state: 'off'
|
|
then:
|
|
- service: input_datetime.set_datetime
|
|
entity_id: input_datetime.kallen_nightly_briefing
|
|
data:
|
|
time: "{{ (state_attr('input_datetime.kallen_bedtime','timestamp') - 1200) | timestamp_custom('%H:%M', false) }}"
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.kallen_bedroom_climate_override
|
|
state: 'off'
|
|
then:
|
|
- service: input_select.select_option
|
|
target:
|
|
entity_id: input_select.scheduled_climate_mode_kallen_bedroom
|
|
data:
|
|
option: >
|
|
{% if is_state('input_boolean.kallen_overnight','on') %}
|
|
N/A
|
|
{% elif (states('sensor.overnight_lowest_temperature') | int) >= (states('input_number.kallen_fan_threshold') | int) %}
|
|
Fan
|
|
{% else %}
|
|
White Noise
|
|
{% endif %}
|
|
- 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 %}
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.kallen_night_meds_notify
|
|
data:
|
|
datetime: >
|
|
{% set bedtime = state_attr('input_datetime.kallen_bedtime','timestamp') | int %}
|
|
{% set bedtime_mod = (bedtime - 600) | timestamp_custom('%T',false) %}
|
|
{% if bedtime < 13800 %}
|
|
{% set date = (as_timestamp(now()) + 86400) | timestamp_custom("%Y-%m-%d", True) %}
|
|
{% else %}
|
|
{% set date = now().strftime('%Y-%m-%d') %}
|
|
{% endif %}
|
|
{{ date + ' ' + bedtime_mod }}
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.kallen_late_bedtime
|
|
state: 'on'
|
|
then:
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.kallen_bedtime
|
|
data:
|
|
time: "{{ (state_attr('input_datetime.kallen_bedtime','timestamp') + 3600) | timestamp_custom('%H:%M', false) }}"
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.kallen_nightly_briefing
|
|
data:
|
|
time: "{{ (state_attr('input_datetime.kallen_nightly_briefing','timestamp') + 3600) | timestamp_custom('%H:%M', false) }}"
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.kallen_bedroom_climate_override
|
|
state: 'off'
|
|
then:
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.kallen_fan
|
|
data:
|
|
time: "{{ (state_attr('input_datetime.kallen_fan','timestamp') + 3600) | timestamp_custom('%H:%M', false) }}"
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.kallen_night_meds_notify
|
|
data:
|
|
datetime: "{{ (state_attr('input_datetime.kallen_night_meds_notify','timestamp') + 3600) | timestamp_custom('%Y-%m-%d %H:%M:%S') }}"
|
|
- service: input_boolean.turn_on
|
|
target:
|
|
entity_id: input_boolean.kallen_scheduling_evening_ran
|
|
|
|
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 %}
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.house_briefing_times_override
|
|
state: 'off'
|
|
then:
|
|
- service: input_datetime.set_datetime
|
|
entity_id: input_datetime.morning_briefing
|
|
data:
|
|
time: >
|
|
{% set kallenbriefing = state_attr('input_datetime.kallen_morning_briefing','timestamp') %}
|
|
{% set kallenloc = states('input_select.kallen_morning_briefing_location') %}
|
|
{% if is_state('input_boolean.kallen_school_today','on') %}
|
|
{{ (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','off') %}
|
|
{% if (state_attr('input_datetime.tina_workday_start','timestamp')) > 43200 %}
|
|
{% if kallenloc == 'Common Areas' and kallenbriefing == 43200 %}
|
|
12:05
|
|
{% else %}
|
|
12:00
|
|
{% endif %}
|
|
{% 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 %}
|
|
{% if kallenloc == 'Common Areas' and kallenbriefing == 43200 %}
|
|
12:05
|
|
{% else %}
|
|
12:00
|
|
{% endif %}
|
|
{% endif %}
|
|
- service: input_datetime.set_datetime
|
|
entity_id: input_datetime.daily_briefing
|
|
data:
|
|
time: >
|
|
{% from 'time.jinja' import time_from_calendar %}
|
|
{% if is_state('input_boolean.kallen_school_today','on') %}
|
|
{% if is_state('input_boolean.kallen_alternate_pickup','on') or is_state('input_boolean.kallen_btb','on') %}
|
|
15:30
|
|
{% else %}
|
|
{{ time_from_calendar('calendar.kallen_school_days','end_time','set','subtract',1) }}
|
|
{% endif %}
|
|
{% elif is_state('input_boolean.kallen_school_today','off') and is_state('input_boolean.work_today','off') %}
|
|
15:30
|
|
{% 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: state
|
|
entity_id: sensor.today_is
|
|
state: 'Monday'
|
|
then:
|
|
- if:
|
|
- condition: template
|
|
value_template: >
|
|
{% from 'easy_time.jinja' import count_the_days, month_week_day %}
|
|
{% set month = as_timestamp(now()) | timestamp_custom('%-m') | int %}
|
|
{% set largepickup = month_week_day(month,3,2) %}
|
|
{% set countdown = count_the_days(largepickup) | int %}
|
|
{{ 0 <= countdown < 7 }}
|
|
then:
|
|
- service: calendar.create_event
|
|
target:
|
|
entity_id: calendar.garbage_collection
|
|
data:
|
|
summary: Large Garbage Pickup
|
|
description: Bulk items ARE accepted
|
|
start_date: >
|
|
{% from 'easy_time.jinja' import this_weekday, count_the_days %}
|
|
{% set holiday = state_attr('calendar.holidays','next_holiday') %}
|
|
{% if holiday in ["New Year's Day","Memorial Day","Independence Day","Labor Day","Thanksgiving","Christmas"] and count_the_days('calendar.holidays','start_time') | int <= 4 %}
|
|
{{ as_timestamp(this_weekday(3)) | timestamp_custom('%Y-%m-%d') }}
|
|
{% else %}
|
|
{{ as_timestamp(this_weekday(2)) | timestamp_custom('%Y-%m-%d') }}
|
|
{% endif %}
|
|
end_date: >
|
|
{% from 'easy_time.jinja' import this_weekday, count_the_days %}
|
|
{% set holiday = state_attr('calendar.holidays','next_holiday') %}
|
|
{% if holiday in ["New Year's Day","Memorial Day","Independence Day","Labor Day","Thanksgiving","Christmas"] and count_the_days('calendar.holidays','start_time') | int <= 4 %}
|
|
{{ as_timestamp(this_weekday(4)) | timestamp_custom('%Y-%m-%d') }}
|
|
{% else %}
|
|
{{ as_timestamp(this_weekday(3)) | timestamp_custom('%Y-%m-%d') }}
|
|
{% endif %}
|
|
else:
|
|
- service: calendar.create_event
|
|
target:
|
|
entity_id: calendar.garbage_collection
|
|
data:
|
|
summary: Normal Garbage Pickup
|
|
description: Bulk items not accepted
|
|
start_date: >
|
|
{% from 'easy_time.jinja' import this_weekday, count_the_days %}
|
|
{% set holiday = state_attr('calendar.holidays','next_holiday') %}
|
|
{% if holiday in ["New Year's Day","Memorial Day","Independence Day","Labor Day","Thanksgiving","Christmas"] and count_the_days('calendar.holidays','start_time') | int <= 4 %}
|
|
{{ as_timestamp(this_weekday(3)) | timestamp_custom('%Y-%m-%d') }}
|
|
{% else %}
|
|
{{ as_timestamp(this_weekday(2)) | timestamp_custom('%Y-%m-%d') }}
|
|
{% endif %}
|
|
end_date: >
|
|
{% from 'easy_time.jinja' import this_weekday, count_the_days %}
|
|
{% set holiday = state_attr('calendar.holidays','next_holiday') %}
|
|
{% if holiday in ["New Year's Day","Memorial Day","Independence Day","Labor Day","Thanksgiving","Christmas"] and count_the_days('calendar.holidays','start_time') | int <= 4 %}
|
|
{{ as_timestamp(this_weekday(4)) | timestamp_custom('%Y-%m-%d') }}
|
|
{% else %}
|
|
{{ as_timestamp(this_weekday(3)) | timestamp_custom('%Y-%m-%d') }}
|
|
{% endif %}
|
|
- if:
|
|
- condition: state
|
|
entity_id: binary_sensor.heat_warning
|
|
state: 'on'
|
|
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: "{{ states('sensor.todays_high_temp') | int <= states('input_number.cold_day_threshold') | int }}"
|
|
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
|
|
- service: input_boolean.turn_on
|
|
target:
|
|
entity_id: input_boolean.house_scheduling_morning_ran
|
|
|
|
house_scheduling_evening:
|
|
alias: 'House Scheduling Evening'
|
|
sequence:
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.house_briefing_times_override
|
|
state: 'off'
|
|
then:
|
|
- service: input_datetime.set_datetime
|
|
entity_id: input_datetime.nightly_briefing
|
|
data:
|
|
time: >
|
|
{% if is_state('input_boolean.kallen_late_bedtime','on') %}
|
|
{{ (state_attr('input_datetime.kallen_bedtime','timestamp') - 7200) | timestamp_custom('%H:%M', false) }}
|
|
{% else %}
|
|
{{ (state_attr('input_datetime.kallen_bedtime','timestamp') - 3600) | timestamp_custom('%H:%M', false) }}
|
|
{% endif %}
|
|
- service: input_datetime.set_datetime
|
|
entity_id: input_datetime.audible_notification_off
|
|
data:
|
|
time: >
|
|
{% if is_state('binary_sensor.kallen_school_tomorrow','on') %}
|
|
22:15
|
|
{% else %}
|
|
23:15
|
|
{% endif %}
|
|
- service: input_boolean.turn_on
|
|
target:
|
|
entity_id: input_boolean.house_scheduling_evening_ran
|
|
|
|
master_bedroom_scheduling_morning:
|
|
alias: 'Master Bedroom Scheduling Morning'
|
|
sequence:
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.master_bedroom_wakeup_override
|
|
state: 'off'
|
|
then:
|
|
- 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_alternate_pickup','on') or is_state('input_boolean.kallen_btb','on') %}
|
|
16:30
|
|
{% elif is_state('input_boolean.kallen_school_early_release','on') %}
|
|
12:30
|
|
{% else %}
|
|
13:00
|
|
{% endif %}
|
|
{% else %}
|
|
16:30
|
|
{% endif %}
|
|
- delay:
|
|
milliseconds: 500
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.tony_morning_meds_notify
|
|
data:
|
|
time: "{{ states('input_datetime.master_bedroom_wakeup') }}"
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.tony_afternoon_meds_notify
|
|
data:
|
|
time: >
|
|
{% set interval = states('input_number.tony_afternoon_meds_interval') | int %}
|
|
{% set math = ((interval * 60) * 60) | int %}
|
|
{% set wakeup = state_attr('input_datetime.master_bedroom_wakeup','timestamp') | int %}
|
|
{{ (wakeup + math) | timestamp_custom('%H:%M', false) }}
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.tina_morning_meds_notify
|
|
data:
|
|
datetime: >
|
|
{% from 'time.jinja' import datetime_from_calendar %}
|
|
{% set date = now().strftime('%Y-%m-%d') %}
|
|
{% if is_state('input_boolean.work_today','on') %}
|
|
{{ datetime_from_calendar('calendar.family_tinawork','start_time','set','subtract',0,0,30) }}
|
|
{% else %}
|
|
{{ date + ' ' + states('input_datetime.master_bedroom_wakeup') }}
|
|
{% endif %}
|
|
- service: input_boolean.turn_on
|
|
target:
|
|
entity_id: input_boolean.master_bedroom_scheduling_morning_ran
|
|
|
|
master_bedroom_scheduling_evening:
|
|
alias: 'Master Bedroom Scheduling Evening'
|
|
sequence:
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.master_bedroom_climate_override
|
|
state: 'off'
|
|
then:
|
|
- service: input_datetime.set_datetime
|
|
entity_id: input_datetime.master_bedroom_cooling
|
|
data:
|
|
time: >
|
|
{% set low = states('sensor.overnight_lowest_temperature') | int %}
|
|
{% set kallen_bedtime = state_attr('input_datetime.kallen_bedtime','timestamp') | int %}
|
|
{% set cutoff = 81000 %}
|
|
{% if is_state('input_boolean.hot_day','on') and is_state('binary_sensor.kallen_school_tomorrow','on') %}
|
|
{{ (kallen_bedtime - 3600) | timestamp_custom('%H:%M',false) }}
|
|
{% elif is_state('input_boolean.hot_day','on') and is_state('binary_sensor.kallen_school_tomorrow','off') %}
|
|
{{ kallen_bedtime | timestamp_custom('%H:%M',false) }}
|
|
{% elif 56 <= low <= 60 %}
|
|
22:30
|
|
{% elif low > 60 %}
|
|
{% if kallen_bedtime < cutoff %}
|
|
{{ kallen_bedtime | timestamp_custom('%H:%M',false) }}
|
|
{% else %}
|
|
21:30
|
|
{% endif %}
|
|
{% else %}
|
|
00:00
|
|
{% endif %}
|
|
- service: input_datetime.set_datetime
|
|
entity_id: input_datetime.master_bedroom_fan
|
|
data:
|
|
time: >
|
|
{% set low = states('sensor.overnight_lowest_temperature') | int %}
|
|
{% set high = states('sensor.todays_high_temp') | int %}
|
|
{% if low > 60 or is_state('input_boolean.hot_day','on') %}
|
|
00:00
|
|
{% elif 50 <= low <= 60 %}
|
|
01:00
|
|
{% elif low >= states('input_number.master_bedroom_fan_threshold') | int and high > 60 %}
|
|
02:00
|
|
{% else %}
|
|
06:00
|
|
{% endif %}
|
|
- service: input_select.select_option
|
|
target:
|
|
entity_id: input_select.scheduled_climate_mode_master_bedroom_aircon
|
|
data:
|
|
option: >
|
|
{% set low = states('sensor.overnight_lowest_temperature') | int %}
|
|
{% set run_threshold = states('input_number.master_bedroom_aircon_run_threshold') | int %}
|
|
{% set mode_threshold = states('input_number.master_bedroom_aircon_mode_threshold') | int %}
|
|
{% if is_state('input_boolean.master_bedroom_aircon_installed','off') %}
|
|
N/A
|
|
{% elif low >= run_threshold %}
|
|
{% if low >= mode_threshold %}
|
|
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: >
|
|
{% set low = states('sensor.overnight_lowest_temperature') | int %}
|
|
{% set fan_threshold = states('input_number.master_bedroom_fan_threshold') | int %}
|
|
{% if low >= fan_threshold %}
|
|
Fan
|
|
{% else %}
|
|
N/A
|
|
{% endif %}
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.tina_night_meds_notify
|
|
data:
|
|
datetime: "{{ (as_timestamp(now()) + 86400) | timestamp_custom('%Y-%m-%d', True) + ' 03:00:00' }}"
|
|
- service: input_boolean.turn_on
|
|
target:
|
|
entity_id: input_boolean.master_bedroom_scheduling_evening_ran
|
|
|
|
emma_bedroom_scheduling_morning:
|
|
alias: 'Emma Bedroom Scheduling Morning'
|
|
sequence:
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.emma_wakeup_override
|
|
state: 'off'
|
|
then:
|
|
- service: input_datetime.set_datetime
|
|
entity_id: input_datetime.emma_wakeup
|
|
data:
|
|
time: "{{ states('input_datetime.master_bedroom_wakeup') }}"
|
|
- service: input_boolean.turn_on
|
|
target:
|
|
entity_id: input_boolean.emma_scheduling_morning_ran
|
|
|
|
emma_bedroom_scheduling_evening:
|
|
alias: 'Emma Bedroom Scheduling Evening'
|
|
sequence:
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.emma_bedtime_override
|
|
state: 'off'
|
|
then:
|
|
- service: input_datetime.set_datetime
|
|
entity_id: input_datetime.emma_bedtime
|
|
data:
|
|
time: >
|
|
{% set awake = state_attr('input_datetime.emma_awake_at','timestamp') | int %}
|
|
{% set hours = states('input_number.emma_bedtime_hours') | int %}
|
|
{% set math = (hours * 60) * 60 %}
|
|
{{ (awake + math) | timestamp_custom('%H:%M',false) }}
|
|
- if:
|
|
- condition: state
|
|
entity_id: input_boolean.emma_bedroom_climate_override
|
|
state: 'off'
|
|
then:
|
|
- service: input_select.select_option
|
|
target:
|
|
entity_id: input_select.scheduled_climate_mode_emma_bedroom
|
|
data:
|
|
option: >
|
|
{% if is_state('input_boolean.emma_bedroom_aircon_installed','on') %}
|
|
{% if (states('sensor.overnight_lowest_temperature') | int) >= (states('input_number.emma_aircon_threshold') | int) %}
|
|
AC
|
|
{% else %}
|
|
White Noise
|
|
{% endif %}
|
|
{% else %}
|
|
White Noise
|
|
{% endif %}
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.emma_bedroom_cooling
|
|
data:
|
|
time: >
|
|
{% set high = states('sensor.todays_high_temp') | int %}
|
|
{% set low = states('sensor.overnight_lowest_temperature') | int %}
|
|
{% set bedtime = state_attr('input_datetime.emma_bedtime','timestamp') | int %}
|
|
{% if is_state('input_boolean.hot_day','on') %}
|
|
{{ (bedtime - 7200) | timestamp_custom('%H:%M',false) }}
|
|
{% elif high >= 80 or low >= 60 %}
|
|
{{ (bedtime - 5400) | timestamp_custom('%H:%M',false) }}
|
|
{% else %}
|
|
{{ (bedtime - 3600) | timestamp_custom('%H:%M',false) }}
|
|
{% endif %}
|
|
- service: input_boolean.turn_on
|
|
target:
|
|
entity_id: input_boolean.emma_scheduling_evening_ran
|
|
|
|
security_scheduling:
|
|
alias: Security Scheduling
|
|
sequence:
|
|
- service: input_datetime.set_datetime
|
|
entity_id: input_datetime.morning_alarm_disarm
|
|
data:
|
|
time: >
|
|
{% from 'time.jinja' import ct %}
|
|
{% set ct = ct() | int %}
|
|
{% 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') - 3900) | 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') - 3900) | 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') - 3900) | timestamp_custom('%H:%M', false) }}
|
|
{% else %}
|
|
11:00
|
|
{% endif %}
|
|
- service: input_datetime.set_datetime
|
|
entity_id: input_datetime.morning_alarm_rearm
|
|
data:
|
|
time: >
|
|
{% from 'time.jinja' import ct %}
|
|
{% set ct = ct() | int %}
|
|
{% 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.master_bedroom_scheduling_morning
|
|
- delay:
|
|
seconds: 1
|
|
- service: script.emma_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
|
|
|
|
scheduling_reset:
|
|
alias: 'Scheduling Reset'
|
|
sequence:
|
|
- service: input_boolean.turn_off
|
|
target:
|
|
entity_id:
|
|
- input_boolean.work_today_ran
|
|
- input_boolean.school_today_ran
|
|
- input_boolean.kallen_scheduling_morning_ran
|
|
- input_boolean.kallen_scheduling_evening_ran
|
|
- input_boolean.house_scheduling_morning_ran
|
|
- input_boolean.house_scheduling_evening_ran
|
|
- input_boolean.master_bedroom_scheduling_morning_ran
|
|
- input_boolean.master_bedroom_scheduling_evening_ran
|
|
- input_boolean.emma_scheduling_morning_ran
|
|
- input_boolean.emma_scheduling_evening_ran
|
|
- input_boolean.kallen_late_bedtime |