AI-powered trash can detection system

March 5, 2025

Table of Contents

Notification sent by Home Assistant companion app.

Notification sent by Home Assistant.

Forgetting to take out the trash can be frustrating, and I do it a lot. To solve this problem, I built a reminder system using Home assistant and Node-RED to alert me on my phone, computers, TV, and smart speakers. This worked great IF I remembered to turn off the “put out trash today” switch…I didn’t.

So, I created an locally-hosted AI-powered solution using YOLO object detection, with a model specifically trained to recognize my trash cans. Now, the system automatically stops the reminders once I’ve put the trash out!

Alt text

Tech Stack

Machine Learning Approach

I leveraged YOLO, a real-time object detection algorithm, to train a model specifically designed to detect my trash cans. The process involved:

Integration with Home Automation

After training the model and ensuring its accuracy, I integrated it into my home automation setup using Node-RED:

Image of 'Trash cans out back' input boolean in Home Assistant.

Image of ‘Trash cans out back’ input boolean in Home Assistant.

Trash can detection logic

Four cameras in two locations are checked for trash cans: two in front (front door and front yard) and two in the backyard (driveway and back door). This lets me know with reasonable certainty whether the trash cans are in the front or back yard. The selected cameras also reduce the likelihood of a neighbor’s trash cans being detected.

Image of Node-RED logic flow for trash can detection

  1. Node-RED listens to the MQTT topic camera/+/event for an image_downloaded event
  2. The image size is compared to the known size of a full notification image and only proceeds if it is
    • This prevents cropped images (such as would occur with a person detection event on the camera) from being processed for trash cans, as they often are cropped out
  3. The image is sent to a locally-run YOLO service using a model custom-trained on my particular trash cans
  4. The number of trash cans detected is counted and if > 1, the trash cans are assumed to be in the same location as the camera image being processed
  5. If the trash cans were NOT detected, only update the trash cans’ location between 5AM and 11PM
    • This prevents false negatives from causing my reminders to prematurely be disabled when a dark camera image causes the system to think the trash cans are no longer out back

“Put out trash” reminder logic

Image of Node-RED logic flow for turning on/off ‘Put out trash’ boolean

  1. If a “Put out trash” event is in the “Household Tasks” calendar in Home Assistant, a “Put out trash” input boolean is turned on
  2. If trash cans are NOT detected out back and trash is scheduled to be put out today, it’s assumed the trash has been put out, so “Put out trash” is turned off
  3. If trash cans ARE detected out back and trash is scheduled to be put out today, the “Put out trash” boolean is turned on
    • This is a fail-safe in the off-chance that a false negative causes the system to think trash had been put out prematurely
  4. At 9am, 12pm, 5pm, and 7pm if “Put out trash” boolean is on, reminders are sent in the form of notifications and spoken announcements on smart speakers in occupied rooms. If “Put out trash” is off, the reminders are skipped.

Image of Node-RED logic flow for sending reminders

Results and Impact

This system has significantly improved the reliability of my trash reminders and reduced notification fatigue. And I no longer have to remember to mark the trash cans as being put out, which saves me from being reminded when it isn’t necessary. The project demonstrates a practical application of machine learning and automation to solve everyday challenges efficiently.

Future improvements

Conclusion

This project showcases how AI and automation can be combined to create smart, practical solutions. By leveraging YOLO’s real-time object detection, I developed a system that reduces forgetfulness and enhances household efficiency. It’s a great example of applying machine learning to everyday life in a meaningful way.