mirror of
https://github.com/home-assistant/core.git
synced 2025-08-07 14:45:09 +02:00
Mark scripts as response optional, make it always return a response if return_response is set
This commit is contained in:
@@ -608,7 +608,7 @@ class ScriptEntity(BaseScriptEntity, RestoreEntity):
|
|||||||
variables=service.data, context=service.context, wait=True
|
variables=service.data, context=service.context, wait=True
|
||||||
)
|
)
|
||||||
if service.return_response:
|
if service.return_response:
|
||||||
return response
|
return response or {}
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
|
@@ -678,6 +678,13 @@ def async_set_service_schema(
|
|||||||
if "target" in schema:
|
if "target" in schema:
|
||||||
description["target"] = schema["target"]
|
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.pop(ALL_SERVICE_DESCRIPTIONS_CACHE, None)
|
||||||
hass.data[SERVICE_DESCRIPTION_CACHE][(domain, service)] = description
|
hass.data[SERVICE_DESCRIPTION_CACHE][(domain, service)] = description
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user