弃用 @bind_hass 和 hass.components 的使用
自 Home Assistant 2024.3 起,我们弃用 @bind_hass decorator 的使用,因此也弃用 hass.components 的使用。
使用 hass.components 会在日志中发出警告。
建议自定义集成的作者在 Home Assistant 2024.9 之前更新代码,以避免任何问题。
自 Home Assistant 2024.9 起,@bind_hass decorator 和 hass.components 将被移除,并将不再可用。
使用 @bind_hass decorator
使用 @bind_hass decorator 的集成应进行更新,移除该 decorator,并将 hass 对象作为第一个参数传递给函数:
新示例
旧示例
使用 hass.components
使用 hass.components 的集成应进行更新,从 integration 包中直接 import 函数和类,并将 hass 对象作为第一个参数传递。
请记住在 manifest.json 的 dependencies 下包含所 import 的组件。

