Advertisement
Guest User

Untitled

a guest
Jun 30th, 2025
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.74 KB | None | 0 0
  1. alias: "Frigate AI Notifications - camera.entity"
  2. description: ""
  3. triggers:
  4. - topic: frigate/events
  5. payload: "{{ camera }}/new"
  6. value_template: >-
  7. {{ value_json['after']['camera'] | lower | replace('-','_') }}/{{
  8. value_json['type']}}
  9. id: frigate-event
  10. trigger: mqtt
  11. conditions: []
  12. actions:
  13. - variables:
  14. camera_name: "{{ camera | replace('_', ' ') | replace(' cam', '') | title }}"
  15. object: "{{ trigger.payload_json['after']['label'] }}"
  16. input_base_url: http://your.ddns:8123
  17. base_url: "{{ input_base_url.rstrip('/')}}"
  18. input_local_url: http://your.local.ip:8123
  19. local_url: "{{ input_local_url.rstrip('/')}}"
  20. input_labels:
  21. - person
  22. - dog
  23. - cat
  24. - package
  25. labels: "{{ input_labels | list | lower }}"
  26. label: "{{ object | title }}"
  27. cooldown: 45
  28. debug: true
  29. title: ""
  30. message: A {{ label }} was detected on the {{ camera_name }} camera.
  31. fps: "{{ states('sensor.' + camera + '_camera_fps')|int(5) }}"
  32. id: "{{ trigger.payload_json['after']['id'] }}"
  33. initial_entered_zones: "{{ trigger.payload_json['after']['entered_zones'] |lower}}"
  34. tap_action: "{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4"
  35. icon: >-
  36. mdi:{{'account-outline' if label == 'Person' else 'dog' if label ==
  37. 'Dog' else 'cat' if label == 'Cat' else 'car' if label == 'Car' else
  38. 'home-assistant'}}
  39. clip_url: "{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4"
  40. snapshot_url: "{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg"
  41. update_thumbnail: true
  42. alert_once: true
  43. - alias: Notifications enabled for object label
  44. condition: template
  45. value_template: "{{ not labels|length or object in labels }}"
  46. - data_template:
  47. name: Frigate Notification
  48. message: |
  49. DEBUG:
  50. Info:
  51. fps: {{fps}},
  52. frigate event id: {{id}},
  53. object (formatted): {{object}} ({{label}}),
  54. Config:
  55. camera(formatted): {{camera}}({{camera_name}}),
  56. Base URL: {{base_url}},
  57. Title: {{title}},
  58. Message: {{message}},
  59. Required objects TEST:
  60. Input: {{input_labels}},
  61. TEST: {{'PASS' if not labels|length or object in labels else 'FAIL'}}
  62. action: logbook.log
  63. - action: notify.mobile_app_phone_name
  64. data:
  65. title: "{{title}}"
  66. message: "{{message}}"
  67. data:
  68. tag: "{{ id }}"
  69. group: "{{ camera }}-frigate-notification"
  70. notification_icon: "{{icon}}"
  71. attachment:
  72. url: /api/frigate/notifications/{{id}}/thumbnail.jpg
  73. image: /api/frigate/notifications/{{id}}/thumbnail.jpg?format=android
  74. clickAction: "{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4"
  75. push:
  76. interruption-level: active
  77. alert_once: "{{alert_once}}"
  78. actions:
  79. - action: URI
  80. title: View Clip
  81. uri: "{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4"
  82. - action: URI
  83. title: View Summary
  84. uri: /dashboard-home/event-summaries
  85. - action: URI
  86. title: Open Frigate
  87. uri: http://your.ddns:8971/review
  88. - repeat:
  89. sequence:
  90. - wait_for_trigger:
  91. - topic: frigate/events
  92. payload: "{{ id }}"
  93. value_template: "{{ value_json['after']['id'] }}"
  94. trigger: mqtt
  95. timeout:
  96. minutes: 2
  97. continue_on_timeout: true
  98. - variables:
  99. event: "{{ wait.trigger.payload_json }}"
  100. new_snapshot: >-
  101. {{ update_thumbnail and event['before']['snapshot_time'] !=
  102. event['after']['snapshot_time'] }}
  103. stationary_moved: >-
  104. {{ event['after']['position_changes'] >
  105. event['before']['position_changes'] }}
  106. sub_label: "{{ event['after']['sub_label']}}"
  107. sub_label_changed: "{{ sub_label != event['before']['sub_label'] }}"
  108. update: "{{ alert_once or (new_snapshot and not sub_label_changed) }}"
  109. title: |
  110. {% if sub_label %}
  111. {{sub_label[0]}} was detected on the {{camera_name}} camera.
  112. {%else%}
  113. A {{ label }} was detected on the {{ camera_name }} camera.
  114. {%endif%}
  115. message: ""
  116. - data_template:
  117. name: Frigate Notification
  118. message: |
  119. DEBUG (in loop):
  120. Info:
  121. Last Zones: {{last_zones}},
  122. Current zones: {{entered_zones}},
  123. sublabel: {{sub_label}},
  124. IOS sound: {{update if not critical else 'yes due critical notifications'}},
  125. Android Sound: {{'disabled by alert once' if alert_once else 'enabled'}},
  126. Triggers:
  127. New Snapshot: {{new_snapshot}},
  128. Presence Changed: {{presence_changed}},
  129. stationary moved: {{stationary_moved}},
  130. entered zones changed: {{entered_zones_changed}},
  131. sublabel changed: {{sub_label_changed}},
  132. Conditions:
  133. Loitering: {{loitering}}
  134. or
  135. Presence Entity not home: {{'ON' if presence_entity != '' else 'OFF'}} - {{'PASS' if not home else 'FAIL'}},
  136. zone filter TEST: {{'ON' if zone_only else 'OFF'}} - {{'PASS' if zone_filter else 'FAIL'}},
  137. multi-zone filter: {{'OFF' if not zone_only or not zone_multi else 'ON'}} - {{'PASS' if not zone_only or not zone_multi or ( entered_zones|length and zones and zones |reject('in', entered_zones) |list |length == 0 ) else 'FAIL'}},
  138. state filter TEST: {{'ON' if state_only else 'OFF'}} - {{'PASS' if state_true else 'FAIL'}}
  139.  
  140. image: "/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}.jpg?format=android"
  141. action: logbook.log
  142. - alias: Notify on loitering or significant change
  143. choose:
  144. - conditions:
  145. - condition: template
  146. value_template: "{{new_snapshot or sub_label_changed}}"
  147. sequence:
  148. - action: notify.mobile_app_phone_name
  149. data:
  150. title: "{{title}}"
  151. message: "{{message}}"
  152. data:
  153. tag: "{{ id }}"
  154. group: "{{ camera }}-frigate-notification"
  155. notification_icon: "{{icon}}"
  156. attachment:
  157. url: /api/frigate/notifications/{{id}}/thumbnail.jpg
  158. image: >-
  159. /api/frigate/notifications/{{id}}/thumbnail.jpg?format=android
  160. clickAction: >-
  161. {{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4
  162. push:
  163. interruption-level: active
  164. alert_once: "{{alert_once}}"
  165. actions:
  166. - action: URI
  167. title: View Clip
  168. uri: >-
  169. {{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4
  170. - action: URI
  171. title: View Summary
  172. uri: /dashboard-home/event-summaries
  173. - action: URI
  174. title: Open Frigate
  175. uri: http://your.ddns:8971/review
  176. until:
  177. - condition: template
  178. value_template: "{{ not wait.trigger or wait.trigger.payload_json['type'] == 'end' }}"
  179. - alias: If LLM Vision is Running
  180. if:
  181. - condition: state
  182. entity_id: input_boolean.llm_vision_running
  183. state: "on"
  184. then:
  185. - wait_for_trigger:
  186. - trigger: state
  187. entity_id:
  188. - input_boolean.llm_vision_running
  189. from: "on"
  190. to: "off"
  191. timeout:
  192. hours: 0
  193. minutes: 3
  194. seconds: 0
  195. milliseconds: 0
  196. continue_on_timeout: false
  197. - action: input_boolean.turn_on
  198. metadata: {}
  199. data: {}
  200. target:
  201. entity_id: input_boolean.llm_vision_running
  202. - alias: "LLM Vision: Analyze Frigate Clip"
  203. action: llmvision.video_analyzer
  204. data:
  205. remember: true
  206. provider: llmvision.provider
  207. frigate_retry_attempts: 15
  208. frigate_retry_seconds: 60
  209. max_frames: 20
  210. include_filename: false
  211. target_width: 1920
  212. max_tokens: 500
  213. temperature: 0.1
  214. generate_title: true
  215. expose_images: true
  216. event_id: "{{id}}"
  217. message: >-
  218. Summarize the observed events using clear, neutral third-person
  219. language. Use the embedded timestamps to determine the correct
  220. chronological order. Focus only on moving subjects such as people,
  221. vehicles, packages, pets, lawn equipment, and other active elements.
  222. Ignore static scenery and objects unless directly interacted with. Only
  223. include stationary vehicles if clearly identifiable as delivery or
  224. emergency vehicles—include company names and visible uniform details
  225. when present. Describe activity specifically along the walkway to the
  226. back door on the left and the neighbor’s driveway on the right. Do not
  227. mention timestamps, camera angles, or observers. Present the events as
  228. if directly witnessed in real time. Avoid introductory or transitional
  229. phrases like “Here is what happened” or “In this clip,” and do not
  230. describe events frame by frame. Summarize naturally in a single,
  231. cohesive narrative. If context strongly suggests a likely outcome (e.g.,
  232. someone approaching with a package), describe it with confidence. Keep
  233. the description concise for mobile notifications. Do not mention the
  234. absence of vehicles, uniforms, or other activity, and do not conclude
  235. with statements about what was or wasn’t observed.{% if sub_label
  236. %}These images have already been passed to DeepStack and Double Take and
  237. {{sub_label[0]}} has been identified, use this knowledge as
  238. well.{%endif%}
  239. response_variable: response
  240. enabled: true
  241. - action: input_boolean.turn_off
  242. metadata: {}
  243. data: {}
  244. target:
  245. entity_id: input_boolean.llm_vision_running
  246. - variables:
  247. message: "{{response.response_text}}"
  248. - action: notify.mobile_app_phone_name
  249. data:
  250. title: "{{title}}"
  251. message: "{{message}}"
  252. data:
  253. tag: "{{ id }}"
  254. group: "{{ camera }}-frigate-notification"
  255. notification_icon: "{{icon}}"
  256. attachment:
  257. url: /api/frigate/notifications/{{id}}/thumbnail.jpg
  258. image: /api/frigate/notifications/{{id}}/thumbnail.jpg?format=android
  259. clickAction: "{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4"
  260. push:
  261. interruption-level: active
  262. alert_once: "{{alert_once}}"
  263. actions:
  264. - action: URI
  265. title: View Clip
  266. uri: "{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4"
  267. - action: URI
  268. title: View Summary
  269. uri: /dashboard-home/event-summaries
  270. - action: URI
  271. title: Open Frigate
  272. uri: http://your.ddns:8971/review
  273. trigger_variables:
  274. input_camera: camera.entity
  275. camera: "{{ input_camera | replace('camera.', '') }}"
  276. mode: single
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement