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/core/entity/time.md.

时间实体

time 是一种允许用户向集成输入时间的实体。从 homeassistant.components.time.TimeEntity 派生实体平台。

属性

Tip

属性应始终仅返回内存中的信息,而不是执行 I/O(如网络请求)。实现 update()async_update() 来获取数据。

名称类型默认值描述
native_valuetime | NoneNone时间的值。

所有实体共有的其他属性(如 iconname 等)也适用。

方法

设置值

当用户或自动化想要更新值时调用。

class MyTime(TimeEntity):
    # 实现以下方法之一。

    def set_value(self, value: time) -> None:
        """Update the current value."""

    async def async_set_value(self, value: time) -> None:
        """Update the current value."""