Fixed home-assistant automations and scripts
This commit is contained in:
parent
cc7a8ebaf0
commit
c831770ac8
39
home-assistant/Notification to smart phone.yml
Normal file
39
home-assistant/Notification to smart phone.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# Automation version of notification
|
||||||
|
action: notify.mobile_app_sm_n986b
|
||||||
|
data_template:
|
||||||
|
message: A {{trigger.payload_json["after"]["label"]}} was detected.
|
||||||
|
title: Frigate
|
||||||
|
data:
|
||||||
|
image: >-
|
||||||
|
https://home-assistant.sthome.org/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg?format=android
|
||||||
|
tag: "{{trigger.payload_json[\"after\"][\"id\"]}}"
|
||||||
|
when: "{{trigger.payload_json[\"after\"][\"start_time\"]|int}}"
|
||||||
|
actions:
|
||||||
|
- action: URI
|
||||||
|
title: Open Image
|
||||||
|
uri: >-
|
||||||
|
https://home-assistant.sthome.org/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg?format=android
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# script version of notification
|
||||||
|
alias: Send Dynamic Notification To All Devices
|
||||||
|
sequence:
|
||||||
|
- data:
|
||||||
|
message: "{{ message }}"
|
||||||
|
title: "{{ title }}"
|
||||||
|
data: null
|
||||||
|
url: "{{ video }}"
|
||||||
|
tag: "{{ notifTag }}"
|
||||||
|
group: "{{ group }}"
|
||||||
|
attachment:
|
||||||
|
url: >-
|
||||||
|
{% if (importance == "default" and video != null) -%} {{ video }} {%-
|
||||||
|
else -%} {{ image }} {%- endif %}
|
||||||
|
push:
|
||||||
|
interruption-level: >-
|
||||||
|
{% if importance == "max" -%} time-sensitive {%- else -%} passive {%-
|
||||||
|
endif %}
|
||||||
|
action: notify.mobile_app_sm_n986b
|
||||||
|
mode: single
|
||||||
|
icon: mdi:bell-ring-outline
|
||||||
|
max: 10
|
||||||
97
home-assistant/Person Detect Logic.yml
Normal file
97
home-assistant/Person Detect Logic.yml
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
alias: "FRIGATE: Person Detect Logic"
|
||||||
|
description: >-
|
||||||
|
This automation is used to send a notification when a person is detected by
|
||||||
|
Frigate. It uses the frigate MQTT event stream to trigger the notification and
|
||||||
|
includes a snapshot of the detected object. The notification will be sent to
|
||||||
|
all devices with the specified group and will include a video clip of the
|
||||||
|
detection if available.
|
||||||
|
triggers:
|
||||||
|
- topic: homeassistant/events
|
||||||
|
id: frigate-event
|
||||||
|
value_template: "{{ value_json[\"after\"][\"camera\"] }}"
|
||||||
|
variables:
|
||||||
|
after_zones: "{{ trigger.payload_json[\"after\"][\"entered_zones\"] }}"
|
||||||
|
before_zones: "{{ trigger.payload_json[\"before\"][\"entered_zones\"] }}"
|
||||||
|
camera: "{{ trigger.payload_json[\"after\"][\"camera\"] }}"
|
||||||
|
id: "{{ trigger.payload_json[\"after\"][\"id\"] }}"
|
||||||
|
label: "{{ trigger.payload_json[\"after\"][\"label\"] }}"
|
||||||
|
score: "{{ trigger.payload_json[\"after\"][\"score\"] }}"
|
||||||
|
time_clip_start: "{{ trigger.payload_json[\"after\"][\"start_time\"] - 10.0 }}"
|
||||||
|
trigger: mqtt
|
||||||
|
conditions:
|
||||||
|
- condition: or
|
||||||
|
conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ trigger.payload_json['type'] == 'new' }}"
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ before_zones | length == 0 }}"
|
||||||
|
enabled: false
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ trigger.payload_json[\"after\"][\"entered_zones\"]|length > 0 }}"
|
||||||
|
enabled: false
|
||||||
|
actions:
|
||||||
|
- choose:
|
||||||
|
- conditions:
|
||||||
|
- condition: trigger
|
||||||
|
id: frigate-event
|
||||||
|
sequence:
|
||||||
|
- action: script.person_in_driveway_detect_actions
|
||||||
|
data:
|
||||||
|
id: "{{ id }}"
|
||||||
|
title: >-
|
||||||
|
{{ label }} was detected on {{ camera | replace("_", " ") |
|
||||||
|
title }}
|
||||||
|
message: >-
|
||||||
|
{{ label }} detected in the {{ after_zones[0] | replace("_", "
|
||||||
|
") | title }}
|
||||||
|
notifTag: "{{ id }}"
|
||||||
|
notifIcon: mdi:doorbell-video
|
||||||
|
group: frigate-notification-{{ camera }}
|
||||||
|
importance: max
|
||||||
|
image: /api/frigate/notifications/{{ id }}/snapshot.jpg
|
||||||
|
video: ""
|
||||||
|
clickAction: ""
|
||||||
|
camera: "{{ camera }}"
|
||||||
|
- repeat:
|
||||||
|
sequence:
|
||||||
|
- wait_for_trigger:
|
||||||
|
- topic: homeassistant/events
|
||||||
|
payload: "{{ trigger.payload_json[\"after\"][\"id\"] }}"
|
||||||
|
value_template: "{{ value_json[\"after\"][\"id\"] }}"
|
||||||
|
trigger: mqtt
|
||||||
|
continue_on_timeout: false
|
||||||
|
timeout: "00:02:00"
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ wait.trigger.payload_json['type'] == 'end' }}"
|
||||||
|
- action: script.person_in_driveway_detect_actions
|
||||||
|
data:
|
||||||
|
id: "{{ id }}"
|
||||||
|
title: >
|
||||||
|
{% if (wait.trigger.payload_json["after"]["sub_label"] !=
|
||||||
|
None) -%} {{
|
||||||
|
(wait.trigger.payload_json["after"]["sub_label"]) | title
|
||||||
|
}} {%- else -%} {{ label | replace("_", " ") | title }}
|
||||||
|
{%- endif %} was detected in the {{ after_zones[0] |
|
||||||
|
replace("_", " ") | title }}
|
||||||
|
message: >-
|
||||||
|
Detected with {{ int(score | round(2) * 100) }}%
|
||||||
|
confidence
|
||||||
|
notifTag: "{{ id }}"
|
||||||
|
notifIcon: mdi:doorbell-video
|
||||||
|
group: >
|
||||||
|
frigate-notification-{{
|
||||||
|
trigger.payload_json["after"]["camera"] }}
|
||||||
|
importance: default
|
||||||
|
image: /api/frigate/notifications/{{ id }}/snapshot.jpg
|
||||||
|
video: >-
|
||||||
|
home-assistant.sthome.org/api/{{ id }}/{{ camera
|
||||||
|
}}/clip.mp4
|
||||||
|
clickAction: >
|
||||||
|
https://home-assistant.sthome.org/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4
|
||||||
|
camera: "{{ camera }}"
|
||||||
|
until:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ wait.trigger.payload_json[\"type\"] == \"end\" }}"
|
||||||
|
default: []
|
||||||
|
mode: parallel
|
||||||
|
max: 10
|
||||||
125
home-assistant/Person detect Actions.yml
Normal file
125
home-assistant/Person detect Actions.yml
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
alias: Person detect Actions
|
||||||
|
description: ""
|
||||||
|
variables:
|
||||||
|
relay: null
|
||||||
|
counter: null
|
||||||
|
sequence:
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ camera == 'Driveway' }}"
|
||||||
|
then:
|
||||||
|
- variables:
|
||||||
|
relay: switch.sthome_ut1_relay_1
|
||||||
|
counter: counter.driveway_person_alarm_counter
|
||||||
|
else:
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ camera == 'Patio' }}"
|
||||||
|
then:
|
||||||
|
- variables:
|
||||||
|
relay: switch.sthome_ut1_relay_2
|
||||||
|
counter: counter.patio_person_alarm_counter
|
||||||
|
else:
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ camera == 'Westwall' }}"
|
||||||
|
then:
|
||||||
|
- variables:
|
||||||
|
relay: switch.sthome_ut1_relay_2
|
||||||
|
counter: counter.west_wall_person_alarm_counter
|
||||||
|
else:
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ camera == 'Eastwall' }}"
|
||||||
|
then:
|
||||||
|
- variables:
|
||||||
|
relay: switch.sthome_ut1_relay_3
|
||||||
|
counter: counter.east_wall_person_alarm_counter
|
||||||
|
else:
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ camera == 'Backyard' }}"
|
||||||
|
then:
|
||||||
|
- variables:
|
||||||
|
relay: switch.sthome_ut1_relay_4
|
||||||
|
counter: counter.backyard_person_alarm_counter
|
||||||
|
else:
|
||||||
|
- stop: Unknown camera
|
||||||
|
- action: counter.increment
|
||||||
|
target:
|
||||||
|
entity_id: "{{ counter }}"
|
||||||
|
data: {}
|
||||||
|
- action: switch.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: "{{ relay }}"
|
||||||
|
data: {}
|
||||||
|
- action: script.send_dynamic_notification_to_all_devices
|
||||||
|
data:
|
||||||
|
id: "{{ id }}"
|
||||||
|
title: "{{ title }}"
|
||||||
|
message: "{{ message }}"
|
||||||
|
notifTag: "{{ notifTag }}"
|
||||||
|
notifIcon: "{{ notifIcon }}"
|
||||||
|
group: "{{ group }}"
|
||||||
|
importance: "{{ importance }}"
|
||||||
|
image: "{{ image }}"
|
||||||
|
video: "{{ video }}"
|
||||||
|
clickAction: "{{ clickAction }}"
|
||||||
|
enabled: true
|
||||||
|
fields:
|
||||||
|
id:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
title:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: title
|
||||||
|
required: true
|
||||||
|
message:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: message
|
||||||
|
required: true
|
||||||
|
notiftag:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: notifTag
|
||||||
|
required: true
|
||||||
|
notificon:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: notifIcon
|
||||||
|
required: true
|
||||||
|
group:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: group
|
||||||
|
required: true
|
||||||
|
importance:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: importance
|
||||||
|
required: true
|
||||||
|
image:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: image
|
||||||
|
required: true
|
||||||
|
clickaction:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: clickAction
|
||||||
|
required: true
|
||||||
|
video:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: video
|
||||||
|
required: true
|
||||||
|
camera:
|
||||||
|
selector:
|
||||||
|
entity: {}
|
||||||
|
name: camera
|
||||||
|
description: Name of camera as defined in Frigate
|
||||||
|
required: true
|
||||||
107
home-assistant/Send Dynamic Notification To All Devices.yml
Normal file
107
home-assistant/Send Dynamic Notification To All Devices.yml
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
alias: Send Dynamic Notification To All Devices
|
||||||
|
sequence:
|
||||||
|
- parallel:
|
||||||
|
# - if:
|
||||||
|
# - condition: template
|
||||||
|
# value_template: '{{ send_to_fold | default(True) }}'
|
||||||
|
# then:
|
||||||
|
# - data:
|
||||||
|
# message: '{{ message }}'
|
||||||
|
# title: '{{ title }}'
|
||||||
|
# data:
|
||||||
|
# channel: '{{ channel }}'
|
||||||
|
# clickAction: '{{ video }}'
|
||||||
|
# tag: '{{ notifTag }}'
|
||||||
|
# group: '{{ group }}'
|
||||||
|
# image: '{% if (importance == "default" and video != null) -%} {{ null
|
||||||
|
# }} {%- else -%} {{ image }} {%- endif %}'
|
||||||
|
# video: '{% if (importance == "default" and video != null) -%} {{ video
|
||||||
|
# }} {%- else -%} {{ null }} {%- endif %}'
|
||||||
|
# notification_icon: '{{ notifIcon }}'
|
||||||
|
# importance: '{{ importance }}'
|
||||||
|
# action: notify.mobile_app_fold
|
||||||
|
- data:
|
||||||
|
message: '{{ message }}'
|
||||||
|
title: '{{ title }}'
|
||||||
|
data:
|
||||||
|
url: '{{ video }}'
|
||||||
|
tag: '{{ notifTag }}'
|
||||||
|
group: '{{ group }}'
|
||||||
|
attachment:
|
||||||
|
url: '{% if (importance == "default" and video != null) -%} {{ video }} {%- else -%} {{ image }} {%- endif %}'
|
||||||
|
push:
|
||||||
|
interruption-level: '{% if importance == "max" -%} time-sensitive {%- else -%} passive {%- endif %}'
|
||||||
|
# must test above data sent to notify.mobile_app_sm_n986b and check whether the following data is needed
|
||||||
|
# actions:
|
||||||
|
# - action: URI
|
||||||
|
# title: Open Image
|
||||||
|
# uri: https://home-assistant.sthome.org/api/frigate/notifications/{{ id }}/thumbnail.jpg?format=android
|
||||||
|
action: notify.mobile_app_sm_n986b
|
||||||
|
# - if:
|
||||||
|
# - condition: template
|
||||||
|
# value_template: '{{ states("media_player.nova4k") != "off" }}'
|
||||||
|
# - condition: template
|
||||||
|
# value_template: '{{ importance == "max" }}'
|
||||||
|
# then:
|
||||||
|
# - data:
|
||||||
|
# message: '{{ message }}'
|
||||||
|
# title: '{{ title }}'
|
||||||
|
# data:
|
||||||
|
# fontsize: medium
|
||||||
|
# image:
|
||||||
|
# url: https://frigate.sthome.org/api/events/{{id}}/snapshot.jpg
|
||||||
|
# action: notify.nova_4k
|
||||||
|
mode: parallel
|
||||||
|
icon: mdi:bell-ring-outline
|
||||||
|
max: 10
|
||||||
|
fields:
|
||||||
|
id:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
title:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: title
|
||||||
|
required: true
|
||||||
|
message:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: message
|
||||||
|
required: true
|
||||||
|
notiftag:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: notifTag
|
||||||
|
required: true
|
||||||
|
notificon:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: notifIcon
|
||||||
|
required: true
|
||||||
|
group:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: group
|
||||||
|
required: true
|
||||||
|
importance:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: importance
|
||||||
|
required: true
|
||||||
|
image:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: image
|
||||||
|
required: true
|
||||||
|
clickaction:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: clickAction
|
||||||
|
required: true
|
||||||
|
video:
|
||||||
|
selector:
|
||||||
|
text: null
|
||||||
|
name: video
|
||||||
|
required: true
|
||||||
@ -1,11 +1,11 @@
|
|||||||
alias: Outside - Driveway & Front Yard - Frigate Event - Cat / Dog / Person Seen
|
alias: Frigate Person Detect Notification
|
||||||
description: ''
|
description: 'This automation is used to send a notification when a person is detected by Frigate. It uses the frigate MQTT event stream to trigger the notification and includes a snapshot of the detected object. The notification will be sent to all devices with the specified group and will include a video clip of the detection if available.'
|
||||||
# The trigger is mqtt and will fire whenever an object is detected by YOUR_CAMERA_NAME
|
# The trigger is mqtt and will fire whenever an object is detected by YOUR_CAMERA_NAME
|
||||||
trigger:
|
trigger:
|
||||||
- platform: mqtt
|
- platform: mqtt
|
||||||
topic: frigate/events
|
topic: homeassistant/events
|
||||||
id: frigate-event
|
id: frigate-event
|
||||||
payload: YOUR_CAMERA_NAME
|
payload: Driveway
|
||||||
value_template: "{{ value_json['after']['camera'] }}"
|
value_template: "{{ value_json['after']['camera'] }}"
|
||||||
variables:
|
variables:
|
||||||
after_zones: "{{ trigger.payload_json['after']['entered_zones'] }}"
|
after_zones: "{{ trigger.payload_json['after']['entered_zones'] }}"
|
||||||
@ -27,14 +27,14 @@ condition:
|
|||||||
# This ensures that the object at least has one zone, this can be removed if you don't care about zones
|
# This ensures that the object at least has one zone, this can be removed if you don't care about zones
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: '{{ trigger.payload_json["after"]["entered_zones"]|length > 0 }}'
|
value_template: '{{ trigger.payload_json["after"]["entered_zones"]|length > 0 }}'
|
||||||
# This specifically checks for the object to be in the driveway or front_yard zone. This can be removed or those names changed to fit your use case.
|
# This specifically checks for the object to be in the specified zones. This can be removed or those names changed to fit your use case.
|
||||||
for example:
|
#for example:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: >-
|
value_template: >-
|
||||||
{{ ["driveway", "front_yard"] | select("in",
|
{{ ["driveway_z1", "Driveway_Paving"] | select("in",
|
||||||
after_zones) | list | length > 0 }}
|
after_zones) | list | length > 0 }}
|
||||||
alias: Object is in Driveway or Front Yard
|
alias: Object is in Driveway
|
||||||
# This filters out any car objects as I have a separate automation with different behavior for car. This can be removed if not applicable to your use case.
|
# This filters out any car objects. This can be removed if not applicable to your use case.
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: '{{ trigger.payload_json["after"]["label"] != "car" }}'
|
value_template: '{{ trigger.payload_json["after"]["label"] != "car" }}'
|
||||||
action:
|
action:
|
||||||
@ -71,7 +71,7 @@ action:
|
|||||||
sequence:
|
sequence:
|
||||||
- wait_for_trigger:
|
- wait_for_trigger:
|
||||||
- platform: mqtt
|
- platform: mqtt
|
||||||
topic: frigate/events
|
topic: homeassistant/events
|
||||||
payload: "{{ trigger.payload_json[\"after\"][\"id\"] }}"
|
payload: "{{ trigger.payload_json[\"after\"][\"id\"] }}"
|
||||||
value_template: "{{ value_json[\"after\"][\"id\"] }}"
|
value_template: "{{ value_json[\"after\"][\"id\"] }}"
|
||||||
continue_on_timeout: false
|
continue_on_timeout: false
|
||||||
@ -98,9 +98,9 @@ action:
|
|||||||
image: >-
|
image: >-
|
||||||
/api/frigate/notifications/{{ id }}/snapshot.jpg
|
/api/frigate/notifications/{{ id }}/snapshot.jpg
|
||||||
video: >-
|
video: >-
|
||||||
HASS_URL_BASE/api/{{id}}/{{camera}}/clip.mp4
|
home-assistant.sthome.org/api/{{id}}/{{camera}}/clip.mp4
|
||||||
clickAction: >-
|
clickAction: >-
|
||||||
http://HASS_URL_BASE/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4
|
https://home-assistant.sthome.org/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4
|
||||||
default: []
|
default: []
|
||||||
mode: parallel
|
mode: parallel
|
||||||
max: 10
|
max: 10
|
||||||
|
|||||||
24
home-assistant/notification to android tv.yml
Normal file
24
home-assistant/notification to android tv.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# NOT WORKING
|
||||||
|
|
||||||
|
# Adding notify to Configuration.yaml file
|
||||||
|
# --------------------------------------------------------
|
||||||
|
# open home-assistant configration.yaml file with nano
|
||||||
|
nano /mnt/SSD1/docker/data/home-assistant/config/configuration.yaml
|
||||||
|
# Add the following lines to the end of the file
|
||||||
|
notify:
|
||||||
|
- platform: androidtv
|
||||||
|
name: Android TV
|
||||||
|
host: nova4k.sthome.org
|
||||||
|
|
||||||
|
# Checking the configuration and restarting home-assistant
|
||||||
|
# --------------------------------------------------------
|
||||||
|
# In home-assistant, go to Developer Tools > YAML and click Check Configuration.
|
||||||
|
# If there are no errors, click Restart to apply the changes.
|
||||||
|
|
||||||
|
# In home-assistant, go to Developer Tools > Services and select the notify service.
|
||||||
|
# In the Service Data field, enter the following JSON:
|
||||||
|
{
|
||||||
|
"message": "Hello from Home Assistant!",
|
||||||
|
"title": "Test Notification",
|
||||||
|
"target": "Android TV"
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user