Skip to content

Commit 3082007

Browse files
authored
Add required domain to vacuum intents (#133166)
1 parent 3a62221 commit 3082007

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

homeassistant/components/vacuum/intent.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ async def async_setup_intents(hass: HomeAssistant) -> None:
1818
DOMAIN,
1919
SERVICE_START,
2020
description="Starts a vacuum",
21+
required_domains={DOMAIN},
2122
platforms={DOMAIN},
2223
),
2324
)
@@ -28,6 +29,7 @@ async def async_setup_intents(hass: HomeAssistant) -> None:
2829
DOMAIN,
2930
SERVICE_RETURN_TO_BASE,
3031
description="Returns a vacuum to base",
32+
required_domains={DOMAIN},
3133
platforms={DOMAIN},
3234
),
3335
)

tests/components/vacuum/test_intent.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@ async def test_start_vacuum_intent(hass: HomeAssistant) -> None:
3737
assert call.data == {"entity_id": entity_id}
3838

3939

40+
async def test_start_vacuum_without_name(hass: HomeAssistant) -> None:
41+
"""Test starting a vacuum without specifying the name."""
42+
await vacuum_intent.async_setup_intents(hass)
43+
44+
entity_id = f"{DOMAIN}.test_vacuum"
45+
hass.states.async_set(entity_id, STATE_IDLE)
46+
calls = async_mock_service(hass, DOMAIN, SERVICE_START)
47+
48+
response = await intent.async_handle(
49+
hass, "test", vacuum_intent.INTENT_VACUUM_START, {}
50+
)
51+
await hass.async_block_till_done()
52+
53+
assert response.response_type == intent.IntentResponseType.ACTION_DONE
54+
assert len(calls) == 1
55+
call = calls[0]
56+
assert call.domain == DOMAIN
57+
assert call.service == SERVICE_START
58+
assert call.data == {"entity_id": entity_id}
59+
60+
4061
async def test_stop_vacuum_intent(hass: HomeAssistant) -> None:
4162
"""Test HassTurnOff intent for vacuums."""
4263
await vacuum_intent.async_setup_intents(hass)
@@ -59,3 +80,24 @@ async def test_stop_vacuum_intent(hass: HomeAssistant) -> None:
5980
assert call.domain == DOMAIN
6081
assert call.service == SERVICE_RETURN_TO_BASE
6182
assert call.data == {"entity_id": entity_id}
83+
84+
85+
async def test_stop_vacuum_without_name(hass: HomeAssistant) -> None:
86+
"""Test stopping a vacuum without specifying the name."""
87+
await vacuum_intent.async_setup_intents(hass)
88+
89+
entity_id = f"{DOMAIN}.test_vacuum"
90+
hass.states.async_set(entity_id, STATE_IDLE)
91+
calls = async_mock_service(hass, DOMAIN, SERVICE_RETURN_TO_BASE)
92+
93+
response = await intent.async_handle(
94+
hass, "test", vacuum_intent.INTENT_VACUUM_RETURN_TO_BASE, {}
95+
)
96+
await hass.async_block_till_done()
97+
98+
assert response.response_type == intent.IntentResponseType.ACTION_DONE
99+
assert len(calls) == 1
100+
call = calls[0]
101+
assert call.domain == DOMAIN
102+
assert call.service == SERVICE_RETURN_TO_BASE
103+
assert call.data == {"entity_id": entity_id}

0 commit comments

Comments
 (0)