YouTube
YouTube 集成可让您将 YouTube 频道连接到 Home Assistant。
对于您添加的每个频道,此集成都将创建以下传感器:
- 观看次数
- 订阅者数量
- 最新上传的视频
前提条件
要配置此集成,您需要拥有一个 YouTube 频道。 如需了解如何创建频道,请参阅 YouTube 文档。
您需要配置开发者凭据,以允许 Home Assistant 访问您的 Google 账户。 这些凭据与 Nest、Google Mail 和 Google Sheets 使用的是同一组。 它们与 Google Calendar 使用的凭据不同。
场景 1:您已有凭据
这种情况下,您只需要启用 API:
- 前往 Google Developers Console 中的 YouTube Data API v3。
- 确认项目后,为 API 选择 启用。
- 继续按照配置部分中的步骤操作。
场景 2:您尚未设置凭据
这种情况下,您需要先生成客户端密钥:
生成客户端编号和客户端密钥
本节说明如何在 Google Developers Console 中生成客户端 ID 和客户端密钥。
- First, go to the Google Developers Console to enable YouTube Data API v3.
- Select Create project, enter a project name, and select Create.
- Enable YouTube Data API v3.
- Navigate to APIs & Services > Credentials.
- In the left sidebar, select OAuth consent screen.
- Complete the app information and create the consent screen.
- Under Publishing status > Testing, select Publish app.
- In the left sidebar, select Clients and create a Web application client.
- Add
https://my.home-assistant.io/redirect/oauthto Authorized redirect URIs and select Create. - Copy the Client ID and Client Secret before closing the dialog.
配置
此集成可通过 UI 配置。前往 设置 > 设备与服务 添加。
随后,集成设置流程会引导您输入应用程序凭据,并授权 Home Assistant 连接到 YouTube。
账户授权步骤
- Continue through the steps of selecting the account you want to authorize.
- You may get a message telling you that the app has not been verified and that you need to acknowledge it to proceed.
- Review what Home Assistant is requesting access to, then select Continue.
- When the page displays Link account to Home Assistant?, confirm that Your instance URL is correct, then select Link Account.
- You can close the window and return to Home Assistant, where you should see a Success! message.
删除集成
此集成遵循标准删除流程,无需额外步骤。
从 Home Assistant 中移除集成实例
- 前往 设置 > 设备与服务,然后选择该集成卡片。
- 在设备列表中,选择您要删除的集成实例。
- 在该条目旁边,选择三点菜单
,然后选择 删除。

