Mark scripts as response optional, make it always return a response if return_response is set
parent
de24860c87
commit
2ed3693236
|
@ -608,7 +608,7 @@ class ScriptEntity(BaseScriptEntity, RestoreEntity):
|
|||
variables=service.data, context=service.context, wait=True
|
||||
)
|
||||
if service.return_response:
|
||||
return response
|
||||
return response or {}
|
||||
return None
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
|
|
|
@ -678,6 +678,13 @@ def async_set_service_schema(
|
|||
if "target" in schema:
|
||||
description["target"] = schema["target"]
|
||||
|
||||
if (
|
||||
response := hass.services.supports_response(domain, service)
|
||||
) != SupportsResponse.NONE:
|
||||
description["response"] = {
|
||||
"optional": response == SupportsResponse.OPTIONAL,
|
||||
}
|
||||
|
||||
hass.data.pop(ALL_SERVICE_DESCRIPTIONS_CACHE, None)
|
||||
hass.data[SERVICE_DESCRIPTION_CACHE][(domain, service)] = description
|
||||
|
||||
|
|
Loading…
Reference in New Issue