For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /developers/creating_platform_index.md.

集成平台

Home Assistant 有各种内置的 integrations,它们对 device types 进行了抽象。有 lightsswitchescoversclimate devices,以及更多。你的 integration 可以通过创建 platform 来接入这些 integrations。对于你要集成的每一个 integration,你都需要一个 platform。

要创建 platform,你需要创建一个文件,文件名为你为其构建 platform 的 integration 的 domain name。因此,如果你正在构建一个 light,你会在你的 integration folder 中添加一个新文件 light.py

我们创建了两个示例 integrations,可以让你了解其工作原理:

与 devices 交互

Home Assistant 的一条规则是 integration 永远不要直接与 devices 交互。相反,它应该与一个第三方 Python 3 library 交互。这样,Home Assistant 可以与 Python 社区共享代码,并保持项目的可维护性。

一旦你的 Python library 准备就绪并发布到 PyPI,将其添加到 manifest 中。现在,是时候实现你为其创建 platform 的 integration 所提供的 Entity base class 了。

entity index 中找到你的 integration,以查看可以实现的 methods 和 properties。