35 lines
1.7 KiB
Markdown
35 lines
1.7 KiB
Markdown
---
|
|
author: Martin Hjelmare
|
|
authorURL: https://github.com/MartinHjelmare
|
|
authorTwitter: MartinHjelmare
|
|
title: Astral upgraded to version 2.2
|
|
---
|
|
|
|
We recently merged a [pull request](https://github.com/home-assistant/core/pull/48573) to upgrade the astral library version used in Home Assistant Core to version 2.2. This will be released with Home Assistant 2021.5. This is a major version bump of Astral which includes some breaking changes, this caused us to update our built-in helpers and integrations that depend on astral. This has resulted in a couple of breaking changes to our sun helpers.
|
|
|
|
Custom integration authors that are maintaining integrations that use the sun helpers or the astral library directly, should review the breaking changes and update their custom integrations if needed.
|
|
|
|
The sun helper has changed its signature for `get_astral_location` and `get_location_astral_event_next` to include an `elevation` parameter. Also the return value of `get_astral_location` has changed to a tuple including elevation.
|
|
|
|
```py
|
|
@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."""
|
|
```
|
|
|
|
Please see the [changelog of `astral`](https://github.com/sffjunkie/astral/blob/master/ChangeLog.md#22---2020-05-20) for further details.
|