feat: Add ntfy to Security automations
This commit is contained in:
@@ -328,6 +328,23 @@ automation:
|
|||||||
person.attributes.friendly_name
|
person.attributes.friendly_name
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
- service: shell_command.ntfy
|
||||||
|
data:
|
||||||
|
topic: security
|
||||||
|
tags:
|
||||||
|
- arming
|
||||||
|
title: Home Security {{ trigger.to_state.state|replace('_', ' ')|title }}
|
||||||
|
message: >
|
||||||
|
{%
|
||||||
|
set person = states.person
|
||||||
|
|selectattr('attributes.user_id', 'eq', trigger.to_state.context.user_id)
|
||||||
|
|first|default({'attributes':{'friendly_name':'Automation'}})
|
||||||
|
%}Alarm changed to {{
|
||||||
|
trigger.to_state.state|replace('_', ' ')|title
|
||||||
|
}} by {{
|
||||||
|
person.attributes.friendly_name
|
||||||
|
}}
|
||||||
|
|
||||||
- alias: Reset Alarm Trigger on Disarm
|
- alias: Reset Alarm Trigger on Disarm
|
||||||
trigger:
|
trigger:
|
||||||
- platform: state
|
- platform: state
|
||||||
@@ -350,6 +367,15 @@ automation:
|
|||||||
data:
|
data:
|
||||||
message: Alarm triggered by {{ states('input_text.ha_alarm_trigger') }}
|
message: Alarm triggered by {{ states('input_text.ha_alarm_trigger') }}
|
||||||
|
|
||||||
|
- service: shell_command.ntfy
|
||||||
|
data:
|
||||||
|
topic: security
|
||||||
|
tags:
|
||||||
|
- alarm
|
||||||
|
title: Home Alarm Triggered
|
||||||
|
message: Alarm triggered by {{ states('input_text.ha_alarm_trigger') }}
|
||||||
|
priority: high
|
||||||
|
|
||||||
- alias: Trigger Alarm on Window or Door Open
|
- alias: Trigger Alarm on Window or Door Open
|
||||||
trigger:
|
trigger:
|
||||||
- platform: state
|
- platform: state
|
||||||
@@ -570,6 +596,19 @@ automation:
|
|||||||
title: View Snapshot
|
title: View Snapshot
|
||||||
uri: "https://hass.kraussnet.com/api/frigate/notifications/{{ trigger.payload_json.after.id }}/snapshot.jpg"
|
uri: "https://hass.kraussnet.com/api/frigate/notifications/{{ trigger.payload_json.after.id }}/snapshot.jpg"
|
||||||
|
|
||||||
|
- service: shell_command.ntfy
|
||||||
|
data:
|
||||||
|
topic: security
|
||||||
|
tags:
|
||||||
|
- camera
|
||||||
|
title: Detection on {{ trigger.payload_json.after.camera|title }}
|
||||||
|
message: "A {{ trigger.payload_json.after.label }} detected on {{ trigger.payload_json.after.camera|title }} camera"
|
||||||
|
priority: high
|
||||||
|
attach: "%ha%/api/frigate/notifications/{{ trigger.payload_json.after.id }}/thumbnail.jpg"
|
||||||
|
actions:
|
||||||
|
- "view,View Clip,%ha%/api/frigate/notifications/{{ trigger.payload_json.after.id }}/clip.mp4"
|
||||||
|
- "view,View Snapshot,%ha%/api/frigate/notifications/{{ trigger.payload_json.after.id }}/snapshot.jpg"
|
||||||
|
|
||||||
- if:
|
- if:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: >-
|
value_template: >-
|
||||||
@@ -625,6 +664,19 @@ automation:
|
|||||||
title: View Snapshot
|
title: View Snapshot
|
||||||
uri: "https://hass.kraussnet.com/api/frigate/notifications/{{ event_data['content']['event_id'] }}/snapshot.jpg"
|
uri: "https://hass.kraussnet.com/api/frigate/notifications/{{ event_data['content']['event_id'] }}/snapshot.jpg"
|
||||||
|
|
||||||
|
- service: shell_command.ntfy
|
||||||
|
data:
|
||||||
|
topic: security
|
||||||
|
tags:
|
||||||
|
- doorbell
|
||||||
|
title: Doorbell
|
||||||
|
message: Home Doorbell Rang
|
||||||
|
priority: high
|
||||||
|
attach: "%ha%/api/frigate/notifications/{{ event_data['content']['event_id'] }}/thumbnail.jpg"
|
||||||
|
actions:
|
||||||
|
- "view,View Clip,%ha%/api/frigate/notifications/{{ event_data['content']['event_id'] }}/clip.mp4"
|
||||||
|
- "view,View Snapshot,%ha%/api/frigate/notifications/{{ event_data['content']['event_id'] }}/snapshot.jpg"
|
||||||
|
|
||||||
- service: persistent_notification.create
|
- service: persistent_notification.create
|
||||||
data:
|
data:
|
||||||
notification_id: "camera-{{ event_data['content']['event_id'] }}"
|
notification_id: "camera-{{ event_data['content']['event_id'] }}"
|
||||||
@@ -639,6 +691,15 @@ automation:
|
|||||||
title: "Doorbell"
|
title: "Doorbell"
|
||||||
message: "Home Doorbell Rang but could not create event: {{ event_data['content']['message'] }}"
|
message: "Home Doorbell Rang but could not create event: {{ event_data['content']['message'] }}"
|
||||||
|
|
||||||
|
- service: shell_command.ntfy
|
||||||
|
data:
|
||||||
|
topic: security
|
||||||
|
tags:
|
||||||
|
- doorbell
|
||||||
|
title: Doorbell
|
||||||
|
message: "Home Doorbell Rang but could not create event: {{ event_data['content']['message'] }}"
|
||||||
|
priority: high
|
||||||
|
|
||||||
- alias: Notify that Garage Door is Open when Alarm Arms
|
- alias: Notify that Garage Door is Open when Alarm Arms
|
||||||
description: Send a Garage Door Open Notice to Phones
|
description: Send a Garage Door Open Notice to Phones
|
||||||
trigger:
|
trigger:
|
||||||
@@ -673,6 +734,19 @@ automation:
|
|||||||
- action: "{{ action_close }}"
|
- action: "{{ action_close }}"
|
||||||
title: Close
|
title: Close
|
||||||
|
|
||||||
|
- alias: Send notice to ntfy
|
||||||
|
service: shell_command.ntfy
|
||||||
|
data:
|
||||||
|
topic: security
|
||||||
|
tags:
|
||||||
|
- garage
|
||||||
|
title: Garage Door Open
|
||||||
|
message: Garage door is open! It will close in 10 minutes if not ignored.
|
||||||
|
priority: high
|
||||||
|
actions:
|
||||||
|
- 'http,Ignore,%ha%,body={\"action\":\"{{ action_ignore }}\"}'
|
||||||
|
- 'http,Close,%ha%,body={\"action\":\"{{ action_close }}\"}'
|
||||||
|
|
||||||
- alias: Wait for action callback
|
- alias: Wait for action callback
|
||||||
wait_for_trigger:
|
wait_for_trigger:
|
||||||
- platform: event
|
- platform: event
|
||||||
@@ -681,10 +755,18 @@ automation:
|
|||||||
# waiting for the specific action avoids accidentally continuing
|
# waiting for the specific action avoids accidentally continuing
|
||||||
# for another script/automation's notification action
|
# for another script/automation's notification action
|
||||||
action: "{{ action_ignore }}"
|
action: "{{ action_ignore }}"
|
||||||
|
- platform: event
|
||||||
|
event_type: ntfy
|
||||||
|
event_data:
|
||||||
|
action: "{{ action_ignore }}"
|
||||||
- platform: event
|
- platform: event
|
||||||
event_type: mobile_app_notification_action
|
event_type: mobile_app_notification_action
|
||||||
event_data:
|
event_data:
|
||||||
action: "{{ action_close }}"
|
action: "{{ action_close }}"
|
||||||
|
- platform: event
|
||||||
|
event_type: ntfy
|
||||||
|
event_data:
|
||||||
|
action: "{{ action_close }}"
|
||||||
- platform: state
|
- platform: state
|
||||||
entity_id: alarm_control_panel.ha_alarm
|
entity_id: alarm_control_panel.ha_alarm
|
||||||
to: disarmed
|
to: disarmed
|
||||||
@@ -704,6 +786,19 @@ automation:
|
|||||||
|selectattr('attributes.user_id', 'eq', wait.trigger.event.context.user_id)
|
|selectattr('attributes.user_id', 'eq', wait.trigger.event.context.user_id)
|
||||||
|first|default({'attributes':{'friendly_name':'Automation'}})
|
|first|default({'attributes':{'friendly_name':'Automation'}})
|
||||||
%}Open garage door ignored by {{ person.attributes.friendly_name }}
|
%}Open garage door ignored by {{ person.attributes.friendly_name }}
|
||||||
|
- alias: Notify that the event was ignored (ntfy)
|
||||||
|
shell_command.ntfy
|
||||||
|
data:
|
||||||
|
topic: security
|
||||||
|
tags:
|
||||||
|
- garage
|
||||||
|
title: Garage Door Ignored
|
||||||
|
message: >
|
||||||
|
{%
|
||||||
|
set person = states.person
|
||||||
|
|selectattr('attributes.user_id', 'eq', wait.trigger.event.context.user_id)
|
||||||
|
|first|default({'attributes':{'friendly_name':'Automation'}})
|
||||||
|
%}Open garage door ignored by {{ person.attributes.friendly_name }}
|
||||||
|
|
||||||
- conditions: "{{ wait.remaining > 0 and 'event' in wait.trigger and wait.trigger.event.data.action == action_close }}"
|
- conditions: "{{ wait.remaining > 0 and 'event' in wait.trigger and wait.trigger.event.data.action == action_close }}"
|
||||||
sequence:
|
sequence:
|
||||||
@@ -718,6 +813,14 @@ automation:
|
|||||||
action: notify.security
|
action: notify.security
|
||||||
data:
|
data:
|
||||||
message: "Garage door timeout cancelled because alarm was disarmed"
|
message: "Garage door timeout cancelled because alarm was disarmed"
|
||||||
|
- alias: Notify that the event was cancelled (ntfy)
|
||||||
|
shell_command.ntfy
|
||||||
|
data:
|
||||||
|
topic: security
|
||||||
|
tags:
|
||||||
|
- garage
|
||||||
|
title: Garage Door Cancelled
|
||||||
|
message: "Garage door timeout cancelled because alarm was disarmed"
|
||||||
|
|
||||||
- conditions: "{{ not wait.completed }}"
|
- conditions: "{{ not wait.completed }}"
|
||||||
sequence:
|
sequence:
|
||||||
@@ -729,6 +832,14 @@ automation:
|
|||||||
action: notify.security
|
action: notify.security
|
||||||
data:
|
data:
|
||||||
message: "Garage door closing automatically"
|
message: "Garage door closing automatically"
|
||||||
|
- alias: Notify the event timed out (ntfy)
|
||||||
|
shell_command.ntfy
|
||||||
|
data:
|
||||||
|
topic: security
|
||||||
|
tags:
|
||||||
|
- garage
|
||||||
|
title: Garage Door Closing
|
||||||
|
message: Garage door closing automatically
|
||||||
|
|
||||||
- alias: Notify that Front Door is Unlocked when Alarm Arms
|
- alias: Notify that Front Door is Unlocked when Alarm Arms
|
||||||
description: Send a Front Door Unlocked Notice to Phones
|
description: Send a Front Door Unlocked Notice to Phones
|
||||||
@@ -764,6 +875,19 @@ automation:
|
|||||||
- action: "{{ action_lock }}"
|
- action: "{{ action_lock }}"
|
||||||
title: Lock
|
title: Lock
|
||||||
|
|
||||||
|
- alias: Send notice to ntfy
|
||||||
|
service: shell_command.ntfy
|
||||||
|
data:
|
||||||
|
topic: security
|
||||||
|
tags:
|
||||||
|
- front door
|
||||||
|
title: Front Door Unlocked
|
||||||
|
message: Front door is unlocked! It will lock in 10 minutes if not ignored.
|
||||||
|
priority: high
|
||||||
|
actions:
|
||||||
|
- 'http,Ignore,%ha%,body={\"action\":\"{{ action_ignore }}\"}'
|
||||||
|
- 'http,Lock,%ha%,body={\"action\":\"{{ action_lock }}\"}'
|
||||||
|
|
||||||
- alias: Wait for action callback
|
- alias: Wait for action callback
|
||||||
wait_for_trigger:
|
wait_for_trigger:
|
||||||
- platform: event
|
- platform: event
|
||||||
@@ -772,10 +896,18 @@ automation:
|
|||||||
# waiting for the specific action avoids accidentally continuing
|
# waiting for the specific action avoids accidentally continuing
|
||||||
# for another script/automation's notification action
|
# for another script/automation's notification action
|
||||||
action: "{{ action_ignore }}"
|
action: "{{ action_ignore }}"
|
||||||
|
- platform: event
|
||||||
|
event_type: ntfy
|
||||||
|
event_data:
|
||||||
|
action: "{{ action_ignore }}"
|
||||||
- platform: event
|
- platform: event
|
||||||
event_type: mobile_app_notification_action
|
event_type: mobile_app_notification_action
|
||||||
event_data:
|
event_data:
|
||||||
action: "{{ action_lock }}"
|
action: "{{ action_lock }}"
|
||||||
|
- platform: event
|
||||||
|
event_type: ntfy
|
||||||
|
event_data:
|
||||||
|
action: "{{ action_lock }}"
|
||||||
- platform: state
|
- platform: state
|
||||||
entity_id: alarm_control_panel.ha_alarm
|
entity_id: alarm_control_panel.ha_alarm
|
||||||
to: disarmed
|
to: disarmed
|
||||||
@@ -795,6 +927,19 @@ automation:
|
|||||||
|selectattr('attributes.user_id', 'eq', wait.trigger.event.context.user_id)
|
|selectattr('attributes.user_id', 'eq', wait.trigger.event.context.user_id)
|
||||||
|first|default({'attributes':{'friendly_name':'Automation'}})
|
|first|default({'attributes':{'friendly_name':'Automation'}})
|
||||||
%}Unlocked front door ignored by {{ person.attributes.friendly_name }}
|
%}Unlocked front door ignored by {{ person.attributes.friendly_name }}
|
||||||
|
- alias: Notify that the event was ignored (ntfy)
|
||||||
|
shell_command.ntfy
|
||||||
|
data:
|
||||||
|
topic: security
|
||||||
|
tags:
|
||||||
|
- front door
|
||||||
|
title: Front Door Ignored
|
||||||
|
message: >
|
||||||
|
{%
|
||||||
|
set person = states.person
|
||||||
|
|selectattr('attributes.user_id', 'eq', wait.trigger.event.context.user_id)
|
||||||
|
|first|default({'attributes':{'friendly_name':'Automation'}})
|
||||||
|
%}Unlocked front door ignored by {{ person.attributes.friendly_name }}
|
||||||
|
|
||||||
- conditions: "{{ wait.remaining > 0 and 'event' in wait.trigger and wait.trigger.event.data.action == action_lock }}"
|
- conditions: "{{ wait.remaining > 0 and 'event' in wait.trigger and wait.trigger.event.data.action == action_lock }}"
|
||||||
sequence:
|
sequence:
|
||||||
@@ -809,6 +954,14 @@ automation:
|
|||||||
action: notify.security
|
action: notify.security
|
||||||
data:
|
data:
|
||||||
message: "Front door timeout cancelled because alarm was disarmed"
|
message: "Front door timeout cancelled because alarm was disarmed"
|
||||||
|
- alias: Notify that the event timed out (ntfy)
|
||||||
|
shell_command.ntfy
|
||||||
|
data:
|
||||||
|
topic: security
|
||||||
|
tags:
|
||||||
|
- front door
|
||||||
|
title: Front Door Cancelled
|
||||||
|
message: Front door timeout cancelled because alarm was disarmed
|
||||||
|
|
||||||
- conditions: "{{ not wait.completed }}"
|
- conditions: "{{ not wait.completed }}"
|
||||||
sequence:
|
sequence:
|
||||||
@@ -820,3 +973,11 @@ automation:
|
|||||||
action: notify.security
|
action: notify.security
|
||||||
data:
|
data:
|
||||||
message: "Front door locking automatically"
|
message: "Front door locking automatically"
|
||||||
|
- alias: Notify that the event timed out (ntfy)
|
||||||
|
shell_command.ntfy
|
||||||
|
data:
|
||||||
|
topic: security
|
||||||
|
tags:
|
||||||
|
- front door
|
||||||
|
title: Front Door Locking
|
||||||
|
message: Front door locking automatically
|
||||||
|
|||||||
Reference in New Issue
Block a user