Moved more automation actions to scripts for modularity's sake
This commit is contained in:
@ -170,32 +170,8 @@ automation:
|
|||||||
{%- if as_timestamp(strptime(state_attr('calendar.kallen_school_days', 'start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%Y-%m-%d") == now().strftime("%Y-%m-%d") %}
|
{%- if as_timestamp(strptime(state_attr('calendar.kallen_school_days', 'start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%Y-%m-%d") == now().strftime("%Y-%m-%d") %}
|
||||||
true
|
true
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
action:
|
action:
|
||||||
- choose:
|
- service: script.kallen_school_today
|
||||||
- conditions:
|
|
||||||
- condition: template
|
|
||||||
value_template: >
|
|
||||||
{{ 'Early Release' in states('sensor.school_event') }}
|
|
||||||
sequence:
|
|
||||||
- service: input_boolean.turn_on
|
|
||||||
entity_id: input_boolean.school_early_release
|
|
||||||
- service: input_datetime.set_datetime
|
|
||||||
target:
|
|
||||||
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_end
|
|
||||||
data:
|
|
||||||
time: "15:20:00"
|
|
||||||
- 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
|
|
||||||
|
|
||||||
- id: cd9f921f-71c7-4e29-9aee-7421ef19bdd3
|
- id: cd9f921f-71c7-4e29-9aee-7421ef19bdd3
|
||||||
alias: Work Today
|
alias: Work Today
|
||||||
@ -210,21 +186,7 @@ automation:
|
|||||||
true
|
true
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
action:
|
action:
|
||||||
- service: input_datetime.set_datetime
|
- service: script.tina_work_today
|
||||||
target:
|
|
||||||
entity_id: input_datetime.tina_workday_start
|
|
||||||
data:
|
|
||||||
time: >
|
|
||||||
{{ as_timestamp(strptime(state_attr('calendar.family_tinawork','start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }}
|
|
||||||
- service: input_datetime.set_datetime
|
|
||||||
target:
|
|
||||||
entity_id: input_datetime.tina_workday_end
|
|
||||||
data:
|
|
||||||
time: >
|
|
||||||
{{ as_timestamp(strptime(state_attr('calendar.family_tinawork','end_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }}
|
|
||||||
- service: input_boolean.turn_on
|
|
||||||
entity_id: input_boolean.work_today
|
|
||||||
|
|
||||||
|
|
||||||
- id: b9028665-401c-4de3-8f13-1099160b011f
|
- id: b9028665-401c-4de3-8f13-1099160b011f
|
||||||
alias: School Reset
|
alias: School Reset
|
||||||
@ -236,22 +198,8 @@ automation:
|
|||||||
- platform: time
|
- platform: time
|
||||||
at: 00:00
|
at: 00:00
|
||||||
id: midnight
|
id: midnight
|
||||||
action:
|
action:
|
||||||
- if:
|
- service: script.kallen_school_reset
|
||||||
- condition: trigger
|
|
||||||
id: day_end
|
|
||||||
then:
|
|
||||||
- service: input_boolean.turn_off
|
|
||||||
entity_id:
|
|
||||||
- input_boolean.school_today
|
|
||||||
- input_boolean.kallen_two_hour_delay
|
|
||||||
- input_boolean.kallen_school_cancelled
|
|
||||||
- if:
|
|
||||||
- condition: trigger
|
|
||||||
id: midnight
|
|
||||||
then:
|
|
||||||
- service: input_boolean.turn_off
|
|
||||||
entity_id: input_boolean.school_today_extended
|
|
||||||
|
|
||||||
- id: a6eeb075-d21b-436c-983f-39188ee9b016
|
- id: a6eeb075-d21b-436c-983f-39188ee9b016
|
||||||
alias: Work Reset
|
alias: Work Reset
|
||||||
@ -259,9 +207,8 @@ automation:
|
|||||||
trigger:
|
trigger:
|
||||||
- platform: time
|
- platform: time
|
||||||
at: input_datetime.tina_workday_end
|
at: input_datetime.tina_workday_end
|
||||||
action:
|
action:
|
||||||
- service: input_boolean.turn_off
|
- service: script.tina_work_reset
|
||||||
entity_id: input_boolean.work_today
|
|
||||||
|
|
||||||
- id: 05ee0f8d-5411-4486-8acf-9bfadad2b23a
|
- id: 05ee0f8d-5411-4486-8acf-9bfadad2b23a
|
||||||
alias: End of School Year
|
alias: End of School Year
|
||||||
@ -278,22 +225,89 @@ automation:
|
|||||||
entity_id: script.school_year_over
|
entity_id: script.school_year_over
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
kallen_school_today:
|
||||||
|
sequence:
|
||||||
|
- choose:
|
||||||
|
- conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: >
|
||||||
|
{{ 'Early Release' in states('sensor.school_event') }}
|
||||||
|
sequence:
|
||||||
|
- service: input_boolean.turn_on
|
||||||
|
entity_id: input_boolean.school_early_release
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
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_end
|
||||||
|
data:
|
||||||
|
time: "15:20:00"
|
||||||
|
- 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
|
||||||
|
|
||||||
|
kallen_school_reset:
|
||||||
|
sequence:
|
||||||
|
- if:
|
||||||
|
- condition: trigger
|
||||||
|
id: day_end
|
||||||
|
then:
|
||||||
|
- service: input_boolean.turn_off
|
||||||
|
entity_id:
|
||||||
|
- input_boolean.school_today
|
||||||
|
- input_boolean.kallen_two_hour_delay
|
||||||
|
- input_boolean.kallen_school_cancelled
|
||||||
|
- if:
|
||||||
|
- condition: trigger
|
||||||
|
id: midnight
|
||||||
|
then:
|
||||||
|
- service: input_boolean.turn_off
|
||||||
|
entity_id: input_boolean.school_today_extended
|
||||||
|
|
||||||
|
tina_work_today:
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.tina_workday_start
|
||||||
|
data:
|
||||||
|
time: >
|
||||||
|
{{ as_timestamp(strptime(state_attr('calendar.family_tinawork','start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }}
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.tina_workday_end
|
||||||
|
data:
|
||||||
|
time: >
|
||||||
|
{{ as_timestamp(strptime(state_attr('calendar.family_tinawork','end_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }}
|
||||||
|
- service: input_boolean.turn_on
|
||||||
|
entity_id: input_boolean.work_today
|
||||||
|
|
||||||
|
tina_work_reset:
|
||||||
|
sequence:
|
||||||
|
- service: input_boolean.turn_off
|
||||||
|
entity_id: input_boolean.work_today
|
||||||
|
|
||||||
school_in_session:
|
school_in_session:
|
||||||
sequence:
|
sequence:
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: input_boolean.school_in_session
|
entity_id: input_boolean.school_in_session
|
||||||
state: 'off'
|
state: 'off'
|
||||||
- service: input_boolean.turn_on
|
- service: input_boolean.turn_on
|
||||||
entity_id: input_boolean.school_in_session
|
entity_id: input_boolean.school_in_session
|
||||||
|
|
||||||
school_year_over:
|
school_year_over:
|
||||||
sequence:
|
sequence:
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: input_boolean.school_in_session
|
entity_id: input_boolean.school_in_session
|
||||||
state: 'on'
|
state: 'on'
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: >
|
value_template: >
|
||||||
{{ states('input_datetime.school_last_day') == now().strftime("%Y-%m-%d") }}
|
{{ states('input_datetime.school_last_day') == now().strftime("%Y-%m-%d") }}
|
||||||
- service: input_boolean.turn_off
|
- service: input_boolean.turn_off
|
||||||
entity_id: input_boolean.school_in_session
|
entity_id: input_boolean.school_in_session
|
@ -116,19 +116,7 @@ automation:
|
|||||||
- platform: time
|
- platform: time
|
||||||
at: '06:06:00'
|
at: '06:06:00'
|
||||||
action:
|
action:
|
||||||
- service: input_datetime.set_datetime
|
- service: script.nursery_scheduling
|
||||||
entity_id: input_datetime.nursery_cooling
|
|
||||||
data_template:
|
|
||||||
time: >
|
|
||||||
{% set high = state_attr('sensor.current_forecast','high_temp') | float %}
|
|
||||||
{% set low = state_attr('sensor.current_forecast','overnight_low') | float %}
|
|
||||||
{% if high >= 85 %}
|
|
||||||
20:30
|
|
||||||
{% elif high >= 80 or low >= 60 %}
|
|
||||||
21:30
|
|
||||||
{% else %}
|
|
||||||
22:30
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
kallen_scheduling_morning:
|
kallen_scheduling_morning:
|
||||||
@ -357,3 +345,19 @@ script:
|
|||||||
{% else %}
|
{% else %}
|
||||||
00:00
|
00:00
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
nursery_scheduling:
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
entity_id: input_datetime.nursery_cooling
|
||||||
|
data_template:
|
||||||
|
time: >
|
||||||
|
{% set high = state_attr('sensor.current_forecast','high_temp') | float %}
|
||||||
|
{% set low = state_attr('sensor.current_forecast','overnight_low') | float %}
|
||||||
|
{% if high >= 85 %}
|
||||||
|
20:30
|
||||||
|
{% elif high >= 80 or low >= 60 %}
|
||||||
|
21:30
|
||||||
|
{% else %}
|
||||||
|
22:30
|
||||||
|
{% endif %}
|
Reference in New Issue
Block a user