Google Pub/Sub
Google Pub/Sub 集成允许您挂钩到 Home Assistant 事件总线并将事件发送到 Google Cloud Pub/Sub。当前 GCP 的免费层应该允许您平均每 2 秒同步约 1 个事件(每月 200 万次调用)。
首次设置
这假设您已经有一个 Google Cloud 项目。如果没有,请在 Google Cloud Console 中创建一个。
在 Google Cloud API Console 中创建一个 Google Pub/Sub 主题。主题名称将类似于 projects/project-198373/topics/topic-name。只记下最后一部分(您选择的名称):topic-name。
接下来,您需要在 Google Cloud API Console 中创建一个服务账户密钥
- 选择一个新的"New Service Account",给它一个名称,并将密钥类型保留为 JSON
- 选择角色:Pub/Sub Publisher
这将把服务账户 JSON 密钥下载到您的机器上。不要与任何人分享此文件。将此文件放在您的 Home Assistant 配置文件夹中。
配置
将以下行添加到您的 "configuration.yaml" 文件中。
:::tip
更改配置后需要重启 Home Assistant。
:::
:::important 不过滤域或实体会将每个事件发送到 Google PubSub,从而很快达到免费层限制。请务必填写此配置参数或为 Google Cloud 付费订阅。
:::
配置过滤器
默认情况下,不会排除任何实体。要限制哪些实体暴露给 Google Pub/Sub,您可以使用 filter 参数。
Filters are applied as follows:
- No filter
- All entities included
- Only includes
- Entity listed in entities include: include
- Otherwise, entity matches domain include: include
- Otherwise, entity matches glob include: include
- Otherwise: exclude
- Only excludes
- Entity listed in exclude: exclude
- Otherwise, entity matches domain exclude: exclude
- Otherwise, entity matches glob exclude: exclude
- Otherwise: include
- Domain and/or glob includes (may also have excludes)
- Entity listed in entities include: include
- Otherwise, entity listed in entities exclude: exclude
- Otherwise, entity matches glob include: include
- Otherwise, entity matches glob exclude: exclude
- Otherwise, entity matches domain include: include
- Otherwise: exclude
- Domain and/or glob excludes (no domain and/or glob includes)
- Entity listed in entities include: include
- Otherwise, entity listed in exclude: exclude
- Otherwise, entity matches glob exclude: exclude
- Otherwise, entity matches domain exclude: exclude
- Otherwise: include
- No Domain and/or glob includes or excludes
- Entity listed in entities include: include
- Otherwise: exclude
The following characters can be used in entity globs:
* - The asterisk represents zero, one, or multiple characters
? - The question mark represents zero or one character

