reorg
This commit is contained in:
@@ -1,11 +1,8 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from cgitb import handler
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from logging import Logger
|
from logging import Logger
|
||||||
from typing import TYPE_CHECKING, Any, Literal
|
from typing import TYPE_CHECKING, Any, Literal
|
||||||
|
|
||||||
import appdaemon.utils as utils
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from appdaemon.appdaemon import AppDaemon
|
from appdaemon.appdaemon import AppDaemon
|
||||||
|
|
||||||
@@ -50,12 +47,14 @@ class Callbacks:
|
|||||||
await self.AD.state.remove_entity("admin", f"{callback['type']}_callback.{handle}")
|
await self.AD.state.remove_entity("admin", f"{callback['type']}_callback.{handle}")
|
||||||
return True
|
return True
|
||||||
elif not silent:
|
elif not silent:
|
||||||
self.logger.warning(f"Invalid callback handle '{handle}' in cancel_callback()")
|
self.logger.warning(f"Invalid callback handle '{
|
||||||
|
handle}' in cancel_callback()")
|
||||||
|
|
||||||
async def cancel_all_callbacks(self, name: str, silent: bool = False):
|
async def cancel_all_callbacks(self, name: str, silent: bool = False):
|
||||||
async with self.callbacks_lock:
|
async with self.callbacks_lock:
|
||||||
if callbacks := self.callbacks.pop(name, False):
|
if callbacks := self.callbacks.pop(name, False):
|
||||||
self.logger.debug("Clearing %s callbacks for %s", len(callbacks), name)
|
self.logger.debug(
|
||||||
|
"Clearing %s callbacks for %s", len(callbacks), name)
|
||||||
for handle, cb_info in callbacks.items():
|
for handle, cb_info in callbacks.items():
|
||||||
cb_type: Literal["event", "state", "log"] = cb_info['type']
|
cb_type: Literal["event", "state", "log"] = cb_info['type']
|
||||||
await self.AD.state.remove_entity("admin", f"{cb_type}_callback.{handle}")
|
await self.AD.state.remove_entity("admin", f"{cb_type}_callback.{handle}")
|
||||||
Reference in New Issue
Block a user