1
0
ansible-home-assistant/configuration/automations/alarm.yaml

307 lines
8.7 KiB
YAML

- id: alarm_away_hallway
alias: '[Alarm] Trigger alarm when not at home - Hallway camera'
trigger:
# Use hallway motion sensor
- platform: state
entity_id: binary_sensor.hallway_motion_sensor
to: 'on'
# Use open/close sensors
- platform: state
entity_id: binary_sensor.bathroom_door_open_close
to: 'on'
- platform: state
entity_id: binary_sensor.front_door_open_close
to: 'on'
# Use lock
- platform: state
entity_id: lock.front_door_lock_doorlock
to: 'unlocked'
condition:
- condition: state
entity_id: alarm_control_panel.home_alarm
state: armed_away
action:
- service: alarm_control_panel.alarm_trigger
entity_id: alarm_control_panel.home_alarm
- service: notify.mobile_app_iphone
data:
title: "ALARM! Pending for disarm"
message: >
{{ state_attr(trigger.entity_id, 'friendly_name') }}
data:
entity_id: camera.hallway
url: "/lovelace-tablet/security"
- service: camera.snapshot
data:
filename: /config/www/cctv/hallway.jpg
target:
entity_id: camera.hallway
- service: notify.home_assistant
data:
message: >
ALARM. Pending to disarm
Motion in hallway - {{ state_attr(trigger.entity_id, 'friendly_name') }}
@everyone
target: [ "1070507369164984372" ]
data:
images:
- "/config/www/cctv/hallway.jpg"
- service: camera.record
data:
duration: 30
lookback: 30
filename: /config/www/cctv/hallway.mp4
target:
entity_id: camera.hallway
- service: notify.home_assistant
data:
message: >
Motion recording
target: [ "1070507369164984372" ]
data:
images:
- "/config/www/cctv/hallway.mp4"
- id: alarm_away_living_roomn
alias: '[Alarm] Trigger alarm when not at home (Living Room)'
trigger:
# Use motion sensors
- platform: state
entity_id: binary_sensor.kitchen_motion_sensor
to: 'on'
- platform: state
entity_id: binary_sensor.office_sensor_motion
to: 'on'
# - platform: state
# entity_id: binary_sensor.kitchen_tabletop_motion_detection
# to: 'on'
# - platform: state
# entity_id: binary_sensor.kitchen_sink_motion_sensor
# to: 'on'
# Use open/close sensors
- platform: state
entity_id: binary_sensor.dining_window_1_open_close
to: 'on'
- platform: state
entity_id: binary_sensor.dining_window_2_open_close
to: 'on'
- platform: state
entity_id: binary_sensor.freezer_door_on_off
to: 'on'
- platform: state
entity_id: binary_sensor.front_door_open_close
to: 'on'
- platform: state
entity_id: binary_sensor.office_window_open_close
to: 'on'
condition:
- condition: state
entity_id: alarm_control_panel.home_alarm
state: armed_away
action:
- service: alarm_control_panel.alarm_trigger
entity_id: alarm_control_panel.home_alarm
- service: notify.mobile_app_iphone
data:
title: "ALARM! Pending for disarm"
message: >
{{ state_attr(trigger.entity_id, 'friendly_name') }}
data:
entity_id: camera.living_room
url: "/lovelace-tablet/security"
- service: camera.snapshot
data:
filename: /config/www/cctv/living_room.jpg
target:
entity_id: camera.living_room
- service: notify.home_assistant
data:
message: >
ALARM. Pending to disarm
Motion in Living Room - {{ state_attr(trigger.entity_id, 'friendly_name') }}
@everyone
target: [ "1070507369164984372" ]
data:
images:
- "/config/www/cctv/living_room.jpg"
- service: camera.record
data:
duration: 30
lookback: 30
filename: /config/www/cctv/living_room.mp4
target:
entity_id: camera.hallway
- service: notify.home_assistant
data:
message: >
Motion recording
target: [ "1070507369164984372" ]
data:
images:
- "/config/www/cctv/living_room.mp4"
- id: alarm_away_bedroom
alias: '[Alarm] Trigger alarm when not at home (Bedroom)'
trigger:
# Use motion sensors
- platform: state
entity_id: binary_sensor.bedroom_motion_occupancy
to: 'on'
# Use open/close sensors
- platform: state
entity_id: binary_sensor.bedroom_window_open_close
to: 'on'
condition:
- condition: state
entity_id: alarm_control_panel.home_alarm
state: armed_away
action:
- service: alarm_control_panel.alarm_trigger
entity_id: alarm_control_panel.home_alarm
- service: camera.snapshot
data:
filename: /config/www/cctv/bedroom.jpg
target:
entity_id: camera.bedroom
- service: notify.home_assistant
data:
message: >
ALARM. Pending to disarm
Motion in Bedroom - {{ state_attr(trigger.entity_id, 'friendly_name') }}
@everyone
target: [ "1070507369164984372" ]
data:
images:
- "/config/www/cctv/bedroom.jpg"
- service: camera.record
data:
duration: 30
lookback: 30
filename: /config/www/cctv/bedroom.mp4
target:
entity_id: camera.bedroom
- service: notify.home_assistant
data:
message: >
Motion recording
target: [ "1070507369164984372" ]
data:
images:
- "/config/www/cctv/bedroom.mp4"
- id: alarm_away_remaining
alias: '[Alarm] Trigger alarm when not at home'
trigger:
# Use motion sensors
- platform: state
entity_id: binary_sensor.bathroom_motion_occupancy
to: 'on'
# - platform: state
# entity_id: binary_sensor.bedroom_motion_occupancy
# to: 'on'
- platform: state
entity_id: binary_sensor.bathroom_shower_sensor_motion
to: 'on'
# Use open/close sensors
# - platform: state
# entity_id: binary_sensor.bedroom_window_open_close
# to: 'on'
condition:
- condition: state
entity_id: alarm_control_panel.home_alarm
state: armed_away
action:
- service: alarm_control_panel.alarm_trigger
entity_id: alarm_control_panel.home_alarm
- service: notify.mobile_app_iphone
data:
title: "ALARM! Pending for disarm"
message: >
{{ state_attr(trigger.entity_id, 'friendly_name') }}
data:
url: "/lovelace-tablet/security"
- id: alarm_night
alias: '[Alarm] Trigger alarm at night'
trigger:
- platform: state
entity_id: binary_sensor.bedroom_window_open_close
to: 'on'
- platform: state
entity_id: binary_sensor.dining_window_1_open_close
to: 'on'
- platform: state
entity_id: binary_sensor.dining_window_2_open_close
to: 'on'
- platform: state
entity_id: binary_sensor.freezer_door_on_off
to: 'on'
- platform: state
entity_id: binary_sensor.front_door_open_close
to: 'on'
- platform: state
entity_id: binary_sensor.office_window_open_close
to: 'on'
condition:
- condition: state
entity_id: alarm_control_panel.home_alarm
state: armed_away
action:
- service: alarm_control_panel.alarm_trigger
entity_id: alarm_control_panel.home_alarm
- service: notify.mobile_app_iphone
data:
title: "ALARM! Pending for disarm"
message: >
{{ state_attr(trigger.entity_id, 'friendly_name') }}
data:
url: "/lovelace-tablet/security"
- id: alarm_arm_away
alias: '[Alarm] Arm away'
trigger:
- platform: zone
entity_id: device_tracker.przemyslaws_iphone
zone: zone.home
event: leave
action:
- service: alarm_control_panel.alarm_arm_away
entity_id: alarm_control_panel.home_alarm
- id: alarm_pending
alias: '[Alarm] Send notification when alarm triggered'
trigger:
- platform: state
entity_id: alarm_control_panel.home_alarm
to: 'pending'
action:
- service: zwave_js.set_config_parameter
data:
parameter: '7'
value: '2'
target:
entity_id: switch.siren_alarm
- service: switch.turn_on
entity_id: switch.siren_switch
- id: alarm_triggered
alias: '[Alarm] Turn on alarm'
trigger:
- platform: state
entity_id: alarm_control_panel.home_alarm
to: 'triggered'
action:
- service: notify.notify
data:
message: "ALARM! The alarm has been triggered"
data:
importance: max
- service: zwave_js.set_config_parameter
data:
parameter: '7'
value: '1'
target:
entity_id: switch.siren_alarm
- service: switch.turn_on
entity_id: switch.siren_switch