更新实体
Update entity 是一种指示 device 或 service 是否有 update 可用的 entity。 它可以是任何 update,包括 device(如 light bulb 或 router)的 firmware update,或 apps(以前称为 add-ons)或 containers 的 software updates。
它可用于:
- 提供 device 或 service 是否有 update 可用的指示器。
- 提供一种 install method,允许安装 update 或 software 的特定 version。
- 允许在安装新 update 之前提供 backup。
属性
Properties 应该只从内存返回信息,而不要执行 I/O(如网络请求)。请实现 update() 或 async_update() 来获取数据。
其他在所有 entity 中通用的 properties(如 device_class、entity_category、icon、name 等)仍然适用。
支持的功能
Supported features 通过使用 UpdateEntityFeature enum 中的值来定义。
方法
比较版本
在需要 override 默认 version comparison logic 时应实现此 method。 以下是一个示例:
它允许 developers 指定自定义逻辑来确定一个 version 是否比另一个更新。首次尝试应基于 AwesomeVersion library 提供的 strategies。
安装
实现此 method 使用户可以直接从 Home Assistant 内安装提供的 update。
此 method 要求设置 UpdateEntityFeature.INSTALL。此外,如果此集成支持安装特定 version 或能够在开始 update installation process 之前创建 backup,则可以分别设置 UpdateEntityFeature.SPECIFIC_VERSION 和
UpdateEntityFeature.BACKUP。
发布说明
实现此 method 使用户可以在安装 update 之前,在 Home Assistant Frontend 的 more-info dialog 中查看完整的 release notes。
返回的字符串可以包含 markdown,frontend 会正确格式化它。
此 method 要求设置 UpdateEntityFeature.RELEASE_NOTES。
可用的设备类型
选项性地指定 entity 的类型。

