diff --git a/homeassistant/components/script/__init__.py b/homeassistant/components/script/__init__.py index f8d41db0e11..8530aa3b04c 100644 --- a/homeassistant/components/script/__init__.py +++ b/homeassistant/components/script/__init__.py @@ -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: diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index 715a960de5d..a1dc22ea4a1 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -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