mirror of
https://github.com/home-assistant/core.git
synced 2025-08-01 03:35:09 +02:00
Quiet the chatty sun.sun (#23832)
* Split up method to allow caching event * Lower frequency of updates. * Code review patches. * Minor changes to test * Skip end of period at fixed multiple of delta. Improved documentation.
This commit is contained in:
@@ -43,9 +43,18 @@ def get_astral_event_next(
|
||||
utc_point_in_time: Optional[datetime.datetime] = None,
|
||||
offset: Optional[datetime.timedelta] = None) -> datetime.datetime:
|
||||
"""Calculate the next specified solar event."""
|
||||
from astral import AstralError
|
||||
|
||||
location = get_astral_location(hass)
|
||||
return get_location_astral_event_next(
|
||||
location, event, utc_point_in_time, offset)
|
||||
|
||||
|
||||
@callback
|
||||
def get_location_astral_event_next(
|
||||
location: 'astral.Location', event: str,
|
||||
utc_point_in_time: Optional[datetime.datetime] = None,
|
||||
offset: Optional[datetime.timedelta] = None) -> datetime.datetime:
|
||||
"""Calculate the next specified solar event."""
|
||||
from astral import AstralError
|
||||
|
||||
if offset is None:
|
||||
offset = datetime.timedelta()
|
||||
|
Reference in New Issue
Block a user