mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Fix time pattern listener firing a few microseconds early (#39281)
This commit is contained in:
parent
51a63c1fc4
commit
715fe4eef8
@ -996,13 +996,19 @@ def async_track_utc_time_change(
|
|||||||
|
|
||||||
calculate_next(now + timedelta(seconds=1))
|
calculate_next(now + timedelta(seconds=1))
|
||||||
|
|
||||||
|
# We always get time.time() first to avoid time.time()
|
||||||
|
# ticking forward after fetching hass.loop.time()
|
||||||
|
# and callback being scheduled a few microseconds early
|
||||||
cancel_callback = hass.loop.call_at(
|
cancel_callback = hass.loop.call_at(
|
||||||
hass.loop.time() + next_time.timestamp() - time.time(),
|
-time.time() + hass.loop.time() + next_time.timestamp(),
|
||||||
pattern_time_change_listener,
|
pattern_time_change_listener,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# We always get time.time() first to avoid time.time()
|
||||||
|
# ticking forward after fetching hass.loop.time()
|
||||||
|
# and callback being scheduled a few microseconds early
|
||||||
cancel_callback = hass.loop.call_at(
|
cancel_callback = hass.loop.call_at(
|
||||||
hass.loop.time() + next_time.timestamp() - time.time(),
|
-time.time() + hass.loop.time() + next_time.timestamp(),
|
||||||
pattern_time_change_listener,
|
pattern_time_change_listener,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user