HomeSec
HomeSec is a self-hosted, extensible video pipeline for home security cameras. You can connect cameras directly via RTSP, receive clips over FTP, or implement your own ClipSource. From there, the pipeline filters events with AI and sends smart notifications. Your footage stays private and off third-party clouds.
Design Principles
- Local-Only Data Processing: Video footage remains on the local network by default. Cloud usage (Storage, VLM/OpenAI) is strictly opt-in.
- Modular Architecture: All major components (sources, filters, analyzers, notifiers) are decoupled plugins defined by strict interfaces. If you want to use a different AI model or storage backend, you can swap it out with a few lines of Python.
- Resilience: The primary resilience feature is backing up clips to storage. The pipeline handles intermittent stream failures and network instability without crashing or stalling.
Pipeline at a glance
graph TD
%% Layout Wrapper for horizontal alignment
subgraph Wrapper [" "]
direction LR
style Wrapper fill:none,stroke:none
S[Clip Source]
subgraph Pipeline [Media Processing Pipeline]
direction TB
C(Clip File) --> U([Upload to Storage])
C --> F([Detect objects: YOLO])
F -->|Detected objects| AI{Trigger classes filter}
AI -->|Yes| V([VLM Analysis])
AI -->|No| D([Discard])
V -->|Risk level, detected objects| P{Alert Policy filter}
P -->|No| D
P -->|YES| N[Notifiers]
end
S -->|New Clip File| Pipeline
PG[(Postgres)]
Pipeline -.->|State & Events| PG
end
- Parallel Processing: Upload and filter run in parallel.
- Resilience: Upload failures do not block alerts; filter failures stop expensive VLM calls.
- State: Metadata is stored in Postgres (
clip_states+clip_events) for full observability.
Table of Contents
- Highlights
- Pipeline at a glance
- Quickstart
- Configuration
- Plugins
- Observability
- Development
- Contributing
- License
Highlights
- Multiple pluggable video clip sources: RTSP motion detection, FTP uploads, or a watched folder
- Parallel upload + filter (YOLO) 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
- Health endpoint plus optional Postgres telemetry logging
- Push-to-talk for RTSP cameras with ONVIF audio backchannel support and a local TP-Link Tapo talkback backend path
Quickstart
Docker
Use the included docker-compose.yml (HomeSec + Postgres, pulls leva/homesec:latest).
Configure your own config.yaml and .env files as described in Manual Setup.
Manual Setup
For standard production usage without Docker Compose:
-
Prerequisites:
- Python 3.10+
- ffmpeg
- PostgreSQL (running and accessible)
-
Install
pip install homesec
-
Configure
# Download example config & env curl -O https://raw.githubusercontent.com/lan17/homesec/main/config/example.yaml mv example.yaml config.yaml curl -O https://raw.githubusercontent.com/lan17/homesec/main/.env.example mv .env.example .env # Setup environment (DB_DSN is required) # Edit .env to set your secrets! export DB_DSN="postgresql://user:pass@localhost/homesec"
-
Run
homesec run --config config.yaml
Developer Setup
If you are contributing or running from source:
-
Install dependencies
uv sync -
Start Infrastructure
make db # Starts just Postgres in Docker
-
Run
uv run python -m homesec.cli run --config config/config.yaml
Configuration
Configuration is YAML-based and strictly validated. Secrets (API keys, passwords) should always be loaded from environment variables (_env suffix).
Configuration Examples
1. The "Power User" (Robust RTSP)
Best for real-world setups with flaky cameras.
cameras:
- name: driveway
source:
backend: rtsp
config:
rtsp_url_env: DRIVEWAY_RTSP_URL
output_dir: "./recordings"
stream:
# Critical for camera compatibility:
ffmpeg_flags: ["-rtsp_transport", "tcp", "-vsync", "0"]
reconnect:
backoff_s: 5
filter:
backend: yolo
config:
classes: ["person", "car"]
min_confidence: 0.6
In your .env:
DRIVEWAY_RTSP_URL="rtsp://user:pass@192.168.1.100:554/stream"
2. The "Cloud Storage" (Dropbox)
Uploads to Cloud but keeps analysis local.
storage:
backend: dropbox
config:
token_env: DROPBOX_TOKEN
root: "/SecurityCam"
notifiers:
- backend: sendgrid_email
config:
api_key_env: SENDGRID_API_KEY
to_emails: ["me@example.com"]
In your .env:
DROPBOX_TOKEN="sl.Al..."
SENDGRID_API_KEY="SG.xyz..."
See config/example.yaml for a complete reference of all options.
Tips
- Secrets: Never put secrets in YAML. Use env vars (
*_env) and set them in your shell or.env. - Notifiers: Notifiers are optional. With no enabled notifiers, alert decisions are still evaluated and recorded, but no external notifications are sent.
- YOLO Classes: Built-in classes include
person,car,truck,motorcycle,bicycle,dog,cat,bird,backpack,handbag,suitcase. - Preview storage:
preview.config.storage_diris scratch space for on-demand HLS live preview output from RTSP sources. Prefer tmpfs and keep it separate fromrecordings/and durable storage. Preview defaults torecording_policy: stop_on_recording;allow_during_recordingis best-effort and may consume an extra RTSP session. Seedocs/preview-deployment.md. - Push-to-talk: Browser microphone to camera speaker support is auto-probed for RTSP cameras by default. HomeSec tries standards-based backends first; the bundled ONVIF backend supports
PCMU/8000andPCMA/8000, and the bundledtapo_localbackend implements a local TP-Link Tapo talkback path without TP-Link cloud calls at runtime. Usecameras[].talk.backend: onvif_rtsp_backchannelorcameras[].talk.backend: tapo_localfor explicit selection. Tapo local talk defaults to usernameadmin, can derive host and password material from the RTSP URL, and can use explicit backend env vars when credentials differ. Opt out cameras withcameras[].talk.mode: disabledwhen needed. Physical Tapo C120 compatibility still needs per-firmware validation. Seedocs/push-to-talk.md.
After installation, the homesec command is available:
homesec --help
Commands
Run the pipeline:
homesec run --config config.yaml
Validate config:
homesec validate --config config.yaml
Cleanup old clips (reanalyze and optionally delete empty clips):
homesec cleanup --config config.yaml --older_than_days 7 --dry_run=False
Use homesec <command> --help for detailed options on each command.
Plugins
Extensible by design
We designed HomeSec to be modular. Each major capability is an interface (ClipSource, StorageBackend, ObjectFilter, VLMAnalyzer, AlertPolicy, Notifier) defined in src/homesec/interfaces.py. This means you can swap out components (like replacing YOLO with a different detector) without changing the core pipeline.
HomeSec uses a plugin architecture where every component is discovered at runtime via entry points.
Built-in plugins
| Type | Plugins |
|---|---|
| Sources | rtsp, ftp, local_folder |
| Filters | yolo |
| Storage | dropbox, local |
| VLM analyzers | openai |
| Notifiers | mqtt, sendgrid_email |
| Alert policies | default, noop |
Plugin interfaces
All interfaces are defined in src/homesec/interfaces.py.
| Type | Interface | Decorator |
|---|---|---|
| Sources | ClipSource |
@source_plugin |
| Filters | ObjectFilter |
@filter_plugin |
| Storage | StorageBackend |
@storage_plugin |
| VLM analyzers | VLMAnalyzer |
@vlm_plugin |
| Notifiers | Notifier |
@notifier_plugin |
| Alert policies | AlertPolicy |
@alert_policy_plugin |
Writing a custom plugin
Extending HomeSec is designed to be easy. You can write custom sources, filters, storage backends, and more.
👉 See PLUGIN_DEVELOPMENT.md for a complete guide.
Observability
- Health endpoint:
GET /health(served by FastAPI onserver.host/server.port) - Telemetry logs to Postgres when
DB_DSNis set
Development
Setup
- Clone the repository
- Install uv for dependency management
uv syncto install dependenciesmake dbto start Postgres locally
Commands
- Run tests:
make test - Run type checking (strict):
make typecheck - Run both:
make check - Run the pipeline:
make run
Notes
- 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.
Metadata
Release files for homesec 1.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| homesec-1.11.0.tar.gz | 3.7 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| homesec-1.11.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.0 MB
Release files / homesec-1.11.0.tar.gz
| Download URL | homesec-1.11.0.tar.gz |
|---|---|
| Size | 3.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91947a8a245fc63973214c7ebcaf3d7860ea2f1b7c6bfa0e9b93a41ed21b8b6b
|
|
BLAKE2b-256 checksum How to use checksums |
0fbe4cfa4331812048dbae1fc7844120b4b07862eb7492cc4534cd18e16d672c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 9, 2026.
Transparency logRelease files / homesec-1.11.0-py3-none-any.whl
| Download URL | homesec-1.11.0-py3-none-any.whl |
|---|---|
| Size | 326.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78f72064811530f361dd8995e4c21d910e7d50e7e0d3321709d946cef1598265
|
|
BLAKE2b-256 checksum How to use checksums |
ca5dfb7d660d876a23c4b5bf24cecd0af84c1140e22b69609b65d025507d1be9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 9, 2026.
Transparency log