mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Make it possible to list debug traces for a specific automation (#47744)
This commit is contained in:
@@ -11,9 +11,10 @@ import homeassistant.util.dt as dt_util
|
||||
class TraceElement:
|
||||
"""Container for trace data."""
|
||||
|
||||
def __init__(self, variables: TemplateVarsType):
|
||||
def __init__(self, variables: TemplateVarsType, path: str):
|
||||
"""Container for trace data."""
|
||||
self._error: Optional[Exception] = None
|
||||
self.path: str = path
|
||||
self._result: Optional[dict] = None
|
||||
self._timestamp = dt_util.utcnow()
|
||||
|
||||
@@ -42,7 +43,7 @@ class TraceElement:
|
||||
|
||||
def as_dict(self) -> Dict[str, Any]:
|
||||
"""Return dictionary version of this TraceElement."""
|
||||
result: Dict[str, Any] = {"timestamp": self._timestamp}
|
||||
result: Dict[str, Any] = {"path": self.path, "timestamp": self._timestamp}
|
||||
if self._variables:
|
||||
result["changed_variables"] = self._variables
|
||||
if self._error is not None:
|
||||
@@ -129,10 +130,10 @@ def trace_path_get() -> str:
|
||||
|
||||
def trace_append_element(
|
||||
trace_element: TraceElement,
|
||||
path: str,
|
||||
maxlen: Optional[int] = None,
|
||||
) -> None:
|
||||
"""Append a TraceElement to trace[path]."""
|
||||
path = trace_element.path
|
||||
trace = trace_cv.get()
|
||||
if trace is None:
|
||||
trace = {}
|
||||
|
||||
Reference in New Issue
Block a user