Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/intent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ async def post(self, request: web.Request, data: dict[str, Any]) -> web.Response
intent_result = await intent.async_handle(
hass, DOMAIN, intent_name, slots, "", self.context(request)
)
except intent.IntentHandleError as err:
except (intent.IntentHandleError, intent.MatchFailedError) as err:
intent_result = intent.IntentResponse(language=language)
intent_result.async_set_speech(str(err))

Expand Down
26 changes: 26 additions & 0 deletions tests/components/intent/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,32 @@ async def async_handle(self, intent_obj):
}


async def test_http_handle_intent_match_failure(
hass: HomeAssistant, hass_client: ClientSessionGenerator, hass_admin_user: MockUser
) -> None:
"""Test handle intent match failure via HTTP API."""

assert await async_setup_component(hass, "intent", {})

hass.states.async_set(
"cover.garage_door_1", "closed", {ATTR_FRIENDLY_NAME: "Garage Door"}
)
hass.states.async_set(
"cover.garage_door_2", "closed", {ATTR_FRIENDLY_NAME: "Garage Door"}
)
async_mock_service(hass, "cover", SERVICE_OPEN_COVER)

client = await hass_client()
resp = await client.post(
"/api/intent/handle",
json={"name": "HassTurnOn", "data": {"name": "Garage Door"}},
)
assert resp.status == 200
data = await resp.json()

assert "DUPLICATE_NAME" in data["speech"]["plain"]["speech"]


async def test_cover_intents_loading(hass: HomeAssistant) -> None:
"""Test Cover Intents Loading."""
assert await async_setup_component(hass, "intent", {})
Expand Down
Loading