From 2df0f4995ec37db40cc4d01afbd2140baeb3791f Mon Sep 17 00:00:00 2001 From: Daniel Lashua Date: Thu, 29 Oct 2020 04:10:11 -0500 Subject: [PATCH] allow context on short form service calls --- custom_components/pyscript/function.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/custom_components/pyscript/function.py b/custom_components/pyscript/function.py index da33a9b..ab6fff2 100644 --- a/custom_components/pyscript/function.py +++ b/custom_components/pyscript/function.py @@ -239,7 +239,12 @@ def get(cls, name): return None async def service_call(*args, **kwargs): - await cls.hass.services.async_call(domain, service, kwargs) + if "context" in kwargs and isinstance(kwargs["context"], Context): + context = kwargs["context"] + del kwargs["context"] + await cls.hass.services.async_call(domain, service, kwargs, context=context) + else: + await cls.hass.services.async_call(domain, service, kwargs) return service_call