This commit is contained in:
Felipe Santos 2025-03-21 20:00:03 -03:00 committed by GitHub
commit c489038866
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 176 additions and 62 deletions

View File

@ -9,39 +9,6 @@ set -o errexit -o nounset -o pipefail
# Tell S6-Overlay not to restart this service
s6-svc -O .
function migrate_db_path() {
# Find config file in yaml or yml, but prefer yaml
local config_file="${CONFIG_FILE:-"/config/config.yml"}"
local config_file_yaml="${config_file//.yml/.yaml}"
if [[ -f "${config_file_yaml}" ]]; then
config_file="${config_file_yaml}"
elif [[ ! -f "${config_file}" ]]; then
# Frigate will create the config file on startup
return 0
fi
unset config_file_yaml
# Use yq to check if database.path is set
local user_db_path
user_db_path=$(yq eval '.database.path' "${config_file}")
if [[ "${user_db_path}" == "null" ]]; then
local previous_db_path="/media/frigate/frigate.db"
local new_db_dir="/config"
if [[ -f "${previous_db_path}" ]]; then
if mountpoint --quiet "${new_db_dir}"; then
# /config is a mount point, move the db
echo "[INFO] Moving db from '${previous_db_path}' to the '${new_db_dir}' dir..."
# Move all files that starts with frigate.db to the new directory
mv -vf "${previous_db_path}"* "${new_db_dir}"
else
echo "[ERROR] Trying to migrate the db path from '${previous_db_path}' to the '${new_db_dir}' dir, but '${new_db_dir}' is not a mountpoint, please mount the '${new_db_dir}' dir"
return 1
fi
fi
fi
}
function set_libva_version() {
local ffmpeg_path
ffmpeg_path=$(python3 /usr/local/ffmpeg/get_ffmpeg_path.py)
@ -50,8 +17,8 @@ function set_libva_version() {
}
echo "[INFO] Preparing Frigate..."
migrate_db_path
set_libva_version
echo "[INFO] Starting Frigate..."
cd /opt/frigate || echo "[ERROR] Failed to change working directory to /opt/frigate"

View File

@ -0,0 +1,140 @@
#!/command/with-contenv bash
# shellcheck shell=bash
# Do preparation tasks before starting the main services
set -o errexit -o nounset -o pipefail
function migrate_addon_config_dir() {
local home_assistant_config_dir="/homeassistant"
if ! mountpoint --quiet "${home_assistant_config_dir}"; then
# Not running as a Home Assistant add-on
return 0
fi
local config_dir="/config"
local new_config_file="${config_dir}/config.yml"
local new_config_file_yaml="${new_config_file//.yml/.yaml}"
if [[ -f "${new_config_file_yaml}" || -f "${new_config_file}" ]]; then
# Already migrated
return 0
fi
unset new_config_file new_config_file_yaml
local old_config_file="${home_assistant_config_dir}/frigate.yml"
local old_config_file_yaml="${old_config_file//.yml/.yaml}"
local new_config_file="${config_dir}/config.yml"
if [[ -f "${old_config_file_yaml}" ]]; then
old_config_file="${old_config_file_yaml}"
new_config_file="${new_config_file//.yml/.yaml}"
elif [[ ! -f "${old_config_file}" ]]; then
# Nothing to migrate
return 0
fi
unset old_config_file_yaml
local db_path
db_path=$(yq eval '.database.path' "${old_config_file}")
if [[ "${db_path}" == "null" ]]; then
db_path="${config_dir}/frigate.db"
fi
if [[ "${db_path}" == "${config_dir}/"* ]]; then
# replace /config/ prefix with /homeassistant/
local old_db_path="${home_assistant_config_dir}/${db_path:8}"
if [[ -f "${old_db_path}" ]]; then
local new_db_dir
new_db_dir="$(dirname "${db_path}")"
echo "[INFO] Migrating database from '${old_db_path}' to '${new_db_dir}' dir..."
mkdir -vp "${new_db_dir}"
mv -vf "${old_db_path}"* "${new_db_dir}"
fi
fi
local model_path
model_path=$(yq eval '.model.path' "${old_config_file}")
if [[ "${model_path}" == "${config_dir}/"* ]]; then
# replace /config/ prefix with /homeassistant/
local old_model_path="${home_assistant_config_dir}/${model_path:8}"
if [[ -f "${old_model_path}" ]]; then
local new_model_dir
new_model_dir="$(dirname "${model_path}")"
echo "[INFO] Migrating model from '${old_model_path}' to '${model_path}'..."
mkdir -vp "${new_model_dir}"
mv -vf "${old_model_path}" "${model_path}"
fi
fi
local ffmpeg_path
ffmpeg_path=$(yq eval '.ffmpeg.path' "${old_config_file}")
if [[ "${ffmpeg_path}" == "${config_dir}/"* ]]; then
# replace /config/ prefix with /homeassistant/
local old_ffmpeg_path="${home_assistant_config_dir}/${ffmpeg_path:8}"
if [[ -d "${old_ffmpeg_path}" ]]; then
local new_ffmpeg_dir
new_ffmpeg_dir="$(dirname "${ffmpeg_path}")"
echo "[INFO] Migrating ffmpeg from '${old_ffmpeg_path}' to '${ffmpeg_path}'..."
mkdir -vp "${new_ffmpeg_dir}"
mv -vf "${old_ffmpeg_path}" "${ffmpeg_path}"
fi
fi
local old_model_cache_path="${home_assistant_config_dir}/model_cache"
if [[ -d "${old_model_cache_path}" ]]; then
echo "[INFO] Migrating '${old_model_cache_path}' to '${config_dir}'..."
mv -f "${old_model_cache_path}" "${config_dir}"
fi
echo "[INFO] Migrating other files from '${home_assistant_config_dir}' to '${config_dir}'..."
local file
for file in .exports .jwt_secret .timeline .vacuum go2rtc; do
file="${home_assistant_config_dir}/${file}"
if [[ -f "${file}" ]]; then
mv -vf "${file}" "${config_dir}"
fi
done
echo "[INFO] Migrating config file from '${old_config_file}' to '${new_config_file}'..."
mv -vf "${old_config_file}" "${new_config_file}"
echo "[INFO] Migration from Home Assistant config dir to add-on config dir completed."
}
function migrate_db_from_media_to_config() {
# Find config file in yaml or yml, but prefer yaml
local config_file="${CONFIG_FILE:-"/config/config.yml"}"
local config_file_yaml="${config_file//.yml/.yaml}"
if [[ -f "${config_file_yaml}" ]]; then
config_file="${config_file_yaml}"
elif [[ ! -f "${config_file}" ]]; then
# Frigate will create the config file on startup
return 0
fi
unset config_file_yaml
local user_db_path
user_db_path=$(yq eval '.database.path' "${config_file}")
if [[ "${user_db_path}" == "null" ]]; then
local old_db_path="/media/frigate/frigate.db"
local new_db_dir="/config"
if [[ -f "${old_db_path}" ]]; then
if mountpoint --quiet "${new_db_dir}"; then
# /config is a mount point, move the db
echo "[INFO] Migrating database from '${old_db_path}' to '${new_db_dir}' dir..."
# Move all files that starts with frigate.db to the new directory
mv -vf "${old_db_path}"* "${new_db_dir}"
else
echo "[ERROR] Trying to migrate the database path from '${old_db_path}' to '${new_db_dir}' dir, but '${new_db_dir}' is not a mountpoint, please mount the '${new_db_dir}' dir"
return 1
fi
fi
fi
}
echo "[INFO] Preparing Frigate..."
migrate_addon_config_dir
migrate_db_from_media_to_config

View File

@ -0,0 +1 @@
oneshot

View File

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/prepare/run

View File

@ -14,7 +14,7 @@ Depending on your system, these parameters may not be compatible. More informati
## Raspberry Pi 3/4
Ensure you increase the allocated RAM for your GPU to at least 128 (`raspi-config` > Performance Options > GPU Memory).
If you are using the HA addon, you may need to use the full access variant and turn off `Protection mode` for hardware acceleration.
If you are using the HassOS addon, you may need to use the full access variant and turn off `Protection mode` for hardware acceleration.
```yaml
# if you want to decode a h264 stream
@ -80,7 +80,7 @@ Or map in all the `/dev/video*` devices.
:::note
The default driver is `iHD`. You may need to change the driver to `i965` by adding the following environment variable `LIBVA_DRIVER_NAME=i965` to your docker-compose file or [in the `frigate.yaml` for HA OS users](advanced.md#environment_vars).
The default driver is `iHD`. You may need to change the driver to `i965` by adding the following environment variable `LIBVA_DRIVER_NAME=i965` to your docker-compose file or [in the `config.yaml` for HassOS addon users](advanced.md#environment_vars).
See [The Intel Docs](https://www.intel.com/content/www/us/en/support/articles/000005505/processors.html) to figure out what generation your CPU is.
@ -191,7 +191,7 @@ VAAPI supports automatic profile selection so it will work automatically with bo
:::note
You need to change the driver to `radeonsi` by adding the following environment variable `LIBVA_DRIVER_NAME=radeonsi` to your docker-compose file or [in the `frigate.yaml` for HA OS users](advanced.md#environment_vars).
You need to change the driver to `radeonsi` by adding the following environment variable `LIBVA_DRIVER_NAME=radeonsi` to your docker-compose file or [in the `config.yaml` for HassOS addon users](advanced.md#environment_vars).
:::

View File

@ -3,9 +3,11 @@ id: index
title: Frigate Configuration
---
For Home Assistant Addon installations, the config file needs to be in the root of your Home Assistant config directory (same location as `configuration.yaml`). It can be named `frigate.yaml` or `frigate.yml`, but if both files exist `frigate.yaml` will be preferred and `frigate.yml` will be ignored.
For HassOS addon installations, the config file should be at `/addon_configs/ccab4aaf_frigate/config.yaml` ([click here to learn more on how to access this directory](#accessing-addon-config)).
For all other installation types, the config file should be mapped to `/config/config.yml` inside the container.
For all other installation types, the config file should be mapped to `/config/config.yaml` inside the container.
It can be named `config.yaml` or `config.yml`, but if both files exist `config.yaml` will be preferred and `config.yml` will be ignored.
It is recommended to start with a minimal configuration and add to it as described in [this guide](../guides/getting_started.md) and use the built in configuration editor in Frigate's UI which supports validation.
@ -23,6 +25,14 @@ cameras:
- detect
```
## Accessing the HassOS addon configuration directory {#accessing-addon-config}
When running Frigate through the HassOS addon, the Frigate `/config` directory is mapped to a directory in the host inside `/addon_configs`. The directory name depends on the addon variant you are using. For example, if you are using the standard Frigate addon variant, the directory will be `/addon_configs/ccab4aaf_frigate`.
**Whenever you see `/config` in the documentation, it refers to this directory.**
If for example you use the [VS Code addon](https://github.com/hassio-addons/addon-vscode) to browse your files, you can click _File_ > _Open folder..._ and navigate to `/addon_configs/ccab4aaf_frigate` to access the Frigate `/config` directory.
## VSCode Configuration Schema
VSCode supports JSON schemas for automatically validating configuration files. You can enable this feature by adding `# yaml-language-server: $schema=http://frigate_host:5000/api/config/schema.json` to the beginning of the configuration file. Replace `frigate_host` with the IP address or hostname of your Frigate server. If you're using both VSCode and Frigate as an add-on, you should use `ccab4aaf-frigate` instead. Make sure to expose the internal unauthenticated port `5000` when accessing the config from VSCode on another machine.

View File

@ -104,9 +104,9 @@ cameras:
WebRTC works by creating a TCP or UDP connection on port `8555`. However, it requires additional configuration:
- For external access, over the internet, setup your router to forward port `8555` to port `8555` on the Frigate device, for both TCP and UDP.
- For internal/local access, unless you are running through the add-on, you will also need to set the WebRTC candidates list in the go2rtc config. For example, if `192.168.1.10` is the local IP of the device running Frigate:
- For internal/local access, unless you are running through the HassOS addon, you will also need to set the WebRTC candidates list in the go2rtc config. For example, if `192.168.1.10` is the local IP of the device running Frigate:
```yaml title="/config/frigate.yaml"
```yaml title="/addon_configs/ccab4aaf_frigate/config.yaml"
go2rtc:
streams:
test_cam: ...

View File

@ -281,18 +281,19 @@ HassOS users can install via the addon repository.
2. Add https://github.com/blakeblackshear/frigate-hass-addons
3. Install your desired Frigate NVR Addon and navigate to it's page
4. Setup your network configuration in the `Configuration` tab
5. (not for proxy addon) Create the file `frigate.yaml` in your `config` directory with your detailed Frigate configuration
5. (not for proxy addon) Create the file `config.yaml` in your `/addon_configs/ccab4aaf_frigate` directory with your detailed Frigate configuration ([click here to learn more on how to access this directory](../configuration/index.md#accessing-addon-config))
6. Start the addon container
7. (not for proxy addon) If you are using hardware acceleration for ffmpeg, you may need to disable "Protection mode"
There are several versions of the addon available:
There are several variants of the addon available:
| Addon Version | Description |
| ------------------------------ | ---------------------------------------------------------- |
| Frigate NVR | Current release with protection mode on |
| Frigate NVR (Full Access) | Current release with the option to disable protection mode |
| Frigate NVR Beta | Beta release with protection mode on |
| Frigate NVR Beta (Full Access) | Beta release with the option to disable protection mode |
| Addon Version | Description |
| -------------------------- | ---------------------------------------------------------- |
| Frigate | Current release with protection mode on |
| Frigate (Full Access) | Current release with the option to disable protection mode |
| Frigate Beta | Beta release with protection mode on |
| Frigate Beta (Full Access) | Beta release with the option to disable protection mode |
| Frigate HailoRT Beta | Beta release with HailoRT support |
## Kubernetes

View File

@ -15,12 +15,6 @@ As of Home Assistant Core 2023.6, Network Mounted Storage is supported for addon
### Initial Setup
1. Stop the Frigate addon
2. Update your [config](configuration/index.md) so the DB is stored in the /config directory by adding:
```yaml
database:
path: /config/frigate.db
```
### Move current data

View File

@ -97,13 +97,13 @@ services:
If you are using HassOS with the addon, the URL should be one of the following depending on which addon version you are using. Note that if you are using the Proxy Addon, you do NOT point the integration at the proxy URL. Just enter the URL used to access Frigate directly from your network.
| Addon Version | URL |
| ------------------------------ | ----------------------------------------- |
| Frigate NVR | `http://ccab4aaf-frigate:5000` |
| Frigate NVR (Full Access) | `http://ccab4aaf-frigate-fa:5000` |
| Frigate NVR Beta | `http://ccab4aaf-frigate-beta:5000` |
| Frigate NVR Beta (Full Access) | `http://ccab4aaf-frigate-fa-beta:5000` |
| Frigate NVR HailoRT Beta | `http://ccab4aaf-frigate-hailo-beta:5000` |
| Addon Version | URL |
| -------------------------- | ----------------------------------------- |
| Frigate | `http://ccab4aaf-frigate:5000` |
| Frigate (Full Access) | `http://ccab4aaf-frigate-fa:5000` |
| Frigate Beta | `http://ccab4aaf-frigate-beta:5000` |
| Frigate Beta (Full Access) | `http://ccab4aaf-frigate-fa-beta:5000` |
| Frigate HailoRT Beta | `http://ccab4aaf-frigate-hailo-beta:5000` |
### Frigate running on a separate machine