Files
Home-Assistant-Configs/packages/security.yaml

254 lines
8.5 KiB
YAML

input_boolean:
# Main security switch. If this is on, the security is armed.
sentry_mode:
name: Sentry Mode
icon: mdi:security
# Vacation mode is automagically set when we are 3 hours from the house, and turns off when we return.
# This is used to modify some of the normal automations.
vacation_mode:
name: Vacation Mode
icon: mdi:airplane-takeoff
# Guest mode is use to modify automations when we have guests.
# In some cases this prevents security from being set to prevent security alarm going off
guest_mode:
name: Guest Mode
icon: mdi:account-multiple
# This switch powers the security alarm and gives an easy way to kill the alarm.
# When it is on, the alarm is going off
security_alarm:
name: Security Alarm
icon: mdi:speaker-wireless
# This switch powers the fire alarm.
# When on the fire alarm is going off.
fire_alarm:
name: Fire Alarm
icon: mdi:speaker-wireless
# This switch turns on if the security system checks that fire when someone tries to arm the system
# finds a door open, or another condition that would prevent the system from being able to monitor properly.
lockdown_issue:
name: Lockdown Issue
icon: mdi:lock-reset
# This switch is turned on if there is a security breach. Turning on this switch starts the countdown to the alarm.
security_issue:
name: Security Issue
icon: mdi:alert-circle-outline
input_datetime:
morning_alarm_disarm:
name: Morning Alarm Disarm
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
sensors:
windows_open:
friendly_name: "Windows"
unit_of_measurement: 'open'
value_template: >-
{% set windows = [
states.binary_sensor.front_window_near,
states.binary_sensor.kitchen_big_window,
states.binary_sensor.mud_room_window,
states.binary_sensor.stairway_window_lower,
] %}
{% set windows_open = windows | selectattr('state','eq','on') | list | count %}
{{ windows_open }}
icon_template: >-
{% set windows = [
states.binary_sensor.front_window_near,
states.binary_sensor.kitchen_big_window,
states.binary_sensor.mud_room_window,
states.binary_sensor.stairway_window_lower,
] %}
{% set windows_open = windows | selectattr('state','eq','on') | list | count %}
{% if windows_open == 0 %}
mdi:window-closed
{% else %}
mdi:window-open
{% endif %}
doors_open:
friendly_name: "Doors"
unit_of_measurement: 'open'
value_template: >-
{% set doors = [
states.binary_sensor.front_door,
states.binary_sensor.back_door,
] %}
{% set doors_open = doors | selectattr('state','eq','on') | list | count %}
{{ doors_open }}
icon_template: >-
{% set doors = [
states.binary_sensor.front_door,
states.binary_sensor.back_door,
] %}
{% set doors_open = doors | selectattr('state','eq','on') | list | count %}
{% if doors_open == 0 %}
mdi:door-closed
{% else %}
mdi:door-open
{% endif %}
total_faults:
friendly_name: Faults
unit_of_measurement: 'open'
value_template: >-
{% set windows = [
states.binary_sensor.front_window_near,
states.binary_sensor.kitchen_big_window,
states.binary_sensor.mud_room_window,
states.binary_sensor.stairway_window_lower,
] %}
{% set doors = [
states.binary_sensor.front_door,
states.binary_sensor.back_door,
] %}
{% set windows_open = windows | selectattr('state','eq','on') | list | count %}
{% set doors_open = doors | selectattr('state','eq','on') | list | count %}
{{ doors_open + windows_open }}
icon_template: >-
{% set windows = [
states.binary_sensor.front_window_near,
states.binary_sensor.kitchen_big_window,
states.binary_sensor.mud_room_window,
states.binary_sensor.stairway_window_lower,
] %}
{% set doors = [
states.binary_sensor.front_door,
states.binary_sensor.back_door,
] %}
{% set windows_open = windows | selectattr('state','eq','on') | list | count %}
{% set doors_open = doors | selectattr('state','eq','on') | list | count %}
{% set faults = ( doors_open + windows_open ) %}
{% if faults == 0 %}
mdi:shield-home
{% else %}
mdi:shield-off
{% endif %}
automation:
- id: 51819f36-2407-496c-afcd-ae160d747f0a
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
state: 'home'
- condition: state
entity_id: input_boolean.vacation_mode
state: 'off'
- condition: state
entity_id: input_boolean.guest_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: state
entity_id: input_boolean.guest_mode
state: 'off'
- condition: time
after: '06:00'
before: '12:00'
- 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
sequence:
- if:
- condition: state
entity_id: sensor.total_faults
state: '0'
then:
- service: alarm_control_panel.alarm_arm_home
target:
entity_id: alarm_control_panel.stratton_ave_alarm
data:
code: !secret ring_alarm_code
else:
- service: script.speech_engine
data:
who: common
message: 'There are active security faults. Please close all doors and windows before arming.'
- service: script.text_urgent_alert
data:
who: 'parents'
title: 'Security Not Armed!'
message: 'There are active security faults. Please close all doors and windows before arming.'
security_arm_away:
alias: Security Arm - Away
sequence:
- if:
- condition: state
entity_id: sensor.total_faults
state: '0'
then:
- service: alarm_control_panel.alarm_arm_away
target:
entity_id: alarm_control_panel.stratton_ave_alarm
data:
code: !secret ring_alarm_code
- service: alarm_control_panel.alarm_arm_away
target:
entity_id: alarm_control_panel.alexa_guard_9ee3b
else:
- service: script.speech_engine
data:
who: common
message: 'There are active security faults. Please close all doors and windows before arming.'
- service: script.text_urgent_alert
data:
who: 'parents'
title: 'Security Not Armed!'
message: 'There are active security faults. Please close all doors and windows before arming.'
security_disarm:
alias: Security Disarm
sequence:
- service: alarm_control_panel.alarm_disarm
target:
entity_id: alarm_control_panel.stratton_ave_alarm
data:
code: !secret ring_alarm_code
- service: alarm_control_panel.alarm_disarm
target:
entity_id: alarm_control_panel.alexa_guard_9ee3b