Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow empty trigger sentence responses in conversations #131849

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/assist_pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ async def recognize_intent(
:= await conversation.async_handle_sentence_triggers(
self.hass, user_input
)
):
) is not None:
# Sentence trigger matched
trigger_response = intent.IntentResponse(
self.pipeline.conversation_language
Expand Down
10 changes: 7 additions & 3 deletions tests/components/conversation/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,17 @@ async def test_prepare_agent(
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."""
assert await async_setup_component(hass, "homeassistant", {})
assert await async_setup_component(hass, "conversation", {})

response_template = "response {{ trigger.device_id }}"
assert await async_setup_component(
hass,
"automation",
Expand All @@ -260,7 +265,6 @@ async def test_async_handle_sentence_triggers(hass: HomeAssistant) -> None:

# Device id will be available in response template
device_id = "1234"
expected_response = f"response {device_id}"
actual_response = await async_handle_sentence_triggers(
hass,
ConversationInput(
Expand Down