In this guide, we’ll be taking our Home Assistant Frigate install to the next level with advanced object detection. We will be playing around with Masks and Zones, configuring Frigate to detect specific objects (such as dogs or vehicles), and enabling the snapshots and clips feature to save locally or to a network share.
Let’s get started!
This is Part 2 of a 3 part guide.
Frigate Install Series:
In Part 1, I’ve shown you how to:
- Install Frigate within Home Assistant
- Install the Frigate Home Assistant integration via HACS
- Add your first camera to Frigate
- Create a Lovelace card to display your camera
In Part 2 (this guide), I’ll show you how to:
- Add your first object detection
- Configure detection zones
- Create masks
- Advanced object detection (such as vehicles, dogs, or bicycles)
In Part 3 (postponed), I’ll show you how to:
- Create a basic notification when an object is detected
- Create an actionable notification that shows a screenshot
- In the meantime, you can use this Frigate Notification blueprint
Before following this guide, make sure you have followed Part 1: Setting up Frigate in Home Assistant first. We will be editing and adding to the existing configuration file we created in Part 1.
What cameras am I using?
As I mentioned in Part 1, the cameras you choose must support RTSP (real time streaming protocol). I’ve been very happy with Amcrest RTSP camers so far and highly recommend them.
For indoor cameras, I’m using the Amcrest ProHD IP2M-841B:
- HIGH PERFORMANCE, REAL-TIME, TRUE HD – Experience magnificent full-HD 1080P video at 30fps with enhanced low light capability utilizing the image sensor and Ambarella chipset. Extra-wide 90°...
- SMARTER SECURITY – Receive motion alert notifications, review footage and engage in two-way communication via your smartphone with the Amcrest View app. Playback and record professionally on a PC...
For outdoor cameras, I’m using the Amcrest IP5M-T1179EW-28MM:
- CMOS ILLUMINATION & MIC – Stunning low-light 5MP performance with CMOS 1/2.7” image sensor and 5MP resolution (2592x1944). Super-wide 103° viewing angle allows you to cover more ground. Power...
- SMARTER SECURITY & STORAGE OPTIONS – Receive motion alert notifications and review footage via your smartphone with the Amcrest View app. Playback and record professionally on a PC using the Amcrest...
Understanding Masks and Zones
I won’t go into this section in too much detail, as the Frigate documentation does a great job explaining it in detail. I’m personally not using zones or masks yet. If you’d like to configure masks or zones, you can do so by clicking the Frigate NVR integration in your sidebar, clicking a camera, and then choosing Show Options or Hide Options.
Masks should be used to “ignore” certain detection zones from your cameras point of view. For example, if you have a busy sidewalk in the front of your house and don’t want to record snapshots of passerby’s.
Zones allow you to define an area of a frame and apply additional object type filters so you can determine whether or not an object is detected within that zone. An example use case of zones might be detecting if a certain vehicle is detected in your driveway. Zones allow you to create some really automations, such as if a person object is detected at night, you could turn on your exterior lights or send you a notification.
Step 1: Adding more detection objects
This next section will allow you track specific objects in Frigate, such as dogs, vehicles, bicyles, and much more. A full list of available detection objects can be found here.
File Editor > frigate.yml. For this example, I want to detect person, dogs, and cell phones. Add the following code under your
- cell phone
Then go Supervisor > Frigate NVR > Restart. No need to restart Home Assistant. You should always check the Log tab after every restart in case you have a syntax error. (If Frigate doesn’t load after making a change, you probably make a syntax or indentation error!)
Go back into Frigate NVR, click a camera, make sure “Bounding Boxes” is checked, and you should now see that is tracking PERSON, DOG, and CELL PHONE.
If your tracked objects only shows black thumbnails, that’s because it hasn’t yet tracked that object. After you let it detect a cellphone and a person, refresh the frigate page you’re on and it’ll show up correctly.
So far so good! You’ve now confirmed it tracks objects correctly. However, if you click the Events section, you’ll notice it’s not showing any events yet. This is because we haven’t configured it to capture screenshots or recording yet.
Step 2: Enable Frigate Snapshots
Go back to File Editor > frigate.yml.
In our current config, we have it set to just detect. There are 4 available roles: detect, clip, record, and rtmp. You can use all 4 if you’d like, or mix and match. For this example, I’m just adding clips which will save snapshots and recording clips.
- detect: Detect and track objects
- clip: Save motion clips (either to Home Assistant or any storage medium you choose)
- See Step 88888 for saving to network share
- record: Continuous recording
- rtmp: Rebroadcast RTSP stream, instead of opening a new stream from Frigate
In your frigate.yml file, edit your config to match mine. I am adding the clips role, enabling snapshots, disabling the timestamp, and retaining clips for 3 days. You can also retain clips on a per object basis, so for example if you want to retain clips of persons for 7 days but dogs for 2, you can do that by reading over the Frigate documentation.
After saving, go back to Supervisor > Frigate NVR > Restart.
Snapshots will now be on by default:
Wait a few moments and then click Events. You show now see that Frigate has started capturing events, along with the timestamp, detection score, and the object label it detected.
If you click the thumbnail of the one of the images, you can get some more info if you’d like. You will notice that it says “No clip available”, which means there is no recording of the event yet, just a snapshot. This is because we haven’t turned on recording clips just yet.
Step 3: Enable Recording Clips
Head over to your frigate.yml file once again. Then, we’re going to add a few more lines of code. This time, we’re only going to retain clips for 1 day. Again, you can customize recording on a per-object basis if you’d like.
Save it once again, and then go back to Supervisor > Frigate NVR > Restart.
Frigate will show show that it’s recording clips:
Click the camera again. Now, walk in front of your camera or move a detected object in front of it. Wait a minute for the new events to process, and then click Events. This time when you click the thumbnail, it should show a video clip.
Awesome! So, now you can view snapshots and recording clips from Frigate NVR. That’s great, but I also wanted to let you know that you can view these from the Media Browser.
Step 4: View Snapshots and Recording from Media Browser
In your Home Assistant sidebar, click Media Browser.
You’ll see that a new Frigate folder has been created.
Remember, we only turned on “Clips” and not continuous recording, so your recording clips will be under Clips and nothing should be under Recordings.
Step 5: Review Home Assistant Frigate integration
Go to Configuration > Integrations. You’ll notice that Frigate probably hasn’t updated the number of new entities. There should be a bunch more now that you’ve got enabled snapshots and clips.
To update, click the 3 dots and then click Reload.
Click on 1 device, and you should see a few entities created, such as the cell phone, person, and dog.
Example Frigate.yml configuration
Here’s the code I’m using in my frigate.yml file. You are welcome to copy and paste this in, enter your own MQTT credentials and RTSP URL, and change up the detected objects and retain length.
- path: rtsp://admin:firstname.lastname@example.org:554
- cell phone
Now, we are one step closer to a fully automated local NVR setup within Home Assistant! The remaining step is to configure notifications which will be covered in Part 3.
Stay tuned for Part 3!
My Favorite Home Assistant Devices
Below are some of the Home Assistant-compatible devices I personally use in my home. I highly recommend each of them.
- Zwave/Zigbee hub: Nortek GoControl HUSBZB-1
- Smart Plugs: Sonoff S31 Lite Zigbee
- Motion Sensors: Hue Indoor Motion
- Outdoor Camera: Amcrest IP5M Turret
- Robot Vacuum: Roborock S7
The full list of all Home Assistant compatible & recommended devices I use can be found on my Equipment List page.