mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Improve docstrings for time related event helpers (#102839)
* Improve docstrings for time related event helpers * Fix grammar --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
1a1bc05470
commit
9ea97fd8d2
@ -1357,7 +1357,10 @@ def async_track_point_in_time(
|
|||||||
| Callable[[datetime], Coroutine[Any, Any, None] | None],
|
| Callable[[datetime], Coroutine[Any, Any, None] | None],
|
||||||
point_in_time: datetime,
|
point_in_time: datetime,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Add a listener that fires once after a specific point in time."""
|
"""Add a listener that fires once at or after a specific point in time.
|
||||||
|
|
||||||
|
The listener is passed the time it fires in local time.
|
||||||
|
"""
|
||||||
job = (
|
job = (
|
||||||
action
|
action
|
||||||
if isinstance(action, HassJob)
|
if isinstance(action, HassJob)
|
||||||
@ -1388,7 +1391,10 @@ def async_track_point_in_utc_time(
|
|||||||
| Callable[[datetime], Coroutine[Any, Any, None] | None],
|
| Callable[[datetime], Coroutine[Any, Any, None] | None],
|
||||||
point_in_time: datetime,
|
point_in_time: datetime,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Add a listener that fires once after a specific point in UTC time."""
|
"""Add a listener that fires once at or after a specific point in time.
|
||||||
|
|
||||||
|
The listener is passed the time it fires in UTC time.
|
||||||
|
"""
|
||||||
# Ensure point_in_time is UTC
|
# Ensure point_in_time is UTC
|
||||||
utc_point_in_time = dt_util.as_utc(point_in_time)
|
utc_point_in_time = dt_util.as_utc(point_in_time)
|
||||||
expected_fire_timestamp = dt_util.utc_to_timestamp(utc_point_in_time)
|
expected_fire_timestamp = dt_util.utc_to_timestamp(utc_point_in_time)
|
||||||
@ -1450,7 +1456,10 @@ def async_call_at(
|
|||||||
| Callable[[datetime], Coroutine[Any, Any, None] | None],
|
| Callable[[datetime], Coroutine[Any, Any, None] | None],
|
||||||
loop_time: float,
|
loop_time: float,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Add a listener that is called at <loop_time>."""
|
"""Add a listener that fires at or after <loop_time>.
|
||||||
|
|
||||||
|
The listener is passed the time it fires in UTC time.
|
||||||
|
"""
|
||||||
job = (
|
job = (
|
||||||
action
|
action
|
||||||
if isinstance(action, HassJob)
|
if isinstance(action, HassJob)
|
||||||
@ -1467,7 +1476,10 @@ def async_call_later(
|
|||||||
action: HassJob[[datetime], Coroutine[Any, Any, None] | None]
|
action: HassJob[[datetime], Coroutine[Any, Any, None] | None]
|
||||||
| Callable[[datetime], Coroutine[Any, Any, None] | None],
|
| Callable[[datetime], Coroutine[Any, Any, None] | None],
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Add a listener that is called in <delay>."""
|
"""Add a listener that fires at or after <delay>.
|
||||||
|
|
||||||
|
The listener is passed the time it fires in UTC time.
|
||||||
|
"""
|
||||||
if isinstance(delay, timedelta):
|
if isinstance(delay, timedelta):
|
||||||
delay = delay.total_seconds()
|
delay = delay.total_seconds()
|
||||||
job = (
|
job = (
|
||||||
@ -1492,7 +1504,10 @@ def async_track_time_interval(
|
|||||||
name: str | None = None,
|
name: str | None = None,
|
||||||
cancel_on_shutdown: bool | None = None,
|
cancel_on_shutdown: bool | None = None,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Add a listener that fires repetitively at every timedelta interval."""
|
"""Add a listener that fires repetitively at every timedelta interval.
|
||||||
|
|
||||||
|
The listener is passed the time it fires in UTC time.
|
||||||
|
"""
|
||||||
remove: CALLBACK_TYPE
|
remove: CALLBACK_TYPE
|
||||||
interval_listener_job: HassJob[[datetime], None]
|
interval_listener_job: HassJob[[datetime], None]
|
||||||
interval_seconds = interval.total_seconds()
|
interval_seconds = interval.total_seconds()
|
||||||
@ -1636,7 +1651,10 @@ def async_track_utc_time_change(
|
|||||||
second: Any | None = None,
|
second: Any | None = None,
|
||||||
local: bool = False,
|
local: bool = False,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Add a listener that will fire if time matches a pattern."""
|
"""Add a listener that will fire every time the UTC or local time matches a pattern.
|
||||||
|
|
||||||
|
The listener is passed the time it fires in UTC or local time.
|
||||||
|
"""
|
||||||
# We do not have to wrap the function with time pattern matching logic
|
# We do not have to wrap the function with time pattern matching logic
|
||||||
# if no pattern given
|
# if no pattern given
|
||||||
if all(val is None or val == "*" for val in (hour, minute, second)):
|
if all(val is None or val == "*" for val in (hour, minute, second)):
|
||||||
@ -1711,7 +1729,10 @@ def async_track_time_change(
|
|||||||
minute: Any | None = None,
|
minute: Any | None = None,
|
||||||
second: Any | None = None,
|
second: Any | None = None,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Add a listener that will fire if local time matches a pattern."""
|
"""Add a listener that will fire every time the local time matches a pattern.
|
||||||
|
|
||||||
|
The listener is passed the time it fires in local time.
|
||||||
|
"""
|
||||||
return async_track_utc_time_change(hass, action, hour, minute, second, local=True)
|
return async_track_utc_time_change(hass, action, hour, minute, second, local=True)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user