Frigate Notifications for Home Assistant

Posted on 2024-1-26

Background

We use some neat software called Frigate to manage our home's security cameras and recordings. It runs bare metal on a Debian box, utilizing a CPU with video encoding as well as a TPU for AI person detection. It has been working pretty well, and is nice because we can basically buy IP cameras from anywhere, and provided they can spit out an RTSP stream, have them up and running in one place.

Recently, we have been trying to move away from paid (and some unpaid) cloud based services. These are convenient but we want to try and keep our data inside the walls of the house as much as possible. We currently rely on a cloud service and some proprietary cameras for notifications regarding occupancy around the exterior of our home. I wanted to move this "inside" and utilize Home Assistant to send us these notifications. (Yes I am aware iOS / Android notifications are a cloud service. Can't win em all.)

Methods

There are a few established ways to do this. There is an execlent Home Assistant blueprint for Frigate notifications. I tried it and was able to get it to work, but it would seemingly stop working at random, and Home assistant was giving me issues when trying to view snapshots / clips from these notifications. I'm sure this is an issue with my spaghetti-laden house of cards setup, but I still wanted to see if I could get reliable notifications with an alternative.

I found Another good solution in a github discussion that achieves frigate notifications without any blueprints. Many people seem to be using this with success, but I wanted to see if I could just create an automation myself that handled this properly.

The Solution

What I found after reading through Home Assistant's documentation was the ability to retrieve images from an MQTT topic. This seemed promising as frigate publishes snapshots to MQTT as raw jpeg data, which I already have configured and working.

a raw jpeg in an mqtt message

To get this into a notification we can use the data field in the notification action within an automation.

But before we build the automation, we need to add something to our main configuration, that takes the raw jpeg binary data from the mqtt message and then places it into a jpeg file that is accessible via URL. This is what I am using:

  mqtt:
  - image:
      name: front_driveway_snapshot
      image_topic: frigate/Front-Driveway/person/snapshot
      content_type: image/jpg

Once we have this in our main configuration, we can build the automation.

Here is what the finished notification looks like.

  alias: Frigate - Front Driveway

  description: "notification to phones when front driveway occupied"

  triggers:
    - type: occupied
      device_id: 00000000000000000000000000000000
      entity_id: 00000000000000000000000000000000
      domain: binary_sensor
      trigger: device
  conditions: []

  actions:
    - action: notify.mobile_app_phone1
      metadata: {}
      data:
        message: A person is in your front driveway.
        title: Hey!
        data:
          image: /api/image_proxy/image.front_driveway_snapshot
          url: https://frigate.example.com/#Front-Driveway

    - action: notify.mobile_app_phone2
      metadata: {}
      data:
        message: A person is in your front driveway.
        title: Hey!
        data:
          image: /api/image_proxy/image.front_driveway_snapshot
          url: https://frigate.example.com/#Front-Driveway

  mode: single

This example sends a notification to two phones when the front driveway becomes occupied. It seems to work well. You can force touch the notification and see the cropped snapshot with a bounding box around the detected person, and when clicked, it takes you directly to a live feed of the camera in question.

Hopefully this helps somebody who wants to achieve this without 100 lines of YAML or a blueprint, that could potentially suffer from breaking changes down the line. These are great solutions, but I wanted something super simplistic for someone like me who likes books with lots of pictures :)

← Back to Posts