Skip to content

Commit

Permalink
Add required domain to vacuum intents (#133166)
Browse files Browse the repository at this point in the history
  • Loading branch information
synesthesiam authored Dec 16, 2024
1 parent 3a62221 commit 3082007
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions homeassistant/components/vacuum/intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async def async_setup_intents(hass: HomeAssistant) -> None:
DOMAIN,
SERVICE_START,
description="Starts a vacuum",
required_domains={DOMAIN},
platforms={DOMAIN},
),
)
Expand All @@ -28,6 +29,7 @@ async def async_setup_intents(hass: HomeAssistant) -> None:
DOMAIN,
SERVICE_RETURN_TO_BASE,
description="Returns a vacuum to base",
required_domains={DOMAIN},
platforms={DOMAIN},
),
)
42 changes: 42 additions & 0 deletions tests/components/vacuum/test_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ async def test_start_vacuum_intent(hass: HomeAssistant) -> None:
assert call.data == {"entity_id": entity_id}


async def test_start_vacuum_without_name(hass: HomeAssistant) -> None:
"""Test starting a vacuum without specifying the name."""
await vacuum_intent.async_setup_intents(hass)

entity_id = f"{DOMAIN}.test_vacuum"
hass.states.async_set(entity_id, STATE_IDLE)
calls = async_mock_service(hass, DOMAIN, SERVICE_START)

response = await intent.async_handle(
hass, "test", vacuum_intent.INTENT_VACUUM_START, {}
)
await hass.async_block_till_done()

assert response.response_type == intent.IntentResponseType.ACTION_DONE
assert len(calls) == 1
call = calls[0]
assert call.domain == DOMAIN
assert call.service == SERVICE_START
assert call.data == {"entity_id": entity_id}


async def test_stop_vacuum_intent(hass: HomeAssistant) -> None:
"""Test HassTurnOff intent for vacuums."""
await vacuum_intent.async_setup_intents(hass)
Expand All @@ -59,3 +80,24 @@ async def test_stop_vacuum_intent(hass: HomeAssistant) -> None:
assert call.domain == DOMAIN
assert call.service == SERVICE_RETURN_TO_BASE
assert call.data == {"entity_id": entity_id}


async def test_stop_vacuum_without_name(hass: HomeAssistant) -> None:
"""Test stopping a vacuum without specifying the name."""
await vacuum_intent.async_setup_intents(hass)

entity_id = f"{DOMAIN}.test_vacuum"
hass.states.async_set(entity_id, STATE_IDLE)
calls = async_mock_service(hass, DOMAIN, SERVICE_RETURN_TO_BASE)

response = await intent.async_handle(
hass, "test", vacuum_intent.INTENT_VACUUM_RETURN_TO_BASE, {}
)
await hass.async_block_till_done()

assert response.response_type == intent.IntentResponseType.ACTION_DONE
assert len(calls) == 1
call = calls[0]
assert call.domain == DOMAIN
assert call.service == SERVICE_RETURN_TO_BASE
assert call.data == {"entity_id": entity_id}

0 comments on commit 3082007

Please sign in to comment.