From 2488c9965d0167253396dc01090985e8cb7ef024 Mon Sep 17 00:00:00 2001 From: "J.P. Krauss" Date: Tue, 21 Nov 2023 14:41:36 -0700 Subject: [PATCH] Update Security Scripts --- packages/security/security.yaml | 88 +++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 26 deletions(-) diff --git a/packages/security/security.yaml b/packages/security/security.yaml index 1bb881c..83f3b5e 100644 --- a/packages/security/security.yaml +++ b/packages/security/security.yaml @@ -144,6 +144,57 @@ input_button: shell_command: doorbell_camera_set_online: !secret doorbell_camera_online_command +# ----------------------------------------------------------------------------- +# Security Scripts +script: + pause_camera_events: + alias: Pause Exterior Camera Event Detection + sequence: + - service: mqtt.publish + data: + topic: frigate/backyard/detect/set + payload: 'OFF' + - service: mqtt.publish + data: + topic: frigate/doorbell/detect/set + payload: 'OFF' + + resume_camera_events: + alias: Resume Exterior Camera Event Detection + sequence: + - service: mqtt.publish + data: + topic: frigate/backyard/detect/set + payload: 'ON' + - service: mqtt.publish + data: + topic: frigate/doorbell/detect/set + payload: 'ON' + + # Run as a script so it can be cancelled by the helper turning back off + auto_resume_camera_events: + alias: Automatically Resume Exterior Camera Event Detection (timed) + data: + minutes: + name: Minutes + description: "The amount of time to wait before resuming detection" + default: 60 + selector: + number: + min: 0 + max: 240 + step: 10 + unit_of_measurement: minutes + mode: slider + mode: restart + sequence: + - delay: + minutes: "{{ minutes }}" + - service: input_boolean.turn_off + target: + entity_id: input_boolean.disable_camera_events + - service: script.resume_camera_events + # ----------------------------------------------------------------------------- # Security Automations automation: @@ -311,26 +362,12 @@ automation: entity_id: input_boolean.disable_camera_events to: 'on' action: - - service: mqtt.publish - data: - topic: frigate/backyard/detect/set - payload: 'OFF' - - service: mqtt.publish - data: - topic: frigate/doorbell/detect/set - payload: 'OFF' - - delay: 3600 - - service: input_boolean.turn_off + - service: script.pause_camera_events + - service: script.turn_on target: - entity_id: input_boolean.disable_camera_events - - service: mqtt.publish + entity_id: script.auto_resume_camera_events data: - topic: frigate/backyard/detect/set - payload: 'ON' - - service: mqtt.publish - data: - topic: frigate/doorbell/detect/set - payload: 'ON' + minutes: 60 - alias: Resume Camera Event Detection trigger: @@ -338,14 +375,10 @@ automation: entity_id: input_boolean.disable_camera_events to: 'off' action: - - service: mqtt.publish - data: - topic: frigate/backyard/detect/set - payload: 'ON' - - service: mqtt.publish - data: - topic: frigate/doorbell/detect/set - payload: 'ON' + - service: script.turn_off + target: + entity_id: script.auto_resume_camera_events + - service: script.resume_camera_events - alias: Pause Doorbell Event Detection on Arrival or Departure trigger: @@ -362,6 +395,7 @@ automation: condition: state entity_id: input_boolean.disable_camera_events state: 'off' + mode: restart action: - service: mqtt.publish data: @@ -382,6 +416,7 @@ automation: condition: state entity_id: alarm_control_panel.ha_alarm state: disarmed + mode: restart action: - service: mqtt.publish data: @@ -400,6 +435,7 @@ automation: condition: state entity_id: input_boolean.disable_camera_events state: 'off' + mode: restart action: - delay: 60 - service: mqtt.publish