Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 50 You must be signed in to star a gist
  • Fork 13 You must be signed in to fork a gist
  • Save SgtBatten/10a2dc7f16af9f55f3ba83fe4523d8d7 to your computer and use it in GitHub Desktop.
Save SgtBatten/10a2dc7f16af9f55f3ba83fe4523d8d7 to your computer and use it in GitHub Desktop.
Frigate Notifications have moved
blueprint:
name: Frigate Notifications by SgtB have moved
description: |
## ANNOUNCEMENT
I have moved from this gist to a github repositry.
Please checkout https://github.com/SgtBatten/HA_blueprints for the latest versions
domain: automation
input:
camera:
name: This blueprint has moved.
description: Please checkout https://github.com/SgtBatten/HA_blueprints for the latest versions
selector:
text:
default: https://github.com/SgtBatten/HA_blueprints
trigger: []
action: []
@SgtBatten
Copy link
Author

"the path of the stored segments has changed from /media/frigate/recordings/%Y-%m/%d/%H-%s.mp4 to /media/frigate/recordings/%Y-%m-%d/%H-%s.mp4."

Yes, but we don't use these, we use the API which hasn't changed.

@mr-brains
Copy link

mr-brains commented Apr 10, 2023

I having troubles with zones.notify works but when i use a zone i don't get notifications.
tried the zone_0 but had trouble with the blueprint so renamed it to side.
in the logging andon the events of the cam i can see that frigate is sending the event but i dont got a notification.
any ideas?

edit:
maybe i shoeld tell wich versions i use :)
frigate 0.12
has 2023.4.1
frigate integration3.0.1
your template 0.11.0.15f

@mrplow
Copy link

mrplow commented Apr 10, 2023

@SgtBatten After setting attachment: snapshot the next notification did indeed send the snapshot with the bounding box. But every notification since is just the thumbnail. I tried turning off Update Thumbnail but that didn't seem to make a difference.

Thanks!
Home Assistant 2023.4.2
Frigate 0.12.0-DA3E197
Frigate Notifications 0.11.0.15f

alias: Frigate - Front Door - Phones
description: ""
use_blueprint:
  path: SgtBatten/frigate_0.11_notification_beta.yaml
  input:
    tv_transparency: 0%
    camera: camera.frontdoor
    notify_group: phones
    base_url: https://<redacted>
    critical: "true"
    alert_once: true
    update_thumbnail: false
    color: cyan
    icon: >-
      mdi:{{'account-outline' if label == 'Person' else 'dog' if label == 'Dog'
      else 'cat' if label == 'Cat' else 'car' if label == 'Car' else 'bird' if
      label == 'Bird' else 'panda' if label == 'Bear' else 'cctv'}}
    sticky: true
    cooldown: 300
    silence_timer: 45
    url_1: >-
      {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4
    button_2: View Stream
    url_2: >-
      {{base_url}}/api/camera_proxy_stream/camera.{{trigger.payload_json['after']['camera']}}?token={{state_attr(
      'camera.' ~ camera, 'access_token')}}
    button_3: Silence New Notifications for 45min
    tv_size: large
    channel: frigate-{{ label }}
    tv_position: center
    attachment: snapshot

@SgtBatten
Copy link
Author

@mr-brains please share your config for the automation like mrplow did above

@SgtBatten
Copy link
Author

@mrplow odd, I can't see anywhere left in the blueprint that has thumbnail.jpg anymore.

@mrplow
Copy link

mrplow commented Apr 10, 2023

@SgtBatten I'm not great at reading through code, but I think you changed it to {{attachment}}.jpg

@Delta1977
Copy link

Delta1977 commented Apr 10, 2023

@SgtBatten Hi, is there a reason why you take gist and not git from github?

@SgtBatten
Copy link
Author

@Delta1977 forked from an original gist. I could change it for easier conversations/issue tracking though

@SgtBatten
Copy link
Author

@mrplow found an issue with one of the filters incorrectly being false. it was blocking updated attachments being sent. But unsure why the first one also is not containing the bounding box. Will keep testing.

@mrplow
Copy link

mrplow commented Apr 10, 2023

Great thanks, I'll report back after giving it a thorough test

@SgtBatten
Copy link
Author

@mrplow only just updated 2 seconds ago. gotta run to work

@Delta1977
Copy link

@Delta1977 forked from an original gist. I could change it for easier conversations/issue tracking though

Yes, git is much better. When I see the threat here how long it is

@SgtBatten
Copy link
Author

@mrplow still not working for me, but images are updating again.

I'm considering hardcoding snapshots everywhere to test. Maybe frigate doesn't save the bounding box before the image gets sent.

@mr-brains
Copy link

mr-brains commented Apr 11, 2023

@mr-brains please share your config for the automation like mrplow did above
here you go:

  alias: beweging woonkamer beta
  description: ''
  use_blueprint:
    path: hunterjm/frigate_0.11_15f-beta.yaml
    input:
      tv_transparency: 0%
      camera: camera.huiskamer
      notify_device: f1dd73c85b7201c8b2faad8ba0a3347a
      base_url: http://external.url:8123
      title: Beweging!
      critical: 'true'
      alert_once: true
      tv_size: large
      tv_position: center
      color: red
      message: persoon gedetecteerd in huiskamer
      zone_filter: true
      zones:
      - side
      - examples
      zone_multi: false
      debug: true

config from the cam:

huiskamer:
    record:
      enabled: true
    ffmpeg:
      hwaccel_args: preset-vaapi
      inputs:
        - path: rtsp://user:pass@internal.ip:8554/
          roles:
            - detect
            - rtmp
    rtmp:
      enabled: False
    detect:
      width: 640
      height: 360
    zones:
      Side:
        coordinates: 0,360,640,360,90,108,0,126
      examples:
        coordinates: 585,80,640,247,365,243,370,0

@SgtBatten
Copy link
Author

SgtBatten commented Apr 11, 2023

@mrplow I have tested extensively today. It seems the primary issue is simply that the snapshot is cropped and saved in the background sometime after the notification is sent. I have tried hardcoding snaphot.jpg instead of using the variable just in case, no change.

I have been testing by running two notifications in parallel for the same camera. one with thumbnail and one with snapshot. The thumbnail one shows a cropped image, the snapshot one shows an uncropped image despite being set to crop: true. Both update simultaneously as better snapshots are taken (i move closer to camera)

Clicking view snapshot on either notification shows me the uncropped image. If i wait a little while after ending the event the same url now shows me a cropped image with the bounding box. Not sure i can solve this one

@SgtBatten
Copy link
Author

@mr-brains I may see the issue. Can you grab me the debug output please, I see you have it enabled.

You can view it easily in the notification trace by clicking on this icon
image
One is 7 down from the top and the other is 6 up from the bottom. Im more interested in the bottom one which may have many iterations. The last one should be enough.

@mr-brains
Copy link

mr-brains commented Apr 11, 2023

the top one:

Edited down to relevant bit by SgtBatten

      Required zones: ['side', 'examples'], 
      Entered Zones: ['Side'], 

@mr-brains
Copy link

also: Ah, there is where the debugging is going. i expected them in the logging of home assistant somewhere. :)

@SgtBatten
Copy link
Author

also: Ah, there is where the debugging is going. i expected them in the logging of home assistant somewhere. :)

It goes to the logbook also, but the formatting is hard to read. much easier to read in the trace.

I have just uploaded a fix for your issue.
The issue was capitalisation of your zones in frigate config.

  Required zones: ['side', 'examples'], 

  Entered Zones: ['Side'], 

See here that side is not the same as Side
The fix should make everything lowercase behind the scenes, regardless of your configuration. Please try the latest beta and let me know

@mr-brains
Copy link

on it. I was seeing that and so i tried to add the zone's with upper and lowercase. didn't work.
I let you know the result of the fix.

@mr-brains
Copy link

@SgtBatten
IT WORKS! thank you.
now up to finetuning my notifications.

@SgtBatten
Copy link
Author

i tried to add the zone's with upper and lowercase. didn't work.

Yep that wouldn't have worked because I was forcing the inputs to be lowercase already (due to users having the opposite problem to you. Now it does both so they should always match.

@SgtBatten
Copy link
Author

@mrplow I have a workaround and I really hate how much bigger the blueprint gets but try the latest beta (16a). It sends a final notification 10 seconds after the end of the event which seems to be enough time for my frigate instance to process the snapshot.

It will only send if update thumbnail is true and attachment is set to snapshot.

@Delta1977
Copy link

@Delta1977 forked from an original gist. I could change it for easier conversations/issue tracking though

@SgtBatten Do you have plans or a timeline to move to git?

@mr-brains
Copy link

@SgtBatten IT WORKS! thank you. now up to finetuning my notifications.

and that was it, worked 1 time :/
i am going to start allover, trow away what i have now and start with 1 camera.
let you know what happens.

@mr-brains
Copy link

first i had to restart HA,after that the camera we troubleshoot started working again. so that was something with my homeassist.
it looks like your blueprint doesn't like _ in the camera names. I renamed 1 camera and now it works.

other question, can i edit the zones in the automation yaml?
the tekst glitch is preventing me from typing but i kan paste and hit enter,or i just type it in the automation yaml.

@mrplow
Copy link

mrplow commented Apr 11, 2023

@SgtBatten wow, that was a big change. So far so good though. I had two notifications so far this morning and both had the bounding boxes.

@SgtBatten
Copy link
Author

blueprint doesn't like _ in the camera names

I have _ in some of mine. It does handle them fine.

Yes you can edit the zones in yaml, select one of the examples and then edit it in yaml. I have raised an issue on GitHub and someone has already done a fix but it is not yet release in homeassistant.

@SgtBatten
Copy link
Author

@Delta1977 I will clean up this repo later today but you can now use https://github.com/SgtBatten/HA_blueprints and people can raise issues there.

@Delta1977
Copy link

@Delta1977 I will clean up this repo later today but you can now use https://github.com/SgtBatten/HA_blueprints and people can raise issues there.

@SgtBatten great. Thank you for your amazing work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment