Pluggable async home security camera pipeline with detection, VLM analysis, and alerts.
Project description
HomeSec
HomeSec is a self-hosted, extensible network video recorder that puts you in control. Store clips wherever you want, analyze them with AI, and get smart notifications—all while keeping your footage private and off third-party clouds.
Under the hood, it's a pluggable async pipeline for home security cameras. It records short clips, runs object detection, optionally calls a vision-language model (VLM) for a structured summary, and sends alerts via MQTT or email. The design prioritizes reliability and extensibility.
Table of Contents
- Highlights
- Pipeline at a glance
- Quickstart
- Configuration
- Extensible by design
- CLI
- Built-in plugins
- Writing a plugin
- Observability
- Development
- Contributing
- License
Highlights
- Multiple pluggable video clip sources: RTSP motion detection, FTP uploads, or a watched folder
- Parallel upload + filter (YOLOv8) with frame sampling and early exit
- OpenAI-compatible VLM analysis with structured output
- Policy-driven alerts with per-camera overrides
- Fan-out notifiers (MQTT for Home Assistant, SendGrid email)
- Postgres-backed state + events with graceful degradation
- Built around small, stable interfaces so new plugins drop in cleanly
- Health endpoint plus optional Postgres telemetry logging
Pipeline at a glance
ClipSource -> (Upload + Filter) -> VLM (optional) -> Alert Policy -> Notifier(s)
- Upload and filter run in parallel; VLM runs only when trigger classes are detected.
- Upload failures do not block alerts; filter failures stop processing.
- State is stored in Postgres (
clip_states+clip_events) when available.
Quickstart
Requirements
- Raspberry Pi 4 (or equivalent) or higher; any x86_64 system works as well
- Docker and Docker Compose
- Optional: MQTT broker, Dropbox credentials, OpenAI-compatible API key
Setup
- Create a config file:
cp config/example.yaml config/config.yaml # Edit config/config.yaml with your settings
- Set environment variables:
cp .env.example .env # Edit .env with your credentials
- Start HomeSec + Postgres:
make up - Stop:
make down
Running without Docker
If you prefer to run locally:
- Install Python 3.10+ and ffmpeg
uv syncmake db(starts Postgres)make run
Configuration
Configs are YAML and validated with Pydantic. See config/example.yaml for all options.
Minimal example (RTSP + Dropbox + MQTT):
version: 1
cameras:
- name: front_door
source:
type: rtsp
config:
rtsp_url_env: FRONT_DOOR_RTSP_URL
output_dir: "./recordings"
storage:
backend: dropbox
dropbox:
root: "/homecam"
token_env: DROPBOX_TOKEN
app_key_env: DROPBOX_APP_KEY
app_secret_env: DROPBOX_APP_SECRET
refresh_token_env: DROPBOX_REFRESH_TOKEN
state_store:
dsn_env: DB_DSN
notifiers:
- backend: mqtt
config:
host: "localhost"
port: 1883
filter:
plugin: yolo
config:
classes: ["person"]
min_confidence: 0.5
vlm:
backend: openai
llm:
api_key_env: OPENAI_API_KEY
model: gpt-4o
alert_policy:
backend: default
enabled: true
config:
min_risk_level: medium
per_camera_alert:
front_door:
min_risk_level: low
notify_on_activity_types: ["person_at_door", "delivery"]
A few things worth knowing:
- Secrets never go in YAML. Use env var names (
*_env) and set values in your shell or.env. - At least one notifier must be enabled (
mqttorsendgrid_email). - Built-in YOLO classes:
person,car,truck,motorcycle,bicycle,dog,cat,bird,backpack,handbag,suitcase. - Local storage for development:
storage:
backend: local
local:
root: "./storage"
- Set
alert_policy.enabled: falseto disable notifications (a noop policy is used). - For a quick local run, pair
local_folderwithlocalstorage and drop a clip intorecordings/.
Extensible by design
HomeSec is intentionally modular. Each major capability is an interface
(ClipSource, StorageBackend, ObjectFilter, VLMAnalyzer, AlertPolicy,
Notifier) defined in src/homesec/interfaces.py, and plugins are discovered at
runtime via entry points. This keeps the core pipeline small while making it
easy to add new backends without editing core code.
What this means in practice:
- Swap storage or notifications by changing config, not code.
- Add a new plugin type as a separate package and register it.
- Keep config validation strict by pairing each plugin with a Pydantic model.
Extension points (all pluggable):
- Sources: RTSP motion detection, FTP uploads, local folders
- Storage backends: Dropbox, local disk, or your own
- Filters: object detection (YOLO or custom models)
- VLM analyzers: OpenAI-compatible APIs or local models
- Alert policies: per-camera rules and thresholds
- Notifiers: MQTT, email, or anything else you can send from Python
CLI
- Run the pipeline:
uv run python -m homesec.cli run --config config/config.yaml --log_level INFO - Validate config:
uv run python -m homesec.cli validate --config config/config.yaml - Cleanup (reanalyze and optionally delete empty clips):
uv run python -m homesec.cli cleanup --config config/config.yaml --older_than_days 7 --dry_run True
Built-in plugins
- Filters:
yolo - VLM analyzers:
openai(OpenAI-compatible API) - Storage:
dropbox,local - Notifiers:
mqtt,sendgrid_email - Alert policies:
default,noop
Writing a plugin
HomeSec discovers plugins via entry points in the homesec.plugins group. A plugin
module just needs to import and register itself.
Each plugin provides:
- A unique name (used in config)
- A Pydantic config model for validation
- A factory that builds the concrete implementation
# my_package/filters/custom.py
from pydantic import BaseModel
from homesec.interfaces import ObjectFilter
from homesec.plugins.filters import FilterPlugin, filter_plugin
class CustomConfig(BaseModel):
threshold: float = 0.5
class CustomFilter(ObjectFilter):
...
@filter_plugin(name="custom")
def register() -> FilterPlugin:
return FilterPlugin(
name="custom",
config_model=CustomConfig,
factory=lambda cfg: CustomFilter(cfg),
)
# pyproject.toml
[project.entry-points."homesec.plugins"]
my_filters = "my_package.filters.custom"
Observability
- Health endpoint:
GET /health(configurable inhealth.host/health.port) - Optional telemetry logs to Postgres when
DB_DSNis set:- Start local DB:
make db - Run migrations:
make db-migrate
- Start local DB:
Development
- Run tests:
make test - Run type checking (strict):
make typecheck - Run both:
make check - Tests must include Given/When/Then comments.
- Architecture notes:
DESIGN.md
Contributing
Contributions are welcome! Here's how to get started:
- Fork and clone the repository
- Create a branch for your feature or fix:
git checkout -b my-feature - Install dependencies:
uv sync - Make your changes and ensure tests pass:
make check - Submit a pull request with a clear description of your changes
Guidelines
- All code must pass CI checks:
make check - Tests should include Given/When/Then comments explaining the test scenario
- New plugins should follow the existing patterns in
src/homesec/plugins/ - Keep PRs focused on a single change for easier review
Reporting Issues
Found a bug or have a feature request? Please open an issue with:
- A clear description of the problem or suggestion
- Steps to reproduce (for bugs)
- Your environment (OS, Python version, HomeSec version)
License
Apache 2.0. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file homesec-1.1.1.tar.gz.
File metadata
- Download URL: homesec-1.1.1.tar.gz
- Upload date:
- Size: 418.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf58035b7cacc3ab423e118028cb124e83ea352286ae0be8e110244331f7f4f6
|
|
| MD5 |
1d7a5d6d3e00079fc14c216a078b1fca
|
|
| BLAKE2b-256 |
50d638925f47e355de2c8df24acdb73f4c89512904132c59d32da9454496bece
|
Provenance
The following attestation bundles were made for homesec-1.1.1.tar.gz:
Publisher:
release.yaml on lan17/homesec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
homesec-1.1.1.tar.gz -
Subject digest:
bf58035b7cacc3ab423e118028cb124e83ea352286ae0be8e110244331f7f4f6 - Sigstore transparency entry: 830288512
- Sigstore integration time:
-
Permalink:
lan17/homesec@4c8342f71274f2110231f112b77d68c8bb119c17 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lan17
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@4c8342f71274f2110231f112b77d68c8bb119c17 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file homesec-1.1.1-py3-none-any.whl.
File metadata
- Download URL: homesec-1.1.1-py3-none-any.whl
- Upload date:
- Size: 107.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bcdd5ac34aa3bdffc85e22e0db933b124d6f11b4d0ab374ceb044dbd87b4e20
|
|
| MD5 |
41d47b74c88eebb9ed1d46e0a6b83b0b
|
|
| BLAKE2b-256 |
f46050cb2fea7a168e61da26e0539f052ed86966640fe215a8622fdd33e5268c
|
Provenance
The following attestation bundles were made for homesec-1.1.1-py3-none-any.whl:
Publisher:
release.yaml on lan17/homesec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
homesec-1.1.1-py3-none-any.whl -
Subject digest:
2bcdd5ac34aa3bdffc85e22e0db933b124d6f11b4d0ab374ceb044dbd87b4e20 - Sigstore transparency entry: 830288536
- Sigstore integration time:
-
Permalink:
lan17/homesec@4c8342f71274f2110231f112b77d68c8bb119c17 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lan17
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@4c8342f71274f2110231f112b77d68c8bb119c17 -
Trigger Event:
workflow_dispatch
-
Statement type: