|
| 1 | + |
| 2 | +--- |
| 3 | +sidebar_position: 5 |
| 4 | +--- |
| 5 | + |
| 6 | +# Frigate NVR and Home Assistant Integration Wiki |
| 7 | + |
| 8 | +## 🌍 Introduction |
| 9 | + |
| 10 | +Frigate NVR is an open-source Network Video Recorder (NVR) designed specifically for real-time object detection using AI models. It is lightweight, powerful, and works seamlessly with cameras via the RTSP protocol. |
| 11 | + |
| 12 | +Home Assistant (HA) is an open-source platform for smart home automation that enables you to control and automate devices in your home. |
| 13 | + |
| 14 | +In this guide, we'll walk you through how to install **Frigate on a reComputer AI box** equipped with **Hailo PCIe**, and how to connect it to your existing **Home Assistant** setup using **MQTT** with minimal hassle. |
| 15 | + |
| 16 | +--- |
| 17 | +## 🛠️ Install Hailo PCIe Driver |
| 18 | + |
| 19 | +### Step 1: Enable PCIe Gen 3 Mode |
| 20 | + |
| 21 | +```bash |
| 22 | +sudo apt update |
| 23 | +sudo raspi-config |
| 24 | +``` |
| 25 | + |
| 26 | +* Navigate to `6 Advanced Options > A8 PCIe Speed` |
| 27 | +* Select `Yes` to enable PCIe Gen 3 |
| 28 | +* Exit and select `Finish` |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +Append the following line to the end of `/boot/firmware/config.txt`: |
| 33 | + |
| 34 | +```ini |
| 35 | +dtoverlay=pciex1-compat-pi5,no-mip |
| 36 | +``` |
| 37 | + |
| 38 | +### Step 2: Install PCIe Driver |
| 39 | + |
| 40 | +```bash |
| 41 | +sudo apt update |
| 42 | +sudo apt install dkms |
| 43 | +``` |
| 44 | + |
| 45 | +```bash |
| 46 | +git clone https://github.com/hailo-ai/hailort-drivers |
| 47 | +cd hailort-drivers/linux/pcie |
| 48 | +git checkout 24e7ff2fb58fab7029024c1a1d3f2d1914f56d7b |
| 49 | +sudo make install_dkms |
| 50 | +``` |
| 51 | + |
| 52 | +### Step 3: Install Firmware |
| 53 | + |
| 54 | +```bash |
| 55 | +cd ../.. |
| 56 | +./download_firmware.sh |
| 57 | +sudo mkdir -p /lib/firmware/hailo |
| 58 | +sudo cp hailo8_fw*.bin /lib/firmware/hailo/hailo8_fw.bin |
| 59 | +``` |
| 60 | + |
| 61 | +### Step 4: Fix PCIe Descriptor Size Issue |
| 62 | + |
| 63 | +Create `/etc/modprobe.d/hailo_pci.conf` with this content: |
| 64 | + |
| 65 | +```bash |
| 66 | +options hailo_pci force_desc_page_size=4096 |
| 67 | +``` |
| 68 | + |
| 69 | +### Step 5: Reboot and Verify |
| 70 | + |
| 71 | +```bash |
| 72 | +sudo reboot |
| 73 | +ls /dev/hailo* |
| 74 | +``` |
| 75 | + |
| 76 | +Expected output: |
| 77 | + |
| 78 | +```bash |
| 79 | +/dev/hailo0 |
| 80 | +``` |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## 🚧 Install Frigate NVR with Docker |
| 85 | + |
| 86 | +### Prerequisites |
| 87 | + |
| 88 | +Make sure your camera is configured for RTSP streaming at 1920x1080 resolution. |
| 89 | + |
| 90 | +### Update System |
| 91 | + |
| 92 | +```bash |
| 93 | +sudo apt update |
| 94 | +``` |
| 95 | + |
| 96 | +### Install Docker |
| 97 | + |
| 98 | +```bash |
| 99 | +curl -fsSL get.docker.com | bash |
| 100 | +sudo usermod -aG docker $USER |
| 101 | +sudo reboot |
| 102 | +``` |
| 103 | + |
| 104 | +### Pull Frigate Image |
| 105 | + |
| 106 | +```bash |
| 107 | +docker pull ghcr.io/blakeblackshear/frigate:0.15.0-rc2-h8l |
| 108 | +``` |
| 109 | + |
| 110 | +### Create Directory Structure |
| 111 | + |
| 112 | +```bash |
| 113 | +mkdir -p ~/frigate/config |
| 114 | +mkdir -p ~/frigate/data/db |
| 115 | +mkdir -p ~/frigate/data/storage |
| 116 | +cd ~/frigate |
| 117 | +``` |
| 118 | + |
| 119 | + |
| 120 | +### Create Docker Compose File (frigate.yml) |
| 121 | + |
| 122 | +```bash |
| 123 | +nano frigate.yml |
| 124 | +``` |
| 125 | + |
| 126 | +```yaml |
| 127 | +services: |
| 128 | + frigate-hailo: |
| 129 | + container_name: frigate-hailo |
| 130 | + privileged: true |
| 131 | + restart: unless-stopped |
| 132 | + image: ghcr.io/blakeblackshear/frigate:0.15.0-rc2-h8l |
| 133 | + shm_size: 1024mb |
| 134 | + devices: |
| 135 | + - /dev/hailo0:/dev/hailo0 |
| 136 | + volumes: |
| 137 | + - /etc/localtime:/etc/localtime:ro |
| 138 | + - ./config/:/config |
| 139 | + - ./data/db/:/data/db |
| 140 | + - ./data/storage:/media/frigate |
| 141 | + - type: tmpfs |
| 142 | + target: /tmp/cache |
| 143 | + tmpfs: |
| 144 | + size: 1g |
| 145 | + ports: |
| 146 | + - 5000:5000 |
| 147 | +``` |
| 148 | +### Create Frigate Config File (config/config.yml) |
| 149 | +
|
| 150 | +```bash |
| 151 | +nano config/config.yml |
| 152 | +``` |
| 153 | + |
| 154 | +```yaml |
| 155 | +database: |
| 156 | + path: /data/db/frigate.db |
| 157 | + |
| 158 | +go2rtc: |
| 159 | + streams: |
| 160 | + home: |
| 161 | + - rtsp://admin:passw0rd@192.168.98.11:554/cam/realmonitor?channel=1&subtype=0 |
| 162 | + |
| 163 | +cameras: |
| 164 | + home: |
| 165 | + ffmpeg: |
| 166 | + inputs: |
| 167 | + - path: rtsp://admin:passw0rd@192.168.98.11:554/cam/realmonitor?channel=1&subtype=0 |
| 168 | + roles: |
| 169 | + - record |
| 170 | + - detect |
| 171 | + |
| 172 | +mqtt: |
| 173 | + enabled: False |
| 174 | + |
| 175 | +objects: |
| 176 | + track: |
| 177 | + - person |
| 178 | + - cat |
| 179 | + |
| 180 | +detectors: |
| 181 | + hailo8l: |
| 182 | + type: hailo8l |
| 183 | + device: PCIe |
| 184 | + |
| 185 | +model: |
| 186 | + width: 300 |
| 187 | + height: 300 |
| 188 | + model_type: ssd |
| 189 | + path: /config/model_cache/h8l_cache/ssd_mobilenet_v1.hef |
| 190 | + |
| 191 | +version: 0.15-1 |
| 192 | +``` |
| 193 | +
|
| 194 | +### Start Frigate |
| 195 | +
|
| 196 | +```bash |
| 197 | +docker compose -f frigate.yml up -d |
| 198 | +``` |
| 199 | + |
| 200 | +### Access Web UI |
| 201 | + |
| 202 | +Visit: `http://<your-device-ip>:5000` |
| 203 | + |
| 204 | +--- |
| 205 | + |
| 206 | + |
| 207 | + |
| 208 | +## 🌟 Home Assistant Integration |
| 209 | + |
| 210 | +### Step 1: HACS Setup |
| 211 | + |
| 212 | +Assuming you're running Home Assistant (HA Green, HA Yellow, or similar standalone devices): |
| 213 | + |
| 214 | +* Install [HACS](https://hacs.xyz/docs/setup/download) if not already installed. |
| 215 | +* In HACS, install the **Frigate integration** from the community store. |
| 216 | + |
| 217 | + |
| 218 | + |
| 219 | +* Configure it using the IP and port of your Frigate AI box, e.g.: |
| 220 | + |
| 221 | +``` |
| 222 | +http://<ai_box_ip>:5000 |
| 223 | +``` |
| 224 | + |
| 225 | + |
| 226 | + |
| 227 | + |
| 228 | +### Step 2: Install MQTT Add-on |
| 229 | + |
| 230 | +Follow the [official MQTT integration guide](https://www.home-assistant.io/integrations/mqtt/) to install and configure the MQTT broker add-on. |
| 231 | + |
| 232 | +### Step 3: Update Frigate Config for MQTT |
| 233 | + |
| 234 | + |
| 235 | +### Step 3: Update Frigate Config for MQTT |
| 236 | + |
| 237 | +```yaml |
| 238 | +mqtt: |
| 239 | + host: <HA IP> |
| 240 | + port: 1883 |
| 241 | + topic_prefix: frigate |
| 242 | + client_id: frigate |
| 243 | + user: <HA User Name> |
| 244 | + password: <HA Password> |
| 245 | +``` |
| 246 | +
|
| 247 | +Example: |
| 248 | +
|
| 249 | +```yaml |
| 250 | +mqtt: |
| 251 | + host: 10.0.0.136 |
| 252 | + port: 1883 |
| 253 | + topic_prefix: frigate |
| 254 | + client_id: frigate |
| 255 | + user: kasun |
| 256 | + password: HiezenburgCook |
| 257 | +``` |
| 258 | +
|
| 259 | +full example : |
| 260 | +
|
| 261 | +```yaml |
| 262 | +database: |
| 263 | + path: /data/db/frigate.db |
| 264 | + |
| 265 | +go2rtc: |
| 266 | + streams: |
| 267 | + home: |
| 268 | + - rtsp://admin:12345678a@10.0.0.108:554/cam/realmonitor?channel=1&subtype=0 |
| 269 | + |
| 270 | +cameras: |
| 271 | + home: |
| 272 | + ffmpeg: |
| 273 | + inputs: |
| 274 | + - path: rtsp://admin:12345678a@10.0.0.108:554/cam/realmonitor?channel=1&subtype=0 |
| 275 | + roles: |
| 276 | + - record |
| 277 | + - detect |
| 278 | + |
| 279 | +mqtt: |
| 280 | + host: core-mosquitto |
| 281 | + port: 1883 |
| 282 | + topic_prefix: frigate |
| 283 | + client_id: frigate |
| 284 | + user: kasun |
| 285 | + password: HiezenburgCook |
| 286 | + |
| 287 | +objects: |
| 288 | + track: |
| 289 | + - person |
| 290 | + - cat |
| 291 | + |
| 292 | +detectors: |
| 293 | + hailo8l: |
| 294 | + type: hailo8l |
| 295 | + device: PCIe |
| 296 | + |
| 297 | +model: |
| 298 | + width: 300 |
| 299 | + height: 300 |
| 300 | + model_type: ssd |
| 301 | + path: /config/model_cache/h8l_cache/ssd_mobilenet_v1.hef |
| 302 | + |
| 303 | +version: 0.15-1 |
| 304 | + |
| 305 | + |
| 306 | +``` |
| 307 | +
|
| 308 | +### Step 4: Restart Frigate |
| 309 | +
|
| 310 | +```bash |
| 311 | +docker compose -f frigate.yml down |
| 312 | +sudo docker compose -f frigate.yml up -d |
| 313 | +``` |
| 314 | + |
| 315 | +### Step 5: Confirm MQTT is Working (optional) |
| 316 | + |
| 317 | +* Check HA logs or MQTT add-on logs to verify messages from Frigate |
| 318 | +* In HA, you can now use Frigate events in automations, e.g., motion alerts, detected objects, etc. |
| 319 | + |
| 320 | +--- |
| 321 | + |
| 322 | + |
| 323 | + |
| 324 | + |
| 325 | + |
| 326 | + |
0 commit comments