I recently found an article where someone built an AI bird feeder from scratch including the 3D printed parts for the feeder itself. After taking a look at this, I wanted to do something similar while also integrating Home Assistant. There are a few moving parts to this and a several different options for each step, so I'm going to go over what I specifically did here. When there is a different option to take, I will also try and note it down. Because there are a lot of moving parts here, I am going to reference a lot of the different videos/instructions that I used while noting important configuration changes needed as well as tips that I found throughout the project.
It is also worth noting that if you want out of the box functionality for something similar, there is the Bird Buddy kickstarter that has recently started shipping. I don't know the details of quality, but there is a BirdBuddy subreddit for discussions. On Amazon, there are knockoffs like this one that I actually bought as a gift for someone and it work pretty well. The big advantage here is that these have the options of using solar, so there are no messy wires. The disadvantage is that these are more expensive and the AI is spotty at best. The AI is also a manual process which you have to click on when you are in the app after a bird notification comes in. The AI then runs and you have to hope the bird stays there as it's running. With our project, we have snapshots/recordings as well as a database of all of the bird species historically. Lastly, if you don't care about AI recognition and just want a wireless camera on a bird feeder, check out this case that we will be using for this project anyways and then you can put something like a Blink or Wyze camera in it. Just note that without installing a focus ring, the quality may not be great out of the box as mentioned below.
Plan Overview:
To summarize what we will be doing and to provide a TL;DR for those who just want to know the high level plan, here is what it looks like:
Set up the Wyze v3 camera (create a Wyze account, connect it to Wi-Fi, etc)
Optional but recommended: Install a focus ring in the camera to change the focal length
Install the Wyze camera into the Wasserstein bird feeder.
Power the camera with the outdoor power cable (solar/batteries won't work due to the constant RTSP stream being required)
Set up wyze-bridge in an docker container or HASS addon to have the camera provide an RTSP stream.
Set up Frigate as a docker container or HASS addon and feed the RTSP stream from wyze-bridge into Frigate.
Install the Frigate Home Assistant Integration so that objects that the Frigate addon finds can be actioned upon in Home Assistant.
Set up WhosAtMyFeeder as a docker container or a HASS addon to talk with Frigate to determine the species of the bird object that Frigate is finding.
Configure Home Assistant notifications e.g. send a notification to my phone with a picture when a bird is at the feeder.
Requirements / Items Needed:
Software:
Home Assistant (with MQQT Installed)
All of the apps below can run as addons in Home Assistant. Alternatively you can run them as standalone docker containers. Personally I am using a mix of both, with Wyze-Bridge being run in a docker container and the other two being Home Assistant addons.
WhosAtMyFeeder - A sidecar app for Frigate to identify species of birds
Wyze-Bridge - A method to get an RTSP stream from the Wyze camera to Frigate
Frigate - AI NVR Software
Hardware:
Wyze Cam v3 ($35)
Bird Seed ($12)
Set up the Wyze camera:
If you just purchased a Wyze camera, make sure to set it up as you normally would. Get it on WiFi (2.4 GHz only), create a Wyze account, name it, etc. I named mine Bird Cam.
Optional/Recommended: Install focus ring:
* This will void your warranty and make the camera less weatherproof *
By default, the Wyze camera has a wide focus view with a focal length well past the ~6" of what we are looking for (details). In order to get around this, we will need to take the camera apart and install a focus ring. You can 3D print the focus ring from here which is what I did, or you can buy a similar one on Etsy here. The video I followed to take apart the camera is available here. To see the difference the focus ring makes, I'm putting two comparison videos below. One is with the default camera and the other is after installing the focus ring and being able to adjust it. While the AI seems to work regardless, the difference in picture is very apparent and worth the mod in my opinion. All in all it wasn't too bad taking the camera apart, but make sure you have a #0 phillips screwdriver or else it may not fit in the small holes for the cameras recessed screws. I also picked up some silicone to seal things up a bit better although I'm not sure how necessary this is, especially when most of the camera is enclosed by the feeder.
Here is an example video of a Sparrow eating at the feeder with the default camera. Notice that the camera doesn't do great with objects that are really close to it by default:
Here is an example video after taking the camera apart and adjusting the focus ring. The birds are no longer blurry as the camera focus is set to be right in front of the camera versus the default:
Setup Wyze-Bridge:
Wyze has a complicated history with offering RTSP in their cameras. Apparently they used to have it as a feature and eventually gave up on it. For this project we need an a stream to feed into Frigate for the AI to work. This is unfortunately also why we need constant power and why batteries/solar won't work for the camera. There are a few ways of getting an RTSP stream from the Wyze camera (and this Reddit post also goes over them):
Wyze Docker Bridge - This is what we will be using
Deprecated Wyze V3 RTSP Firmware (not recommended)
As mentioned above, all of these docker containers also have a Home Assistant option. For the wyze-bridge specifically, I am using a docker container on a Ubuntu VM in my ESXi host which works perfectly well for me. Per the project GitHub instructions, there really isn't much to set up. Simply make sure you have docker Compose installed, use the sample file to create your own docker-compose.yml file in a folder in your machine, and then run "docker-compose up". One thing to note is that you must enter in the "WYZE_EMAIL" and "WYZE_PASSWORD" field in the docker-compose.yml file that you are creating.
Once the container is running, you can access the webserver for the container at http://IPOFSERVER:5000. From there, you will see your Wyze camera and an option for RTSP. Right click and copy that link, and note is down as you will need it for the next step in setting up Frigate. The RTSP link should look something like: rtsp://IPOFSERVER:8554/birdcam
Frigate NVR:
I would like to point out here that Everything Smart Home has a fantastic video on the setup of Frigate in Home Assistant. Rather than write out everything he is saying in this article, I highly recommend following his video (and subscribing to his channel) for the setup of Frigate in Home Assistant. I will point out a few things to know while following along this video though.
As previously mentioned above, Frigate can also be set up as a standalone system rather than being used in Home Assistant. For a standalone system they recommend a physical Debian box (more details here) and not using Windows or a VM in something like ESXi or Proxmox. I ended up using Frigate as an addon in Home Assistant which is essentially a container in my Home Assistant VM on ESXi. Many articles mention performance concerns - especially without a Coral Accelerator - but for a single 1080p camera, I have found that just using my CPU works fine. I am currently getting ~140ms detection times which is completely fine for me in this application. If you are like me and have an ESXi host and were dissuaded by setting up Frigate on a standalone VM due to their documentation noting that it can be a problem and that Coral has issues with this setup, there is an article that seems to show how to set up the Coral Accelerator within an ESXi VM and have it work well. This is available here.
Another thing to mention is that since Home Assistant version 6 you can utilize network storage. I have setup an SMB share from Home Assistant to my file server so that the Frigate media can be stored there rather than on the disk of the Home Assistant VM. More info on that here.
The last thing to mention here is that, in Frigate, the only object we care about is the "bird" object. The video discusses how to add objects for snapshots and "clips" (which you should replace with "recordings" in the Frigate config now). Make sure that you also have the Home Assistant addon as well as the Home Assistant integration set up for Frigate.
Below is my Frigate configuration for reference. There is also the official configuration example with tons of information for reference available here as well. Of course, do not directly copy either of these configs, or if you do, make sure you go through each line to ensure you are placing your proper IPs and other configuration items correctly in the various bolded rows. The "retain" section is how long you want to save the pics/vids you capture before it removes it.
mqtt:
host: HA_IP_Here
user: mqqt_user_here
password: mqqt_pass_here
cameras:
bird_cam:
ffmpeg:
inputs:
- path: rtsp://BIRDIPCAMHERE:8554/birdcam
roles:
- detect
- record
detect:
enabled: True
width: 1920 # <---- update for your camera's resolution
height: 1080 # <---- update for your camera's resolution
fps: 5 # Leave this alone
objects:
track:
- bird
filters:
bird:
threshold: 0.8
snapshots:
enabled: True
timestamp: True
bounding_box: False
retain:
default: 30
record:
enabled: True
events:
pre_capture: 5
post_capture: 5
retain:
default: 30
detectors:
cpu1:
type: cpu
cpu2:
type: cpu
database:
path: /config/frigate.db
Who'sAtMyFeeder:
At this point you should have Frigate set up in Home Assistant with an RTSP feed streaming to it from wyze-bridge. Now that this is set up, we need to install the "sidecar app" WhosAtMyFeeder (link) which uses the bird species classifier model available on TensorFlow Hub which is linked in the projects GitHub. There are two ways to do this, either through the Home Assistant add on (Home Assistant > Settings > Add-ons > Add-on Store > 3 dots on upper right > Custom Repositories > Add > https://github.com/bertybuttface/addons) or through a standalone docker container. The instructions on the GitHub for the latter are pretty self explanatory, so feel free to follow the "Docker Config" instructions there if going that route. Two things to note: 1) Per the GitHub, change the configuration files that you will be copying accordingly. For instance, in the config.yml file, you will need to change the "frigate_url" field to your Home Assistant IP as well as the "mqqt_server" IP, which may also be your Home Assistant IP. Of course, make sure that the camera name is correct too (e.g. "bird_cam").
2) If using the Home Assistant Frigate add on, you need to make sure port 5000 is exposed since it is not by default. To do this, go to the addon configuration tab and then hit "Show disabled ports". Make sure under "Web Interface" you put 5000.
When it is working, the WhosAtMyFeeder dashboard can be accessed via Home Assistant or http://HOMEASSISTANTIP:5000 and should look something like this:
What may be more helpful though is going into "Frigate" -> "Events" and then looking at the "Sub Labels" dropdown which will have all identified species. This way you can filter out which species you want to look at. In my experience, the AI is pretty accurate, but occasionally I will get incorrect identifications which I usually just delete here:
Home Assistant:
The Frigate documentation has examples for Home Assistant notifications that you can check out here. They recommend using MQQT and it's probably a better solution than what I am using. When I was setting this up initially I didn't read in to this part and created my own notifications. These notifications are very similar to what I use for other camera notifications around my house and work well for me. Below is the YAML for my notification and below that are screenshots of how it looks on my phone.
alias: "When Bird Cam detects a bird via Frigate, notify Ryan"
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.bird_cam_bird_occupancy
to: "on"
condition: []
action:
- service: camera.snapshot
data:
filename: /media/bird_cam.jpg
target:
entity_id: camera.bird_cam
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: notify.mobile_app_s22_plus
data:
message: A bird is at your feeder
data:
image: /media/local/bird_cam.jpg
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
mode: single
Hardware Setup:
Having completed everything on the software side, all that is left is to install the hardware. Simply insert the camera into the bird feeder per the instructions that came with it, and mount the feeder however you choose. If you have squirrels, you may want to consider something like a squirrel baffle to prevent them from climbing up the pole. Keep in mine they can jump up to 5' high and about 8' across from a tree. I've also heard that sprinkling red pepper flakes on the food won't affect the birds but the squirrels will not eat it. I'm not sure how long this lasts though especially after some rain.
This is my very temporary setup as I get materials ready to put a wooden post in the ground and run wire to the post for an outlet (and potentially an ethernet cord for PoE):
And that's it! It is worth keeping in mind that some of these projects - and especially the addons - at the time of writing are fairly new and will have some minor bugs or an interface that may need prettying up. If you do run into any bugs, please do report them to the appropriate GitHub projects and support them if you are able to.
I appreciate you checking out the article and I hope it was helpful. If you have any questions, feel free to let me know down below!
コメント