This project is to detect which cars are in my garage as well as if the garbage bins are present. I use a simple object detection model along with an IP Camera in my garage. I publish the state as bianry sensors for use in HomeAssistant. The images used for training are here: https://app.roboflow.com/egge-public/garage/overview
The script uses a rolling average to determine if the object is present or absent, and also skips updating if it detects a person, as they may be obscuring something. I also trained it to recongize my toolbucket. This is a sort of sanity / calibration check. If it finds nothing in the scene, it's likely a system problem, so it shouldn't update the state of the objects.
Quick Start
You need to create a config file which connects to the camera and MQTT broker.
[file]
# where to save the images
path=/mnt/capture
[camera]
user=admin
password=*****
host=garage-cam.home
[mqtt]
host=mqtt
port=1883podman run -it --rm -v etc/config.ini:/app/config.ini brianegge/garbage_binInstall service from source
$ cat /etc/systemd/system/garbage_bin_detector.service
[Unit]
Description=Image processor to find the garbage bin
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=egge
WorkingDirectory=/home/egge/garbage_bin/flask
ExecStart=/home/egge/garbage_bin/flask/simple.py
[Install]
WantedBy=multi-user.targetInstall service via podman
cp podman-systemd.service ~/.config/systemd/user/container-garbage_bin.service
systemctl --user daemon-reload
systemctl --user enable container-garbage_bin.service
systemctl --user start container-garbage_bin.service
systemctl --user enable podman-auto-update.service
systemctl --user start podman-auto-update.serviceHere is one of my automations, which closes my garage door after I leave:
alias: Garage Close Civic departs
description: "Close left garage door after departure "
trigger:
- platform: state
entity_id:
- person.brian
to: not_home
from: home
condition:
- condition: state
entity_id: binary_sensor.honda_civic
state: "off"
- condition: state
entity_id: cover.garage_door_left
state: open
action:
- service: cover.close_cover
target:
entity_id:
- cover.garage_door_left
data: {}
- wait_for_trigger:
- platform: state
entity_id:
- cover.garage_door_left
to: closed
timeout: "60"
- service: notify.mobile_app_brians_iphone_x
data:
message: Garage door left is {{ states('cover.garage_door_left') }}
data:
entity_id: camera.garage_cam
url: /lovelace-mobile/garage/
mode: singleThe arriving home automations are a bit more complicated, because I might be driving either car. If both cars are away, I'm driving the Civic. If the Civic is present, I'm driving the CRV.
