Frigate 如何定义与切换 Profiles,实现 Home/Away/夜间等运行时无重启配置切换?
【免费下载链接】frigateNVR with realtime local object detection for IP cameras项目地址: https://gitcode.com/GitHub_Trending/fr/frigate
Frigate 的 Profiles 让你定义一组命名的摄像头配置覆盖(override),并在运行中激活或停用它们,而无需重启 Frigate。适合"在家 / 出门"(Home / Away)、白天 / 夜间,或任何需要成批改变多台摄像头行为并随时切换的场景。切换后配置在内存中立即生效;当前激活的 Profile 会持久化到/config/.profiles文件,跨重启保留。同一时刻只能有一个 Profile 处于激活状态。
Profile 的两层结构
Profile 是一套两级系统,理解它是正确书写配置的前提:
- Profile 定义声明在配置的顶层
profiles下。每个定义有一个机器名(即 key)和一个供 UI 显示的friendly_name。 - 摄像头 Profile 覆盖声明在每台摄像头自己的
profiles段下,按 Profile 名分键。这里只需写你想改动的字段,其余字段继承摄像头的基线(base)配置。
激活某个 Profile 时,Frigate 把每台摄像头对应的覆盖合并到其基线配置之上;停用时,所有摄像头回到原配置。被摄像头引用的每个 Profile 名,都必须在顶层profiles中定义。
支持覆盖的配置段
Profile 覆盖可以作用于以下摄像头配置段:
| 段 | 说明 |
|---|---|
enabled | 完全启用或禁用该摄像头 |
audio | 音频检测设置 |
birdseye | 鸟瞰视图设置 |
detect | 对象检测设置 |
face_recognition | 人脸识别设置 |
lpr | 车牌识别设置 |
motion | 运动检测设置 |
notifications | 通知设置 |
objects | 对象跟踪与过滤设置 |
record | 录像设置 |
review | Review 告警与检测设置 |
snapshots | 快照设置 |
zones | 区域定义(与基线区域合并) |
只有你在覆盖中显式设置的字段会被应用,其余字段保留基线值。对 masks 和 zones 而言,Profile 的 zones 会覆盖摄像头的基线 masks 与 zones;用 YAML 配置 Profile 时,不要在 Profile 里定义基线配置中不存在的 masks 或 zones。
定义 Profile:YAML 方式
在 Frigate 配置文件顶层定义 Profile。下面的示例声明了home、away、night三个 Profile:
profiles: home: friendly_name: Home away: friendly_name: Away night: friendly_name: Night Mode然后在每台摄像头下加一个profiles段,按 Profile 名给出覆盖。这里只包含你想改的设置:
cameras: front_door: ffmpeg: inputs: - path: rtsp://camera:554/stream roles: - detect - record detect: enabled: true record: enabled: true profiles: away: detect: enabled: true notifications: enabled: true objects: track: - person - car - package review: alerts: labels: - person - car - package home: detect: enabled: true notifications: enabled: false objects: track: - person上面的
rtsp://camera:554/stream是文档示例中的占位流地址,替换为你自己的 RTSP 地址。
也可以直接通过 Frigate UI 定义:进入Settings > Global configuration > Profiles,点击Add Profile并输入名称(可选填 Profile ID)。之后进入某摄像头的配置段(如 Motion detection、Record、Notifications),右上角会出现 Profile 选择器,选择"摄像头 + Profile"即可编辑该组合的覆盖;只保存你改过的字段。需要重启才生效的字段会被隐藏,因为 Profile 在运行时应用。Remove Profile Override按钮用于清除覆盖。
一个 Home / Away 完整示例
这是文档给出的常见用法:根据在家与否使用不同的检测与通知设置。系统有两台摄像头front_door和indoor_cam:
profiles: home: friendly_name: Home away: friendly_name: Away cameras: front_door: ffmpeg: inputs: - path: rtsp://camera:554/stream roles: - detect - record detect: enabled: true record: enabled: true notifications: enabled: false profiles: away: notifications: enabled: true review: alerts: labels: - person - car home: notifications: enabled: false indoor_cam: ffmpeg: inputs: - path: rtsp://camera:554/indoor roles: - detect - record detect: enabled: false record: enabled: false profiles: away: enabled: true detect: enabled: true record: enabled: true home: enabled: false这个例子的行为:
- Away:
front_door开启通知并跟踪特定告警标签;indoor_cam完全启用(检测 + 录像)。 - Home:
front_door关闭通知;indoor_cam为隐私完全禁用。 - 无激活 Profile:所有摄像头使用基线配置值。
激活、停用与验证
Profile 可以通过 Frigate UI、MQTT、HTTP API 或 Home Assistant 集成来激活和停用。
UI 方式:打开设置齿轮,从子菜单选择Profiles即可看到所有已定义 Profile。可激活任意 Profile 或停用当前 Profile,当前生效的 Profile 会在 UI 中标示;桌面浏览器的底部状态栏也会显示当前激活 Profile。
MQTT 方式:向frigate/profile/set发布 Profile 名来激活它,发布none来停用当前 Profile。
# 激活 away Profile mosquitto_pub -t frigate/profile/set -m away # 停用当前 Profile mosquitto_pub -t frigate/profile/set -m nonefrigate/profile/state是验证入口:它发布当前激活的 Profile 名,无 Profile 时值为none,且该 topic 为 retained(保留)。订阅它即可核对激活结果:
mosquitto_sub -t frigate/profile/state激活或停用 Profile 会清除 Live 视图的运行时开关覆盖(runtime toggle overrides),避免切换后被残留的旧开关悄悄覆盖 Profile 设置。
边界与常见限制
- 一次只能激活一个 Profile。激活新 Profile 会自动停用当前 Profile。
- Profile 是纯覆盖。不能只定义在 Profile 而不在基线配置中——所有在 Profile 下定义的 zone / mask 都必须引用已存在于基线摄像头配置的条目;引入"仅 Profile 存在"的 zone 或 mask 的配置会在启动时被拒绝。想让某个 zone / mask 只在特定 Profile 生效,就在基线配置中以
enabled: false定义,再在对应 Profile 的覆盖里启用它。 - 需要重启才生效的字段不能通过 Profile 覆盖,因为 Profile 在运行时应用。这类字段在 UI 编辑覆盖时被隐藏,只能在基线配置中修改。
- 删除基线 zone / mask 的影响:通过 UI 删除基线条目时,对应 Profile 覆盖会被一并删除;若直接编辑配置文件删除了基线条目却留下 Profile 覆盖,配置会在启动时校验失败,直到移除这个孤儿覆盖。
- 让某个 YAML Profile 完全不跟踪对象:必须显式把
track设为空列表,空的objects段(或省略track)不会清空列表——空段不设置任何字段,Profile 会继承基线的完整跟踪列表:
cameras: front_door: profiles: home: objects: track: []其他列表(如audio.listen)同理。
- 定时切换:Frigate 本身不带调度器,因为它是 NVR 而非自动化平台。文档建议从已有时间 / 事件触发能力的自动化平台(如 Home Assistant、Node-RED)来激活 Profile,或用 cron 驱动脚本按时间表切换 Profile。
继续深入
完整说明见 Profiles 文档;MQTT topic 定义见 MQTT 集成,其中frigate/profile/set与frigate/profile/state分别用于切换和读取当前 Profile;Live 视图运行时开关的持久化与 Profile 切换的相互影响见 Live 视图。
【免费下载链接】frigateNVR with realtime local object detection for IP cameras项目地址: https://gitcode.com/GitHub_Trending/fr/frigate
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考