docker.recipes

Frigate + Home Assistant + MQTT

advanced

Complete smart home surveillance stack with AI-powered NVR, home automation, and MQTT broker for seamless integration.

Overview

Frigate is an open-source Network Video Recorder (NVR) built specifically for real-time AI object detection on IP cameras. Unlike traditional surveillance systems that simply record footage, Frigate uses machine learning models to intelligently detect people, vehicles, and other objects in real-time, drastically reducing false alerts from shadows, rain, or swaying trees. It leverages hardware acceleration through Google Coral TPUs, Intel QuickSync, or NVIDIA GPUs to perform efficient AI inference without overwhelming your system resources. This surveillance stack combines Frigate's intelligent video analysis with Home Assistant's powerful automation engine and Mosquitto's lightweight MQTT messaging. Frigate publishes detection events to MQTT topics that Home Assistant consumes, enabling sophisticated automation workflows like sending notifications when a person is detected at your front door, turning on lights when motion is detected at night, or recording clips only when specific objects are identified. The MQTT broker acts as the central nervous system, ensuring reliable message delivery between Frigate's AI detections and Home Assistant's automation responses. This configuration is ideal for privacy-conscious homeowners who want professional-grade surveillance without cloud dependencies, smart home enthusiasts building comprehensive automation systems, and security-focused users who need intelligent video analytics with local processing. The combination provides enterprise-level surveillance capabilities while maintaining complete local control over your video feeds and detection data.

Key Features

  • Real-time AI object detection with configurable zones and object filters
  • Hardware acceleration support for Google Coral TPU, Intel QuickSync, and NVIDIA GPU
  • MQTT-based event publishing for instant Home Assistant automation triggers
  • Frigate integration in Home Assistant for camera feeds, clips, and detection management
  • Intelligent recording that saves storage by capturing only relevant events
  • Web-based dashboard with live camera feeds and detection timeline
  • RTSP re-streaming for accessing camera feeds from multiple clients
  • Home Assistant automation engine with 2000+ device integrations for complex workflows

Common Use Cases

  • 1Home security system with AI-powered person and vehicle detection at entry points
  • 2Smart doorbell replacement using existing IP cameras with Home Assistant notifications
  • 3Automated lighting and security responses based on intelligent motion detection
  • 4Pet monitoring with automated feeding schedules triggered by animal detection
  • 5Business surveillance with after-hours alerts and automated security responses
  • 6Privacy-focused family monitoring without cloud storage or third-party services
  • 7Integration with existing smart home devices for comprehensive automation workflows

Prerequisites

  • Minimum 2GB RAM for Home Assistant and Frigate AI processing (4GB+ recommended)
  • IP cameras with RTSP stream support for Frigate video input
  • Basic understanding of YAML configuration for Frigate camera setup
  • Network access to camera RTSP streams from Docker host
  • Optional: Google Coral TPU, Intel GPU, or NVIDIA GPU for hardware acceleration
  • Understanding of MQTT topics and Home Assistant integration concepts

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 # MQTT Broker - Central message hub
3 mosquitto:
4 image: eclipse-mosquitto:2
5 container_name: mosquitto
6 restart: unless-stopped
7 volumes:
8 - ./mosquitto/config:/mosquitto/config
9 - ./mosquitto/data:/mosquitto/data
10 - ./mosquitto/log:/mosquitto/log
11 ports:
12 - "1883:1883"
13 - "9001:9001"
14 command: mosquitto -c /mosquitto/config/mosquitto.conf
15
16 # Frigate NVR - AI-powered camera system
17 frigate:
18 image: ghcr.io/blakeblackshear/frigate:stable
19 container_name: frigate
20 restart: unless-stopped
21 privileged: true
22 shm_size: 256mb
23 depends_on:
24 - mosquitto
25 devices:
26 - /dev/bus/usb:/dev/bus/usb # USB Coral TPU (optional)
27 # - /dev/dri/renderD128:/dev/dri/renderD128 # Intel GPU (optional)
28 volumes:
29 - ./frigate/config:/config
30 - ./frigate/media:/media/frigate
31 - type: tmpfs
32 target: /tmp/cache
33 tmpfs:
34 size: 1000000000
35 ports:
36 - "5000:5000" # Web UI
37 - "8554:8554" # RTSP feeds
38 - "8555:8555/tcp"
39 - "8555:8555/udp"
40 environment:
41 - FRIGATE_RTSP_PASSWORD=${RTSP_PASSWORD:-changeme}
42 - FRIGATE_MQTT_HOST=mosquitto
43 - FRIGATE_MQTT_PORT=1883
44 - FRIGATE_MQTT_USER=${MQTT_USER:-}
45 - FRIGATE_MQTT_PASSWORD=${MQTT_PASSWORD:-}
46
47 # Home Assistant - Home automation platform
48 homeassistant:
49 image: ghcr.io/home-assistant/home-assistant:stable
50 container_name: homeassistant
51 restart: unless-stopped
52 depends_on:
53 - mosquitto
54 - frigate
55 volumes:
56 - ./homeassistant/config:/config
57 - /etc/localtime:/etc/localtime:ro
58 ports:
59 - "8123:8123"
60 environment:
61 - TZ=${TZ:-UTC}
62
63networks:
64 default:
65 driver: bridge

.env Template

.env
1# Timezone
2TZ=Europe/London
3
4# MQTT Credentials (optional, for secured setup)
5MQTT_USER=
6MQTT_PASSWORD=
7
8# Frigate RTSP Password
9RTSP_PASSWORD=changeme
10
11# ============================================
12# SETUP INSTRUCTIONS
13# ============================================
14
15# 1. Create Mosquitto config:
16# mkdir -p mosquitto/config mosquitto/data mosquitto/log
17# cat > mosquitto/config/mosquitto.conf << 'EOF'
18# listener 1883
19# listener 9001
20# protocol websockets
21# allow_anonymous true
22# persistence true
23# persistence_location /mosquitto/data/
24# log_dest file /mosquitto/log/mosquitto.log
25# EOF
26
27# 2. Create Frigate config:
28# mkdir -p frigate/config frigate/media
29# cat > frigate/config/config.yml << 'EOF'
30# mqtt:
31# enabled: true
32# host: mosquitto
33# port: 1883
34# topic_prefix: frigate
35# client_id: frigate
36#
37# detectors:
38# cpu1:
39# type: cpu
40#
41# cameras:
42# front_door:
43# ffmpeg:
44# inputs:
45# - path: rtsp://user:pass@camera-ip:554/stream
46# roles:
47# - detect
48# - record
49# detect:
50# enabled: true
51# width: 1280
52# height: 720
53# fps: 5
54# record:
55# enabled: true
56# retain:
57# days: 7
58# snapshots:
59# enabled: true
60# retain:
61# default: 7
62# EOF
63
64# 3. In Home Assistant, add MQTT integration:
65# Settings > Devices & Services > Add Integration > MQTT
66# Broker: mosquitto (or the container IP)
67# Port: 1883
68
69# 4. Install Frigate integration in HACS or manually:
70# Settings > Devices & Services > Add Integration > Frigate
71# URL: http://frigate:5000

Usage Notes

  1. 1Frigate UI at http://localhost:5000
  2. 2Home Assistant at http://localhost:8123
  3. 3MQTT broker at localhost:1883
  4. 4Create mosquitto/config/mosquitto.conf before starting
  5. 5Create frigate/config/config.yml with your cameras
  6. 6Add MQTT integration in Home Assistant for Frigate events
  7. 7Install Frigate integration in Home Assistant for full control
  8. 8Frigate sends motion/object events via MQTT to Home Assistant

Individual Services(3 services)

Copy individual services to mix and match with your existing compose files.

mosquitto
mosquitto:
  image: eclipse-mosquitto:2
  container_name: mosquitto
  restart: unless-stopped
  volumes:
    - ./mosquitto/config:/mosquitto/config
    - ./mosquitto/data:/mosquitto/data
    - ./mosquitto/log:/mosquitto/log
  ports:
    - "1883:1883"
    - "9001:9001"
  command: mosquitto -c /mosquitto/config/mosquitto.conf
frigate
frigate:
  image: ghcr.io/blakeblackshear/frigate:stable
  container_name: frigate
  restart: unless-stopped
  privileged: true
  shm_size: 256mb
  depends_on:
    - mosquitto
  devices:
    - /dev/bus/usb:/dev/bus/usb
  volumes:
    - ./frigate/config:/config
    - ./frigate/media:/media/frigate
    - type: tmpfs
      target: /tmp/cache
      tmpfs:
        size: 1000000000
  ports:
    - "5000:5000"
    - "8554:8554"
    - 8555:8555/tcp
    - 8555:8555/udp
  environment:
    - FRIGATE_RTSP_PASSWORD=${RTSP_PASSWORD:-changeme}
    - FRIGATE_MQTT_HOST=mosquitto
    - FRIGATE_MQTT_PORT=1883
    - FRIGATE_MQTT_USER=${MQTT_USER:-}
    - FRIGATE_MQTT_PASSWORD=${MQTT_PASSWORD:-}
homeassistant
homeassistant:
  image: ghcr.io/home-assistant/home-assistant:stable
  container_name: homeassistant
  restart: unless-stopped
  depends_on:
    - mosquitto
    - frigate
  volumes:
    - ./homeassistant/config:/config
    - /etc/localtime:/etc/localtime:ro
  ports:
    - "8123:8123"
  environment:
    - TZ=${TZ:-UTC}

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 # MQTT Broker - Central message hub
5 mosquitto:
6 image: eclipse-mosquitto:2
7 container_name: mosquitto
8 restart: unless-stopped
9 volumes:
10 - ./mosquitto/config:/mosquitto/config
11 - ./mosquitto/data:/mosquitto/data
12 - ./mosquitto/log:/mosquitto/log
13 ports:
14 - "1883:1883"
15 - "9001:9001"
16 command: mosquitto -c /mosquitto/config/mosquitto.conf
17
18 # Frigate NVR - AI-powered camera system
19 frigate:
20 image: ghcr.io/blakeblackshear/frigate:stable
21 container_name: frigate
22 restart: unless-stopped
23 privileged: true
24 shm_size: 256mb
25 depends_on:
26 - mosquitto
27 devices:
28 - /dev/bus/usb:/dev/bus/usb # USB Coral TPU (optional)
29 # - /dev/dri/renderD128:/dev/dri/renderD128 # Intel GPU (optional)
30 volumes:
31 - ./frigate/config:/config
32 - ./frigate/media:/media/frigate
33 - type: tmpfs
34 target: /tmp/cache
35 tmpfs:
36 size: 1000000000
37 ports:
38 - "5000:5000" # Web UI
39 - "8554:8554" # RTSP feeds
40 - "8555:8555/tcp"
41 - "8555:8555/udp"
42 environment:
43 - FRIGATE_RTSP_PASSWORD=${RTSP_PASSWORD:-changeme}
44 - FRIGATE_MQTT_HOST=mosquitto
45 - FRIGATE_MQTT_PORT=1883
46 - FRIGATE_MQTT_USER=${MQTT_USER:-}
47 - FRIGATE_MQTT_PASSWORD=${MQTT_PASSWORD:-}
48
49 # Home Assistant - Home automation platform
50 homeassistant:
51 image: ghcr.io/home-assistant/home-assistant:stable
52 container_name: homeassistant
53 restart: unless-stopped
54 depends_on:
55 - mosquitto
56 - frigate
57 volumes:
58 - ./homeassistant/config:/config
59 - /etc/localtime:/etc/localtime:ro
60 ports:
61 - "8123:8123"
62 environment:
63 - TZ=${TZ:-UTC}
64
65networks:
66 default:
67 driver: bridge
68EOF
69
70# 2. Create the .env file
71cat > .env << 'EOF'
72# Timezone
73TZ=Europe/London
74
75# MQTT Credentials (optional, for secured setup)
76MQTT_USER=
77MQTT_PASSWORD=
78
79# Frigate RTSP Password
80RTSP_PASSWORD=changeme
81
82# ============================================
83# SETUP INSTRUCTIONS
84# ============================================
85
86# 1. Create Mosquitto config:
87# mkdir -p mosquitto/config mosquitto/data mosquitto/log
88# cat > mosquitto/config/mosquitto.conf << 'EOF'
89# listener 1883
90# listener 9001
91# protocol websockets
92# allow_anonymous true
93# persistence true
94# persistence_location /mosquitto/data/
95# log_dest file /mosquitto/log/mosquitto.log
96# EOF
97
98# 2. Create Frigate config:
99# mkdir -p frigate/config frigate/media
100# cat > frigate/config/config.yml << 'EOF'
101# mqtt:
102# enabled: true
103# host: mosquitto
104# port: 1883
105# topic_prefix: frigate
106# client_id: frigate
107#
108# detectors:
109# cpu1:
110# type: cpu
111#
112# cameras:
113# front_door:
114# ffmpeg:
115# inputs:
116# - path: rtsp://user:pass@camera-ip:554/stream
117# roles:
118# - detect
119# - record
120# detect:
121# enabled: true
122# width: 1280
123# height: 720
124# fps: 5
125# record:
126# enabled: true
127# retain:
128# days: 7
129# snapshots:
130# enabled: true
131# retain:
132# default: 7
133# EOF
134
135# 3. In Home Assistant, add MQTT integration:
136# Settings > Devices & Services > Add Integration > MQTT
137# Broker: mosquitto (or the container IP)
138# Port: 1883
139
140# 4. Install Frigate integration in HACS or manually:
141# Settings > Devices & Services > Add Integration > Frigate
142# URL: http://frigate:5000
143EOF
144
145# 3. Start the services
146docker compose up -d
147
148# 4. View logs
149docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/frigate-home-assistant-mqtt/run | bash

Troubleshooting

  • Frigate shows 'Failed to connect to camera' errors: Verify RTSP URLs are accessible and credentials are correct in config.yml
  • High CPU usage during AI detection: Enable hardware acceleration by uncommenting GPU device mappings or connecting Coral TPU
  • Home Assistant not receiving Frigate events: Check MQTT broker connectivity and ensure Frigate MQTT settings match Mosquitto configuration
  • Frigate web UI shows black camera feeds: Verify camera RTSP streams support the codecs specified in Frigate config
  • Mosquitto connection refused errors: Ensure mosquitto.conf exists with proper listener configuration before container startup
  • Home Assistant Frigate integration fails: Install HACS Frigate integration and configure with correct Frigate URL and MQTT settings

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space