Skip to content

Commit 8618116

Browse files
committed
added silent option to cancel event callback
1 parent 82b018a commit 8618116

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

appdaemon/events.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ async def add_event_callback(
117117
)
118118
return handle
119119

120-
async def cancel_event_callback(self, name, handle):
120+
async def cancel_event_callback(self, name: str, handle: str, *, silent: bool = False):
121121
"""Cancels an event callback.
122122
123123
Args:
124-
name (str): Name of the app or module.
125-
handle: Previously supplied callback handle for the callback.
124+
name (str): Name of the app that registered the callback.
125+
handle (str): Handle produced by ``listen_event()`` when creating the callback.
126126
127127
Returns:
128128
None.
@@ -140,7 +140,7 @@ async def cancel_event_callback(self, name, handle):
140140
if name in self.AD.callbacks.callbacks and self.AD.callbacks.callbacks[name] == {}:
141141
del self.AD.callbacks.callbacks[name]
142142

143-
if not executed:
143+
if not executed and not silent:
144144
self.logger.warning(
145145
f"Invalid callback handle '{handle}' in cancel_event_callback() from app {name}"
146146
)

0 commit comments

Comments
 (0)