Store automation and script traces (#56894)

* Store automation and script traces

* Pylint

* Deduplicate code

* Fix issues when no stored traces are available

* Store serialized data for restored traces

* Update WS API

* Update test

* Restore context

* Improve tests

* Add new test files

* Rename restore_traces to async_restore_traces

* Refactor trace.websocket_api

* Defer loading stored traces

* Lint

* Revert refactoring which is no longer needed

* Correct order when restoring traces

* Apply suggestion from code review

* Improve test coverage

* Apply suggestions from code review
This commit is contained in:
Erik Montnemery 2021-10-19 10:23:23 +02:00 committed by GitHub
parent 29c062fcc4
commit 961ee717ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 1256 additions and 191 deletions

View file

@ -9,20 +9,13 @@ from homeassistant.components.trace import ActionTrace, async_store_trace
from homeassistant.components.trace.const import CONF_STORED_TRACES
from homeassistant.core import Context, HomeAssistant
from .const import DOMAIN
class ScriptTrace(ActionTrace):
"""Container for automation trace."""
"""Container for script trace."""
def __init__(
self,
item_id: str,
config: dict[str, Any],
blueprint_inputs: dict[str, Any],
context: Context,
) -> None:
"""Container for automation trace."""
key = ("script", item_id)
super().__init__(key, config, blueprint_inputs, context)
_domain = DOMAIN
@contextmanager