mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Bugfix error on automation reload (#4823)
This commit is contained in:
parent
f78246e686
commit
0bf9e6d4bb
@ -64,10 +64,19 @@ def async_trigger(hass, config, action):
|
|||||||
call_action()
|
call_action()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@callback
|
||||||
|
def clear_listener():
|
||||||
|
"""Clear all unsub listener."""
|
||||||
|
nonlocal async_remove_state_for_cancel
|
||||||
|
nonlocal async_remove_state_for_listener
|
||||||
|
async_remove_state_for_listener = None
|
||||||
|
async_remove_state_for_cancel = None
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def state_for_listener(now):
|
def state_for_listener(now):
|
||||||
"""Fire on state changes after a delay and calls action."""
|
"""Fire on state changes after a delay and calls action."""
|
||||||
async_remove_state_for_cancel()
|
async_remove_state_for_cancel()
|
||||||
|
clear_listener()
|
||||||
call_action()
|
call_action()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
@ -77,6 +86,7 @@ def async_trigger(hass, config, action):
|
|||||||
return
|
return
|
||||||
async_remove_state_for_listener()
|
async_remove_state_for_listener()
|
||||||
async_remove_state_for_cancel()
|
async_remove_state_for_cancel()
|
||||||
|
clear_listener()
|
||||||
|
|
||||||
async_remove_state_for_listener = async_track_point_in_utc_time(
|
async_remove_state_for_listener = async_track_point_in_utc_time(
|
||||||
hass, state_for_listener, dt_util.utcnow() + time_delta)
|
hass, state_for_listener, dt_util.utcnow() + time_delta)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user