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/blog/2021-04-09-astral-2.2.md.

Astral 升级到 2.2 版本

我们最近合并了一个 pull request,将 Home Assistant Core 中使用的 astral 库版本升级到 2.2。这将随 Home Assistant 2021.5 发布。这是 Astral 的一个 major 版本 bump,包含一些 breaking changes,这导致我们更新了依赖 astral 的内置 helpers 和 integrations。这导致我们的 sun helpers 出现了一些 breaking changes。

维护直接使用 sun helpers 或 astral 库的 integrations 的 custom integration 作者,应审查 breaking changes,并在需要时更新他们的 custom integrations。

Sun helper 已更改 get_astral_locationget_location_astral_event_next 的签名,以包含一个 elevation 参数。此外,get_astral_location 的返回值已更改为包含 elevation 的 tuple。

@callback
@bind_hass
def get_astral_location(
    hass: HomeAssistant,
) -> tuple[astral.location.Location, astral.Elevation]:
    """Get an astral location for the current Home Assistant configuration."""

@callback
def get_location_astral_event_next(
    location: astral.Location,
    location: astral.location.Location,
    elevation: astral.Elevation,
    event: str,
    utc_point_in_time: datetime.datetime | None = None,
    offset: datetime.timedelta | None = None,
) -> datetime.datetime:
    """Calculate the next specified solar event."""

详情请查看 astral 的 changelog