Fixed URL gfor home-assistant send dynamic notification

This commit is contained in:
Chris Stuurman 2025-04-20 22:49:26 +02:00
parent c831770ac8
commit 26a21600f3
10 changed files with 844 additions and 42 deletions

View File

@ -0,0 +1,22 @@
# deprecated
alias: "FRIGATE: Car counter"
description: FRIGATE car counter - front yard
triggers:
- topic: homeassistant/events
trigger: mqtt
conditions:
- condition: template
value_template: "{{ trigger.payload_json['after']['label'] == 'car' }}"
- condition: template
value_template: "{{ 'driveway_zall' in trigger.payload_json['after']['entered_zones'] }}"
actions:
- action: script.person_in_driveway_detect_actions
metadata: {}
data:
relay: switch.sthome_ut1_relay_4
counter: counter.car_counter
- action: notify.mobile_app_sm_n986b
data:
message: test message
title: Test
mode: single

View File

@ -29,6 +29,14 @@ conditions:
- condition: template - condition: template
value_template: "{{ trigger.payload_json[\"after\"][\"entered_zones\"]|length > 0 }}" value_template: "{{ trigger.payload_json[\"after\"][\"entered_zones\"]|length > 0 }}"
enabled: false enabled: false
# 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.
# for example:
- condition: template
value_template: '{{ ["driveway_z1", "driveway_zall"] | select("in", after_zones) | list | length > 0 }}'
alias: Object is in Street or Front Yard
# This filters out any car objects.
- condition: template
value_template: '{{ trigger.payload_json["after"]["label"] != "car" }}'
actions: actions:
- choose: - choose:
- conditions: - conditions:

View File

@ -45,28 +45,50 @@ sequence:
counter: counter.backyard_person_alarm_counter counter: counter.backyard_person_alarm_counter
else: else:
- stop: Unknown camera - stop: Unknown camera
- action: counter.increment - if:
target: - condition: template
entity_id: "{{ counter }}" value_template: "{{ importance == \"max\" }}"
data: {} then:
- action: switch.turn_on action: counter.increment
target: target:
entity_id: "{{ relay }}" entity_id: "{{ counter }}"
data: {} data: {}
- action: script.send_dynamic_notification_to_all_devices - if:
- condition: template
value_template: "{{ importance == \"max\" }}"
then:
action: switch.turn_on
target:
entity_id: "{{ relay }}"
data: {}
- action: script.send_dynamic_notification_to_devices
data: data:
send_to_sm_n986b: "{{ send_to_sm_n986b }}"
send_to_nova_4k: "{{ send_to_nova_4k }}"
id: "{{ id }}" id: "{{ id }}"
title: "{{ title }}" title: "{{ title }}"
message: "{{ message }}" message: "{{ message }}"
notifTag: "{{ notifTag }}" notifTag: "{{ notifTag }}"
notifIcon: "{{ notifIcon }}" notifIcon: "{{ notifIcon }}"
group: "{{ group }}" group: "{{ group }}"
channel: "{{ channel }}"
importance: "{{ importance }}" importance: "{{ importance }}"
base_url: "{{ base_url }}"
image: "{{ image }}" image: "{{ image }}"
video: "{{ video }}" video: "{{ video }}"
clickAction: "{{ clickAction }}" when: "{{ when }}"
enabled: true enabled: true
fields: fields:
send_to_sm_n986b:
selector:
boolean: null
name: send_to_sm_n986b
required: false
send_to_nova_4k:
selector:
boolean: null
name: send_to_nova_4k
required: false
id: id:
selector: selector:
text: null text: null
@ -97,21 +119,31 @@ fields:
text: null text: null
name: group name: group
required: true required: true
channel:
selector:
text: null
name: channel
required: true
priority:
selector:
text: null
name: priority
required: true
importance: importance:
selector: selector:
text: null text: null
name: importance name: importance
required: true required: true
base_url:
selector:
text: null
name: base_url
required: true
image: image:
selector: selector:
text: null text: null
name: image name: image
required: true required: true
clickaction:
selector:
text: null
name: clickAction
required: true
video: video:
selector: selector:
text: null text: null
@ -123,3 +155,8 @@ fields:
name: camera name: camera
description: Name of camera as defined in Frigate description: Name of camera as defined in Frigate
required: true required: true
when:
selector:
text: null
name: when
required: true

View File

@ -1,34 +1,52 @@
alias: Send Dynamic Notification To All Devices alias: Send Dynamic Notification To All Devices
sequence: sequence:
- variables:
image_url: "{{ base_url~image }}"
video_url: "{{ base_url~video }}"
- parallel: - parallel:
# - if: - if:
# - condition: template - condition: template
# value_template: '{{ send_to_fold | default(True) }}' value_template: '{{ send_to_sm_n986b | default(True) }}'
# then: then:
# - data: - data:
# message: '{{ message }}' message: "{{ message }}"
# title: '{{ title }}' title: "{{ title }}"
# data: data:
# channel: '{{ channel }}' sticky: "true"
# clickAction: '{{ video }}' color: "#2DF56D"
# tag: '{{ notifTag }}' channel: "{{ channel }}"
# group: '{{ group }}' vibrationPattern: 100, 1000, 100, 1000, 100
# image: '{% if (importance == "default" and video != null) -%} {{ null priority: "{{ priority }}"
# }} {%- else -%} {{ image }} {%- endif %}' ledColor: red
# video: '{% if (importance == "default" and video != null) -%} {{ video importance: "{{ importance }}"
# }} {%- else -%} {{ null }} {%- endif %}' clickAction: "{{ image_url }}"
# notification_icon: '{{ notifIcon }}' tag: "{{ notifTag }}"
# importance: '{{ importance }}' group: "{{ group }}"
# action: notify.mobile_app_fold image: >-
{% if (importance == "default" and video != null) -%} {{ null }}
{%- else -%} {{ image_url }} {%- endif %}
video: >-
{% if (importance == "default" and video != null) -%} {{ video_url
}} {%- else -%} {{ null }} {%- endif %}
notification_icon: "{{ notifIcon }}"
when: "{{ when }}"
actions:
- action: URI
title: Open Image
uri: "{{ image_url }}"
- action: URI
title: Open Clip
uri: "{{ video_url }}"
action: notify.mobile_app_sm_n986b
- data: - data:
message: '{{ message }}' message: '{{ message }}'
title: '{{ title }}' title: '{{ title }}'
data: data:
url: '{{ video }}' url: '{{ video_url }}'
tag: '{{ notifTag }}' tag: '{{ notifTag }}'
group: '{{ group }}' group: '{{ group }}'
attachment: attachment:
url: '{% if (importance == "default" and video != null) -%} {{ video }} {%- else -%} {{ image }} {%- endif %}' url: '{% if (importance == "default" and video != null) -%} {{ video }} {%- else -%} {{ image_url }} {%- endif %}'
push: push:
interruption-level: '{% if importance == "max" -%} time-sensitive {%- else -%} passive {%- endif %}' 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 # must test above data sent to notify.mobile_app_sm_n986b and check whether the following data is needed
@ -55,6 +73,16 @@ mode: parallel
icon: mdi:bell-ring-outline icon: mdi:bell-ring-outline
max: 10 max: 10
fields: fields:
send_to_sm_n986b:
selector:
boolean: null
name: send_to_sm_n986b
required: false
send_to_nova_4k:
selector:
boolean: null
name: send_to_nova_4k
required: false
id: id:
selector: selector:
text: null text: null
@ -90,18 +118,23 @@ fields:
text: null text: null
name: importance name: importance
required: true required: true
base_url:
selector:
text: null
name: base_url
required: true
image: image:
selector: selector:
text: null text: null
name: image name: image
required: true required: true
clickaction:
selector:
text: null
name: clickAction
required: true
video: video:
selector: selector:
text: null text: null
name: video name: video
required: true required: true
when:
selector:
text: null
name: when
required: true

View File

@ -0,0 +1,119 @@
{
"before": {
"id": "1745146820.398967-j9uxs9",
"camera": "Driveway",
"frame_time": 1745146821.63952,
"snapshot": {
"frame_time": 1745146820.802538,
"box": [
439,
131,
526,
168
],
"area": 3219,
"region": [
255,
0,
575,
320
],
"score": 0.68359375,
"attributes": []
},
"label": "car",
"sub_label": null,
"top_score": 0.720703125,
"false_positive": false,
"start_time": 1745146820.398967,
"end_time": null,
"score": 0.5234375,
"box": [
574,
133,
604,
147
],
"area": 420,
"ratio": 2.142857142857143,
"region": [
320,
0,
640,
320
],
"stationary": false,
"motionless_count": 1,
"position_changes": 1,
"current_zones": [
"driveway_zall"
],
"entered_zones": [
"driveway_zall",
"driveway_z1"
],
"has_clip": true,
"has_snapshot": true,
"attributes": {},
"current_attributes": []
},
"after": {
"id": "1745146820.398967-j9uxs9",
"camera": "Driveway",
"frame_time": 1745146821.63952,
"snapshot": {
"frame_time": 1745146820.802538,
"box": [
439,
131,
526,
168
],
"area": 3219,
"region": [
255,
0,
575,
320
],
"score": 0.68359375,
"attributes": []
},
"label": "car",
"sub_label": null,
"top_score": 0.720703125,
"false_positive": false,
"start_time": 1745146820.398967,
"end_time": 1745146822.348831,
"score": 0.5234375,
"box": [
574,
133,
604,
147
],
"area": 420,
"ratio": 2.142857142857143,
"region": [
320,
0,
640,
320
],
"stationary": false,
"motionless_count": 1,
"position_changes": 1,
"current_zones": [
"driveway_zall"
],
"entered_zones": [
"driveway_zall",
"driveway_z1"
],
"has_clip": true,
"has_snapshot": true,
"attributes": {},
"current_attributes": []
},
"type": "end"
}

View File

@ -0,0 +1,92 @@
{
"before": {
"id": "1745146820.398967-j9uxs9",
"camera": "Driveway",
"frame_time": 1745146820.398967,
"snapshot": null,
"label": "car",
"sub_label": null,
"top_score": 0,
"false_positive": true,
"start_time": 1745146820.398967,
"end_time": null,
"score": 0.71484375,
"box": [
338,
137,
436,
171
],
"area": 3332,
"ratio": 2.8823529411764706,
"region": [
225,
0,
545,
320
],
"stationary": false,
"motionless_count": 0,
"position_changes": 0,
"current_zones": [],
"entered_zones": [],
"has_clip": false,
"has_snapshot": false,
"attributes": {},
"current_attributes": []
},
"after": {
"id": "1745146820.398967-j9uxs9",
"camera": "Driveway",
"frame_time": 1745146820.604683,
"snapshot": {
"frame_time": 1745146820.604683,
"box": [
403,
136,
477,
168
],
"area": 2368,
"region": [
219,
0,
539,
320
],
"score": 0.7265625,
"attributes": []
},
"label": "car",
"sub_label": null,
"top_score": 0.720703125,
"false_positive": false,
"start_time": 1745146820.398967,
"end_time": null,
"score": 0.7265625,
"box": [
403,
136,
477,
168
],
"area": 2368,
"ratio": 2.3125,
"region": [
219,
0,
539,
320
],
"stationary": false,
"motionless_count": 1,
"position_changes": 0,
"current_zones": [],
"entered_zones": [],
"has_clip": false,
"has_snapshot": false,
"attributes": {},
"current_attributes": []
},
"type": "new"
}

View File

@ -0,0 +1,120 @@
{
"before": {
"id": "1745146820.398967-j9uxs9",
"camera": "Driveway",
"frame_time": 1745146820.802538,
"snapshot": {
"frame_time": 1745146820.802538,
"box": [
439,
131,
526,
168
],
"area": 3219,
"region": [
255,
0,
575,
320
],
"score": 0.68359375,
"attributes": []
},
"label": "car",
"sub_label": null,
"top_score": 0.720703125,
"false_positive": false,
"start_time": 1745146820.398967,
"end_time": null,
"score": 0.68359375,
"box": [
439,
131,
526,
168
],
"area": 3219,
"ratio": 2.3513513513513513,
"region": [
255,
0,
575,
320
],
"stationary": false,
"motionless_count": 0,
"position_changes": 1,
"current_zones": [
"driveway_z1",
"driveway_zall"
],
"entered_zones": [
"driveway_zall",
"driveway_z1"
],
"has_clip": true,
"has_snapshot": true,
"attributes": {},
"current_attributes": []
},
"after": {
"id": "1745146820.398967-j9uxs9",
"camera": "Driveway",
"frame_time": 1745146821.63952,
"snapshot": {
"frame_time": 1745146820.802538,
"box": [
439,
131,
526,
168
],
"area": 3219,
"region": [
255,
0,
575,
320
],
"score": 0.68359375,
"attributes": []
},
"label": "car",
"sub_label": null,
"top_score": 0.720703125,
"false_positive": false,
"start_time": 1745146820.398967,
"end_time": null,
"score": 0.5234375,
"box": [
574,
133,
604,
147
],
"area": 420,
"ratio": 2.142857142857143,
"region": [
320,
0,
640,
320
],
"stationary": false,
"motionless_count": 1,
"position_changes": 1,
"current_zones": [
"driveway_zall"
],
"entered_zones": [
"driveway_zall",
"driveway_z1"
],
"has_clip": true,
"has_snapshot": true,
"attributes": {},
"current_attributes": []
},
"type": "update"
}

View File

@ -0,0 +1,119 @@
{
"before": {
"id": "1745146820.398967-j9uxs9",
"camera": "Driveway",
"frame_time": 1745146820.802538,
"snapshot": {
"frame_time": 1745146820.802538,
"box": [
439,
131,
526,
168
],
"area": 3219,
"region": [
255,
0,
575,
320
],
"score": 0.68359375,
"attributes": []
},
"label": "car",
"sub_label": null,
"top_score": 0.720703125,
"false_positive": false,
"start_time": 1745146820.398967,
"end_time": null,
"score": 0.68359375,
"box": [
439,
131,
526,
168
],
"area": 3219,
"ratio": 2.3513513513513513,
"region": [
255,
0,
575,
320
],
"stationary": false,
"motionless_count": 0,
"position_changes": 1,
"current_zones": [
"driveway_zall"
],
"entered_zones": [
"driveway_zall"
],
"has_clip": true,
"has_snapshot": true,
"attributes": {},
"current_attributes": []
},
"after": {
"id": "1745146820.398967-j9uxs9",
"camera": "Driveway",
"frame_time": 1745146820.802538,
"snapshot": {
"frame_time": 1745146820.802538,
"box": [
439,
131,
526,
168
],
"area": 3219,
"region": [
255,
0,
575,
320
],
"score": 0.68359375,
"attributes": []
},
"label": "car",
"sub_label": null,
"top_score": 0.720703125,
"false_positive": false,
"start_time": 1745146820.398967,
"end_time": null,
"score": 0.68359375,
"box": [
439,
131,
526,
168
],
"area": 3219,
"ratio": 2.3513513513513513,
"region": [
255,
0,
575,
320
],
"stationary": false,
"motionless_count": 0,
"position_changes": 1,
"current_zones": [
"driveway_z1",
"driveway_zall"
],
"entered_zones": [
"driveway_zall",
"driveway_z1"
],
"has_clip": true,
"has_snapshot": true,
"attributes": {},
"current_attributes": []
},
"type": "update"
}

View File

@ -0,0 +1,124 @@
"driveway_zall",
"driveway_z1"
],
"has_clip": true,
"has_snapshot": true,
"attributes": {},
"current_attributes": []
},
"type": "end"
}
{
"before": {
"id": "1745146820.398967-j9uxs9",
"camera": "Driveway",
"frame_time": 1745146820.604683,
"snapshot": {
"frame_time": 1745146820.604683,
"box": [
403,
136,
477,
168
],
"area": 2368,
"region": [
219,
0,
539,
320
],
"score": 0.7265625,
"attributes": []
},
"label": "car",
"sub_label": null,
"top_score": 0.720703125,
"false_positive": false,
"start_time": 1745146820.398967,
"end_time": null,
"score": 0.7265625,
"box": [
403,
136,
477,
168
],
"area": 2368,
"ratio": 2.3125,
"region": [
219,
0,
539,
320
],
"stationary": false,
"motionless_count": 1,
"position_changes": 0,
"current_zones": [],
"entered_zones": [],
"has_clip": false,
"has_snapshot": false,
"attributes": {},
"current_attributes": []
},
"after": {
"id": "1745146820.398967-j9uxs9",
"camera": "Driveway",
"frame_time": 1745146820.802538,
"snapshot": {
"frame_time": 1745146820.802538,
"box": [
439,
131,
526,
168
],
"area": 3219,
"region": [
255,
0,
575,
320
],
"score": 0.68359375,
"attributes": []
},
"label": "car",
"sub_label": null,
"top_score": 0.720703125,
"false_positive": false,
"start_time": 1745146820.398967,
"end_time": null,
"score": 0.68359375,
"box": [
439,
131,
526,
168
],
"area": 3219,
"ratio": 2.3513513513513513,
"region": [
255,
0,
575,
320
],
"stationary": false,
"motionless_count": 0,
"position_changes": 1,
"current_zones": [
"driveway_zall"
],
"entered_zones": [
"driveway_zall"
],
"has_clip": true,
"has_snapshot": true,
"attributes": {},
"current_attributes": []
},
"type": "update"
}

View File

@ -0,0 +1,128 @@
alias: Send Dynamic Notification To Devices
sequence:
- variables:
image_url: "{{ image }}"
video_url: "{{ video }}"
- parallel:
- if:
- condition: template
value_template: "{{ send_to_sm_n986b | default(True) }}"
alias: Send to SM_N986B?
then:
- data:
message: "{{ message }}"
title: "{{ title }}"
data:
sticky: "true"
color: "#2DF56D"
channel: "{{ channel }}"
vibrationPattern: 100, 1000, 100, 1000, 100
priority: "{{ priority }}"
ledColor: red
importance: "{{ importance }}"
clickAction: "{{ image_url }}"
tag: "{{ notifTag }}"
group: "{{ group }}"
image: >-
{% if (importance == "default" and video != null) -%} {{ null
}} {%- else -%} {{ image_url }} {%- endif %}
video: >-
{% if (importance == "default" and video != null) -%} {{
video_url }} {%- else -%} {{ null }} {%- endif %}
notification_icon: "{{ notifIcon }}"
when: "{{ when }}"
actions:
- action: URI
title: Open Image
uri: "{{ image_url }}"
- action: URI
title: Open Clip
uri: "{{ video_url }}"
action: notify.mobile_app_sm_n986b
alias: "Notify: Send message to SM_N986B"
- action: counter.increment
target:
entity_id: counter.sm_n986b_notification_counter
data: {}
alias: Increment SM_N986B notification counter
enabled: true
mode: parallel
icon: mdi:bell-ring-outline
max: 10
fields:
send_to_sm_n986b:
selector:
boolean: null
name: send_to_sm_n986b
required: false
send_to_nova_4k:
selector:
boolean: null
name: send_to_nova_4k
required: false
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
channel:
selector:
text: null
name: channel
required: true
importance:
selector:
text: null
name: importance
required: true
priority:
selector:
text: null
name: priority
required: true
base_url:
selector:
text: null
name: base_url
required: true
image:
selector:
text: null
name: image
required: true
video:
selector:
text: null
name: video
required: true
when:
selector:
text: null
name: when
required: true
description: ""