跳到主要内容

Home Assistant 集成

与 Home Assistant 集成的最佳方法是使用官方集成。

安装

准备

Frigate 集成要求首先安装并手动配置 mqtt 集成。

请参阅 MQTT 集成文档 了解更多详情。

此外,必须在 Frigate 配置文件中启用 MQTT,并且 Frigate 必须与 Home Assistant 连接到同的 MQTT 服务器,这样集成创建的许多实体才能运行。

集成安装

可通过 HACS 作为默认存储库提供。安装:

  • 使用 HACS 安装集成:
Home Assistant > HACS > Integrations > "Explore & Add Integrations" > Frigate
  • 重启 Home Assistant.
  • 然后添加/配置集成:
Home Assistant > Settings > Devices & Services > Add Integration > Frigate

注意:您还需要在 Home Assistant 配置中启用 media_source,媒体浏览器才会出现。

(可选)Lovelace 卡片安装

要安装可选的配套Lovelace 卡片,请参阅该卡的 单独安装说明

配置

在配置集成时,系统会要求你提供 Frigate 实例的 URL 地址,也就是你在浏览器中访问 Frigate 时使用的 URL。这看起来像 http://<host>:5000/。请注意,如果您使用的是代理插件,则无需将集成指向代理 URL。只需输入从网络直接访问 Frigate 的 URL 即可。

可选

Home Assistant > Configuration > Integrations > Frigate > Options
OptionDescription
RTSP URL TemplateA jinja2 template that is used to override the standard RTSP stream URL (e.g. for use with reverse proxies). This option is only shown to users who have advanced mode enabled. See RTSP流 below.

提供的实体

PlatformDescription
cameraLive camera stream (requires RTSP), camera for image of the last detected object.
sensorStates to monitor Frigate performance, object counts for all zones and cameras.
switchSwitch entities to toggle detection, recordings and snapshots.
binary_sensorA "motion" binary sensor entity per camera/zone/object.

媒体浏览器支持

该集成可提供:

  • 通过缩略图浏览事件记录
  • 浏览抓拍
  • 按月、日、摄像机和时间浏览录像

可通过 Home Assistant 左侧菜单面板上的 “媒体浏览器 ”访问。

将剪辑投射到媒体设备

该集成支持将剪辑和摄像机流传输到支持的媒体设备。

提示

要将剪辑投射到媒体设备上,需要音频,并在录像中启用音频录制。

NOTE: 即使你的摄像机不支持音频,也需要启用音频录制才能投射。

通知 API

许多人不希望将 Frigate 暴露在网络上,因此集成创建了一些可用于通知的公共 API 端点。

加载事件缩略图:

https://HA_URL/api/frigate/notifications/<event-id>/thumbnail.jpg

加载事件抓拍:

https://HA_URL/api/frigate/notifications/<event-id>/snapshot.jpg

加载事件剪辑:

https://HA_URL/api/frigate/notifications/<event-id>/clip.mp4

RTSP流

为了让实况流发挥作用,需要通过 RTSP 端口(默认:8554)访问<frigate_host>:8554。当浏览摄像机实况时,Home Assistant 将直接到该流媒体端口。

RTSP URL 模板

对于高级用例,可使用 RTSP URL 模板 选项更改此行为。设置后,该字符串将覆盖从上述默认行为导出的默认流地址。该选项支持 jinja2 模板,并且模板可使用 Frigate API 中的 camera dict 变量。请注意,模板中没有 Home Assistant 状态,只有来自 Frigate 的 camera dict。

当 Frigate 位于反向代理后面时,和/或当 Home Assistant 无法访问默认流端口时(如防火墙规则),这可能会很有用。

RTSP URL 模板示例

使用不同的端口号:

rtsp://<frigate_host>:2000/front_door

在流 URL 中使用摄像机名称:

rtsp://<frigate_host>:2000/{{ name }}

在流 URL 中使用摄像机名称,先将其转换为小写:

rtsp://<frigate_host>:2000/{{ name|lower }}

多实例支持

Frigate 集成可无缝支持多个 Frigate 服务器的使用。

多实例的要求

为使多个 Frigate 实例正常运行,必须对每个服务器的 topic_prefixclient_id 参数进行不同设置。 请参阅 MQTT 配置 了解如何设置这些参数。

API URLs

当配置了多个 Frigate 实例时,API URL 应包含一个标识符,以便告诉 Home Assistant 要引用哪个 Frigate 实例。使用的标识符是配置中包含的 MQTT client_id 参数,使用方法如下:

https://HA_URL/api/frigate/<client-id>/notifications/<event-id>/thumbnail.jpg
https://HA_URL/api/frigate/<client-id>/clips/front_door-1624599978.427826-976jaa.mp4

默认处理方式

当配置了单个 Frigate 实例时,无需在 URL/标识符中指定 client-id 参数,而是假定为该单个实例。如果配置了多个 Frigate 实例,用户必须明确指定所指向的服务器。

FAQ

如果要检测多个目标,如何在 HomeKit 中为摄像机分配正确的 binary_sensor

HomeKit 集成 会随机链接 Home Assistant 摄像机设备组的一个 binary_sensor(motion sensor entities)。您可以在 Home Assistant HomeKit 配置 中为每个摄像机指定一个 linked_motion_sensor