mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
parent
c15f7f304f
commit
87fc27eeae
@ -1259,6 +1259,14 @@ class Context:
|
||||
"""Compare contexts."""
|
||||
return isinstance(other, Context) and self.id == other.id
|
||||
|
||||
def __copy__(self) -> Context:
|
||||
"""Create a shallow copy of this context."""
|
||||
return Context(user_id=self.user_id, parent_id=self.parent_id, id=self.id)
|
||||
|
||||
def __deepcopy__(self, memo: dict[int, Any]) -> Context:
|
||||
"""Create a deep copy of this context."""
|
||||
return Context(user_id=self.user_id, parent_id=self.parent_id, id=self.id)
|
||||
|
||||
@cached_property
|
||||
def _as_dict(self) -> dict[str, str | None]:
|
||||
"""Return a dictionary representation of the context.
|
||||
|
@ -90,6 +90,7 @@ async def test_assist_api(hass: HomeAssistant) -> None:
|
||||
assert str(tool) == "<IntentTool - test_intent>"
|
||||
|
||||
test_context = Context()
|
||||
assert test_context.json_fragment # To reproduce an error case in tracing
|
||||
intent_response = intent.IntentResponse("*")
|
||||
intent_response.matched_states = [State("light.matched", "on")]
|
||||
intent_response.unmatched_states = [State("light.unmatched", "on")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user