Frigate Mobile App Notifications

I want to notify using a media player with playing an audio sound (dog barking) and also based on a condition (security system activated). Can you tell me where to look in the code and I might be able to fork and modify ?

Post removed to avoid confusion. Thanks for the blueprint.

This is incorrect. The blueprint works with the Home Assistant integration for Frigate and does not require the Frigate Proxy Addon. The URLs are for the API exposed through Home Assistant which communicates to your Frigate instance internally. So long as your Home Assistant is exposed externally and you have installed the latest integration in HACS, everything should work fine - even if you leave base URL blank.

I’m only able to get notifications to work by enabling the unauthenticated notification event proxy on the config of the Frigate Home Assistant integration. Is it possible for this to work without enabling this setting? I don’t want it to be possible to view snapshots/clips without being authenticated.

1 Like

I’m had this blueprint working, but after enabling HA cloud, I’m getting the following error (I do not know if it’s related).

2021-10-21 12:26:51 ERROR (MainThread) [homeassistant.components.automation.frigate_notification] Frigate Notification: Choose at step 1: choice 1: Error executing script. Error for device at pos 1: Unable to find notify service for webhook ID
2021-10-21 12:26:51 ERROR (MainThread) [homeassistant.components.automation.frigate_notification] Frigate Notification: Error executing script. Error for choose at pos 1: Unable to find notify service for webhook ID
2021-10-21 12:26:51 ERROR (MainThread) [homeassistant.components.automation.frigate_notification] Error while executing automation automation.frigate_notification: Unable to find notify service for webhook ID

Any idea? :blush:

Hello! Does anyone know how to make that click action open the live camera?

Thank you!

I have the notification itself working and the text is correct based on the detected event, but all tap actions lead to a 400 error. I have set the base URL to be the remote access URL generated by Nabu Casa.

Is there a step I’m missing?

Also no images are sent with the notification, just text.

Do you have v2.0 or greater of the Frigate Integration installed from HACS?

Running 2.1

I have Frigate running in a Docker container in Unraid
I have Home Assistant running as an OS on an intel NUC.

The camera and clips are shown correctly in the lovelace card.

When I actually query the frigate API directly I get the clip.
When I use the HA query I get a 400.

API request from HA: http://192.168.0.YYY:8123/api/frigate/notifications/{event_id}/camera_1/clip.mp4 (400)

Direct API request to frigate instance: http://192.168.0.XXX:5000/api/events/{event_id}/clip.mp4 (Success)

It doesn’t matter if I used the Nabu Casa remote URL or the internal IP address, I get a 400 response.

Sounds like the proxy might be disabled. You can enable it by configuring it in the integrations page.

Good idea. It’s already enabled though.

Edit: Toggle on/off, reloaded the integration, restarted HA, restarted the Docker for frigate. No change.

1 Like

I was struggling with the same thing then realized that I wasn’t using ‘frigate’ as my mqtt topic. Changed two lines in the blueprint and voila! Just an idea…

I get a “502” after switching to Full Access Addin (because of HW acceleration on PI) on the images. Is there a change needed? Normal Addon without errors.

Also: sometimes the watch does not load the images at first (Session was invalidated without error, so it was likely deinitialized unexpectedly" but after opening a 2nd time while the phone always show them directly. Any idea on that?

1 Like

So the blueprint has the following:

trigger:
  platform: mqtt
  topic: frigate/events

And my frigate config has the following:

mqtt:
  topic_prefix: frigate

That lines up, right? What did you change, specifically?

Looks like you’re good, so that’s not your problem. Worth taking a look!

removed problem resolved

lol, worked it out, case sensitive :slight_smile:

Ok, so I didn’t actually have the proxy Add-on running. Now I do.

But I still have the issues. I’ve restarted everything.
The logs for the add-on don’t show anything.
I can access Frigate in the HA sidebar without issue.

But the HA API is still returning a 400.

Anyone else get a blank screen with a crossed-out play button when clicking the “view clip” action from the notification? Is there a way to specify the video encoding for notification clips?

Image shown after clicking “view clip”
Screen Shot 2021-10-29 at 11.13.21 AMa

Frigate is installed on a separate docker instance than home assistant container and both are working well. Using Frigate v0.9.1 and integration v2.1.0. All user devices are Apple products, iPhone, iPad and MacBook. Below are the encoding settings from the cameras.

Screen Shot 2021-10-28 at 9.16.25 AM

There are no issues with viewing the event or recordings video through the Frigate Web GUI on any of the devices. The event video plays fine and can be downloaded. However, the downloaded video can’t be viewed by QuickTime and I think this is related to not being able to play the notification video. Interesting thing is the downloaded recording can be played in VLC. Below is a screenshot of the codex info from VLC.

Screen Shot 2021-10-29 at 11.15.16 AM

Recordings are set to use a different subchannel that uses h.265 from the camera. 265 is much preferred due to the reduced size and Frigate doesn’t appear to have an issue using it.

I believe this is related to a camera encoder and Apple decoder incompatibility. Would a solution be keeping the recordings at h.265 but have the notification clips be h.264? Is this possible? Is there a reencoding setting for events clips that can be changed in Frigate?

cameras:

  driveway_left:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.2.11/cam/realmonitor?channel=1&subtype=2&unicast=true&proto=Onvif
          roles:
            - detect
            - rtmp
        - path: rtsp://192.168.2.11/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
          roles:
            - record
    motion:
      mask:
        - 0,0,0,167,123,173,169,230,233,223,228,0
        - 0,720,24,365,42,325,122,271,184,313,231,472,190,564,215,720

  front_patio:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.2.12/cam/realmonitor?channel=1&subtype=2&unicast=true&proto=Onvif
          roles:
            - detect
            - rtmp
        - path: rtsp://192.168.2.12/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
          roles:
            - record
    motion:
      mask:
        - 239,0,180,79,169,163,159,244,219,508,328,555,438,720,0,720,0,0
        - 704,0,1002,0,997,55,997,156,993,252,981,408,683,358,628,266,660,223,665,155,707,90

  driveway_right:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.2.13/cam/realmonitor?channel=1&subtype=2&unicast=true&proto=Onvif
          roles:
            - detect
            - rtmp
        - path: rtsp://192.168.2.13/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
          roles:
            - record
    motion:
      mask:
        - 730,152,873,151,957,209,968,340,846,308,849,403,812,489,677,550,582,470,576,376,624,300,745,270,699,181
        - 1157,720,1127,648,1082,649,998,601,956,648,934,720

  doorbell:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.2.21/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif
          roles:
            - detect
            - rtmp
        - path: rtsp://192.168.2.21/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
          roles:
            - record
    detect:
      width: 720
      height: 576
    motion:
      mask:
        - 0,0,270,0,323,51,361,98,328,113,267,125,219,151,183,207,187,333,197,439,94,576,0,555
        - 519,348,510,283,498,78,475,69,404,107,371,206,358,287,394,462

ffmpeg:
  global_args: -hide_banner -loglevel warning
  hwaccel_args:
   - -hwaccel
   - vaapi
   - -hwaccel_device
   - /dev/dri/renderD128
   - -hwaccel_output_format
   - yuv420p
  input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1
  output_args:
    detect: -f rawvideo -pix_fmt yuv420p
    record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an
    rtmp: -c copy -f flv

objects:
  track:
    - person
    - dog
  filters:
    person:
      threshold: 0.75
    dog:
      threshold: 0.75
    car:
      threshold: 0.75

detectors:
  coral:
    type: edgetpu
    device: pci

mqtt:
  host: 192.168.8.12
  port: 1883
  topic_prefix: frigate
  client_id: frigate
  user: 
  password: 
  stats_interval: 60

record:
  enabled: True
  # Optional: Number of days to retain recordings regardless of events (default: shown below)
  # NOTE: This should be set to 0 and retention should be defined in events section below
  #       if you only want to retain recordings of events.
  retain_days: 7
  events:
    max_seconds: 300
    pre_capture: 5
    post_capture: 5
    objects:
      - person
      - dog
    required_zones: []
    retain:
      default: 10
      objects:
        person: 15

snapshots:
  enabled: True
  timestamp: True
  bounding_box: False
  crop: False
  height: 300
  required_zones: []
  retain:
    default: 10
    objects:
      person: 15

detect:
  width: 1280
  height: 720
  fps: 5
  enabled: True
  # Optional: Number of frames without a detection before frigate considers an object to be gone. (default: 5x the frame rate)
  max_disappeared: 25

motion:
  # Optional: The threshold passed to cv2.threshold to determine if a pixel is different enough to be counted as motion. (default: shown below)
  # Increasing this value will make motion detection less sensitive and decreasing it will make motion detection more sensitive.
  # The value should be between 1 and 255.
  threshold: 25
  # Optional: Minimum size in pixels in the resized motion image that counts as motion (default: ~0.17% of the motion frame area)
  # Increasing this value will prevent smaller areas of motion from being detected. Decreasing will make motion detection more sensitive to smaller
  # moving objects.
  contour_area: 100
  # Optional: Alpha value passed to cv2.accumulateWeighted when averaging the motion delta across multiple frames (default: shown below)
  # Higher values mean the current frame impacts the delta a lot, and a single raindrop may register as motion.
  # Too low and a fast moving person wont be detected as motion.
  delta_alpha: 0.2
  # Optional: Alpha value passed to cv2.accumulateWeighted when averaging frames to determine the background (default: shown below)
  # Higher values mean the current frame impacts the average a lot, and a new object will be averaged into the background faster.
  # Low values will cause things like moving shadows to be detected as motion for longer.
  # https://www.geeksforgeeks.org/background-subtraction-in-an-image-using-concept-of-running-average/
  frame_alpha: 0.2
  # Optional: Height of the resized motion frame  (default: 1/6th of the original frame height, but no less than 180)
  # This operates as an efficient blur alternative. Higher values will result in more granular motion detection at the expense of higher CPU usage.
  # Lower values result in less CPU, but small changes may not register as motion.
  frame_height: 180
  # Optional: motion mask
  # NOTE: see docs for more detailed info on creating masks
  # mask: 0,900,1080,900,1080,1920,0,1920