mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Allow empty trigger sentence responses in conversations (#131849)
allow empty trigger sentence responses
This commit is contained in:
parent
8862c5c4d8
commit
1a9ab07742
@ -1040,7 +1040,7 @@ class PipelineRun:
|
|||||||
:= await conversation.async_handle_sentence_triggers(
|
:= await conversation.async_handle_sentence_triggers(
|
||||||
self.hass, user_input
|
self.hass, user_input
|
||||||
)
|
)
|
||||||
):
|
) is not None:
|
||||||
# Sentence trigger matched
|
# Sentence trigger matched
|
||||||
trigger_response = intent.IntentResponse(
|
trigger_response = intent.IntentResponse(
|
||||||
self.pipeline.conversation_language
|
self.pipeline.conversation_language
|
||||||
|
@ -236,12 +236,17 @@ async def test_prepare_agent(
|
|||||||
assert len(mock_prepare.mock_calls) == 1
|
assert len(mock_prepare.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_async_handle_sentence_triggers(hass: HomeAssistant) -> None:
|
@pytest.mark.parametrize(
|
||||||
|
("response_template", "expected_response"),
|
||||||
|
[("response {{ trigger.device_id }}", "response 1234"), ("", "")],
|
||||||
|
)
|
||||||
|
async def test_async_handle_sentence_triggers(
|
||||||
|
hass: HomeAssistant, response_template: str, expected_response: str
|
||||||
|
) -> None:
|
||||||
"""Test handling sentence triggers with async_handle_sentence_triggers."""
|
"""Test handling sentence triggers with async_handle_sentence_triggers."""
|
||||||
assert await async_setup_component(hass, "homeassistant", {})
|
assert await async_setup_component(hass, "homeassistant", {})
|
||||||
assert await async_setup_component(hass, "conversation", {})
|
assert await async_setup_component(hass, "conversation", {})
|
||||||
|
|
||||||
response_template = "response {{ trigger.device_id }}"
|
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
"automation",
|
"automation",
|
||||||
@ -260,7 +265,6 @@ async def test_async_handle_sentence_triggers(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
# Device id will be available in response template
|
# Device id will be available in response template
|
||||||
device_id = "1234"
|
device_id = "1234"
|
||||||
expected_response = f"response {device_id}"
|
|
||||||
actual_response = await async_handle_sentence_triggers(
|
actual_response = await async_handle_sentence_triggers(
|
||||||
hass,
|
hass,
|
||||||
ConversationInput(
|
ConversationInput(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user