From 20ecb7288fd4e5e069e152a43d9621f3ec1a7438 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Tue, 7 Jun 2022 16:42:36 -0400 Subject: [PATCH] Improved alarm system scheduling --- packages/scheduling.yaml | 16 +++++++++++++++- packages/security.yaml | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/packages/scheduling.yaml b/packages/scheduling.yaml index c5fe7ad..b1e226d 100644 --- a/packages/scheduling.yaml +++ b/packages/scheduling.yaml @@ -144,10 +144,24 @@ automation: {% if is_state('input_boolean.work_today','on') and is_state('input_boolean.school_today','off') %} {{ (state_attr('input_datetime.tina_workday_start', 'timestamp') - 3600) | timestamp_custom('%H:%M', false) }} {% elif is_state('input_boolean.school_today','on') %} - 08:00 + {{ (state_attr('input_datetime.school_day_start','timestamp') - 3600) | timestamp_custom('%H:%M', false) }} {% else %} 11:00 {% endif %} + - service: input_datetime.set_datetime + entity_id: input_datetime.morning_alarm_rearm + data_template: + time: > + {% if is_state('input_boolean.work_today','on') and is_state('input_boolean.school_today','off') %} + {{ (state_attr('input_datetime.tina_workday_start','timestamp') + 1800) | timestamp_custom('%H:%M', false) }} + {% elif is_state('input_boolean.school_today','on') and is_state('input_boolean.work_today','off') %} + {{ (state_attr('input_datetime.school_day_start','timestamp') + 3600) | timestamp_custom('%H:%M', false) }} + {% elif is_state('input_boolean.work_today','on') and is_state('input_boolean.school_today','on') %} + {{ (state_attr('input_datetime.tina_workday_start','timestamp') + 1800) | timestamp_custom('%H:%M', false) }} + {% else %} + 12:00 + {% endif %} + - if: - condition: trigger id: house-evening diff --git a/packages/security.yaml b/packages/security.yaml index 8a74a7f..f00db6c 100644 --- a/packages/security.yaml +++ b/packages/security.yaml @@ -39,6 +39,11 @@ input_datetime: icon: mdi:shield-off has_date: false has_time: true + morning_alarm_rearm: + name: Morning Alarm Rearm + icon: mdi:shield-home + has_date: false + has_time: true sensor: - platform: template @@ -120,10 +125,12 @@ sensor: automation: - id: 51819f36-2407-496c-afcd-ae160d747f0a - alias: Morning Alarm Disarm + alias: Scheduled Alarm Disarm trigger: - platform: time at: input_datetime.morning_alarm_disarm + - platform: time + at: input_datetime.master_bedroom_wakeup condition: - condition: state entity_id: group.family @@ -131,9 +138,40 @@ automation: - condition: state entity_id: input_boolean.vacation_mode state: 'off' + - condition: or + conditions: + - condition: state + entity_id: input_boolean.work_today + state: 'on' + - condition: state + entity_id: input_boolean.school_today + state: 'on' action: - service: script.security_disarm + - id: f51eb02f-3f44-4b5d-a389-762b8ca88e2a + alias: Scheduled Alarm Rearm + trigger: + - platform: time + at: input_datetime.morning_alarm_rearm + condition: + - condition: state + entity_id: group.family + state: 'home' + - condition: state + entity_id: input_boolean.vacation_mode + state: 'off' + - condition: or + conditions: + - condition: state + entity_id: input_boolean.work_today + state: 'on' + - condition: state + entity_id: input_boolean.school_today + state: 'on' + action: + - service: script.security_arm_home + script: security_arm_home: alias: Security Arm - Home