Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frigate 0.14 #216

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open

Frigate 0.14 #216

wants to merge 40 commits into from

Conversation

SgtBatten
Copy link
Owner

@SgtBatten SgtBatten commented May 29, 2024

Bugs

  • sub_labels not defined
  • "Person['person']" due to bad variable mapping
  • Notifications labeled with the wrong camera
  • Only get alerts IF zone filter switch is OFF (Possibly fixed) SOMEONE PLEASE CONFIRM
  • Short events result in an incomplete video being attached which often doesnt show the objects (delay needed?)
  • Turning on filters and selecting person causes all of my cameras NOT to send a notification.
  • Delay in notifications arriving
  • message contains all labels, not restricted to desired labels

Features

  • user can set choose severity (alert or detection)
  • can attach the new review gif to the notification (pending frigate integration API update)
  • incorporate new tts options from main branch @djak250

To Do:

  • Update the loop to make it work with 0.14
  • confirm if the user choice of alerts/detections works
  • send message on end of event is video is meant to be send (best chance of recieving video)
  • one automation for multiple cameras (I have some ideas)
  • merge all changes that have been made in the main branch

Thoughts

  • Do we process it as a loop like the current frigate/events version, or process each message in frigate/reviews
  • Can it be built such that it supports both the review and event topics (user selection)

@HenningL-Atea

This comment was marked as resolved.

@Elder-HVAC-Man
Copy link

Elder-HVAC-Man commented Jun 2, 2024

Testing with HenningL's change. Only get alerts IF zone filter switch is OFF. Can't have any zones or object filters as well or automation does not fire. When it does fire, I get alerts on my iWatch, but no snaps or video.

Not sure if it helps, but error message from logs:

Logger: homeassistant.helpers.template
Source: helpers/template.py:2613
First occurred: 10:00:43 AM (3 occurrences)
Last logged: 10:00:43 AM

Template variable warning: 'new_snapshot' is undefined when rendering 'DEBUG (in loop): Send Notification: {{ custom_filter and not home and zone_filter and zone_multi_filter and state_true and (new_snapshot or presence_changed or zone_only_changed or entered_zones_changed ) }} Info: sublabel: {{sub_labels | join(', ')}}, image: "{{base_url}}/api/frigate{{client_id}}/notifications/{{events[0]}}/{{attachment}}" Title: {{title}} message: {{message}} iOS sound: {{'Critical' if critical else 'disabled by alert once' if alert_once else 'enabled'}}, Android Sound: {{'disabled by alert once' if alert_once else 'enabled'}}, iOS url: /api/frigate{{client_id}}/notifications/{{id}}/{{camera + '/clip.mp4' if video|length>0 and wait.trigger.payload_json['type'] == 'end' else attachment }} video: "{{video}}" critical: {{critical}}, Triggers: Presence Changed: {{presence_changed}}, Entered Zones Changed: {{'True' if event['before']['data']['zones'] != event['after']['data']['zones'] else 'False'}}{{' - Disabled' if not zone_only}}, Conditions: Filters: Zones: Zone Filter Enabled: {{zone_only}}, Multi Zone Enabled: {{zone_multi}}, Required Zones: {{input_zones}}, Last Zones: {{last_zones}}, Entered zones: {{enteredzones|list|length}} - {{enteredzones}}, TEST: {{'PASS' if not zone_only or (not zone_multi and zones|select('in', enteredzones)|list|length ) else 'PASS (Multi)' if zone_only and zone_multi and zone_multi_filter else 'FAIL (Multi)' if zone_only and zone_multi else 'FAIL' }}, Object Filter: Input: {{input_labels}}, TEST: {{'PASS' if not labels|length or object in labels else 'FAIL'}}, Presence entity (not home): Entity: {{presence_entity}}, TEST: {{'PASS' if not home else 'FAIL'}}, Time Filter: Disabled times: {{disable_times}}, TEST: {{'PASS' if now().hour not in disable_times else 'FAIL'}} State Filter: state filter toggle on: {{state_only}}, state filter entity: {{input_entity}}, required states: {{input_states}}, TEST: {{'PASS' if state_true else 'FAIL'}}, Custom Filter: {{'PASS' if custom_filter else 'FAIL'}},'

Trying to view clip on iPhone, I get this message:
{"message":"Event not found", "success": false}

@HenningL-Atea
Copy link

There are some inconsistencies with the alerts;

  • Alert tekst says "Person['person'] detected on the yard camera", probably parsing of detected objects label doesn't work as intended ( {{ label }} translates to Person ['person'] )
  • I get alerts from one camera, but with snapshot from another camera, seems like snapshot is correct, but camera name in alert is wrong.
  • Links for clips and snapshots doesn't work ("Event not found").

@SgtBatten
Copy link
Owner Author

There are some inconsistencies with the alerts;

Keep these coming, i appreciate it. Not much time so will update when i can. This is valuable though.

@HenningL-Atea

This comment was marked as resolved.

@SgtBatten

This comment was marked as resolved.

@Amadou91

This comment was marked as resolved.

@SgtBatten

This comment was marked as outdated.

@rroller

This comment was marked as outdated.

SgtBatten added 3 commits June 6, 2024 22:30
minor refactors

Removed loop for now to focus on core notifications, may be permanent. time will tell
refactor some of the code
@SgtBatten

This comment was marked as outdated.

@Elder-HVAC-Man

This comment was marked as resolved.

@SgtBatten

This comment was marked as outdated.

@SgtBatten SgtBatten marked this pull request as draft June 9, 2024 09:18
@SgtBatten
Copy link
Owner Author

Turning on filters and selecting person causes all of my cameras NOT to send a notification.

Fixed this

@rroller
Copy link

rroller commented Jun 10, 2024

Pulled the latest changes. Working great so far

@jacobrian

This comment was marked as resolved.

@SgtBatten

This comment was marked as resolved.

@jacobrian

This comment was marked as resolved.

@SgtBatten

This comment was marked as resolved.

* unify android and IOS attachment options

* Fix attachment input

* refactoring

* restore attachment for IOS

* dont set content type test

* try to fix content-type

* big refactor

* add comment

* Update Beta

* Reduce Description bloat

* Update Beta
review  id was missing
@SgtBatten
Copy link
Owner Author

@ppetro08 It will handle it now

@SgtBatten
Copy link
Owner Author

SgtBatten commented Jan 19, 2025

  • If the first detection in the list of detections isn't the one that triggered the alert, then I get the clip not found error. The snapshot link, which also uses that same detection id works, and so does the review_preview which is based on the review_id. It's just the clip.mp4 in this case that isn't available.

Not sure how to improve this one. It is a list of unpredictable length

ETA: is there a method to get the last element in the array? could reverse it maybe

@SgtBatten
Copy link
Owner Author

I'm just testing the latest commit, and it appears that the zone enforcement and debug logging are broken. I'll try to dig to get more information and post back shortly, but wanted to check in to see if either were working for anybody else in the meantime?

Fixed now mate

@SgtBatten
Copy link
Owner Author

  • In the DEBUG output, the "Required objects TEST" section always shows FAIL,

Fixed

@SgtBatten
Copy link
Owner Author

If I could get a show of hands of the latest version working I think we are good enough to merge into beta.

Please share your automation configs if experiencing issues and enable debug to share anything relevant.

@igiannakas
Copy link

Installed the latest version today. So far so good!

@ppetro08
Copy link

ppetro08 commented Jan 19, 2025

First of all, thank you so much @SgtBatten for all your hard work! The notifications seem to be coming through with an image for the scenario of an alert happening from an event that started as a detection.

Config
alias: Frigate Notifications
description: ""
use_blueprint:
  path: SgtBatten/Beta.yaml
  input:
    presence_filter:
      - ""
    camera:
      - camera.doorbell
    notify_device: <<REDACTED>>
    notify_group: all_phones
    message: >-
      {{ label }}{{ ' was' if type == 'end' else '' }} detected on the {{
      camera_name }} camera{{' in the ' if after_zones|length}}{{ after_zones |
      join(', ') | replace('_', ' ' ) | title }}.
    critical: "true"
    alert_once: true
    attachment: >-
      {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/snapshot.jpg?bbox=1?format=android
    icon: mdi:cctv
    tap_action: app://com.mcu.reolink
    debug: true
    update_sub_label: false
    zone_filter: true
    zones:
      - front_yard
      - driveway
    labels:
      - person
      - car
    base_url: <<REDACTED>>

Couple more issues that I've noticed, some may be the automation and some may be tweaks I need to make to my frigate config.

  1. Some notifications seem to come in with a picture but no text. I forgot to up my trace amount after updating the config so I lost this one unfortunately.
  2. The notifications that do come through with text reads as ['person'] detected on the Doorbell camera in the Front Yard
    2.1 When I try to download the trace it gets cutuff, here's the MQTT payload that came in, let me know if you need more
MQTT Payload
    {"type": "new", "before": {"id": "1737312336.993025-ddxlv2", "camera":
    "Doorbell", "start_time": 1737312336.993025, "end_time": null, "severity":
    "detection", "thumb_path":
    "/media/frigate/clips/review/thumb-Doorbell-1737312336.993025-ddxlv2.webp",
    "data": {"detections": ["1737312336.552329-p3fweu"], "objects": ["person"],
    "sub_labels": [], "zones": [], "audio": []}}, "after": {"id":
    "1737312336.993025-ddxlv2", "camera": "Doorbell", "start_time":
    1737312336.993025, "end_time": null, "severity": "detection", "thumb_path":
    "/media/frigate/clips/review/thumb-Doorbell-1737312336.993025-ddxlv2.webp",
    "data": {"detections": ["1737312336.552329-p3fweu"], "objects": ["person"],
    "sub_labels": [], "zones": [], "audio": []}}}
  1. attachment's query params is built incorrectly for snapshots, it has 2 ?'s {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/snapshot.jpg?bbox=1?format=android

@SgtBatten
Copy link
Owner Author

2. text reads as ['person']

Should be fixed now.

3. attachment's query params is built incorrectly for snapshots, it has 2 ?'s

Fixed, Thanks

  1. notifications seem to come in with a picture but no text.

Have you always only sent an image and not a video? I've always sent a video until now as we have the review gif.
This is the thing that's stopped me progressing for 2 weeks, I cant fix it. The message only comes through if i send a video. If you change the message key to title in your automation config it works perfectly albeit with bolded text.

I tried rolling back and it didnt help. I tried removing the video key from the blueprint completely and it didn't help so it's not an issue with setting video to None specifically.

@ppetro08
Copy link

ppetro08 commented Jan 19, 2025

Thanks for the quick fixes! I've always used snapshot for 2 reasons. One is because if I get a notification with a picture of nothing I want to know what the notification was sent for, in this instance I could look at frigate and see what the alert was for around that time period. And 2 is sometimes the gifs are lengthy and I just want to know who/what triggered the notification since I have the issue of cars on the street getting detected and extending the alert.

The issue with the text sending with the image seems flaky sometimes it will work and sometimes I get just the image or just the text.

Will the gif get attached to the notification before the "end" event is sent?

Also I'd be happy to help debug the automation but I'm not sure how to go about it, I'm pretty green to Frigate and Home Automation.

@igiannakas
Copy link

Agreed on the snapshot. Sometimes you get the box. Some times you don’t. Not really sure what’s driving this behaviour - I’ve just been assuming that the snapshot wasn’t available or something similar from frigate but it may be a bug in the automation?

@SgtBatten
Copy link
Owner Author

Will the gif get attached to the notification before the "end" event is sent?

I typically get the first few frames up to a couple of seconds of the object in the initial notification, then the full gif after it is over.

I'd consider a seperate input for the initial notification and the update loop maybe. Then you set snapshot initially and gif for any updates.

@SgtBatten
Copy link
Owner Author

The issue with the text sending with the image seems flaky sometimes it will work and sometimes I get just the image or just the text

It's odd.

I have 100% success but setting the text in the title
I have 100% failure when it is set to message unless I have video set which then gives me 100% success with message.

@SgtBatten
Copy link
Owner Author

Sometimes you get the box. Some times you don’t.

For testing, try an initial delay of 1-2 seconds.

@igiannakas
Copy link

Sometimes you get the box. Some times you don’t.

For testing, try an initial delay of 1-2 seconds.

Already at 2 seconds initial delay. Updated to 5 and will test tomorrow :)

@kiloptero
Copy link

kiloptero commented Jan 20, 2025 via email

@ppetro08
Copy link

It's odd.

I have 100% success but setting the text in the title I have 100% failure when it is set to message unless I have video set which then gives me 100% success with message.

Just had an interesting one today, I got a notification with text and image and my wife only got an image. lol

I'll try out the gif to see how I like it now that I've gotten Frigate fine tuned to have less false positives.

@ppetro08
Copy link

Sometimes you get the box. Some times you don’t.

For testing, try an initial delay of 1-2 seconds.

Already at 2 seconds initial delay. Updated to 5 and will test tomorrow :)

@igiannakas Have you updated to 0.14.0.2s yet? There was a fix in there for snapshots.

@SgtBatten
Copy link
Owner Author

Their issue is not getting bounding boxes. Which as far as I know are rendered in real time but possibly only during the event.

So is there a chance your event is only a few seconds long when these go missing @igiannakas

@SgtBatten
Copy link
Owner Author

Please check the TTS error

@igiannakas
Copy link

Their issue is not getting bounding boxes. Which as far as I know are rendered in real time but possibly only during the event.

So is there a chance your event is only a few seconds long when these go missing @igiannakas

That’s quite possible. In any case this is by far not a deal breaker as the image does come through just not with the bounding box.

@ppetro08 indeed I am on 0.2.s. Updating now to remove the TTS error too.

@igiannakas
Copy link

TTS error is corrected in the latest commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.