mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 09:23:17 -04:00
Add required_domains to the cover open/close intents (#181892)
This commit is contained in:
@@ -18,6 +18,7 @@ async def async_setup_intents(hass: HomeAssistant) -> None:
|
||||
SERVICE_OPEN_COVER,
|
||||
description="Opens a cover",
|
||||
platforms={DOMAIN},
|
||||
required_domains={DOMAIN},
|
||||
device_classes={CoverDeviceClass},
|
||||
),
|
||||
)
|
||||
@@ -29,6 +30,7 @@ async def async_setup_intents(hass: HomeAssistant) -> None:
|
||||
SERVICE_CLOSE_COVER,
|
||||
description="Closes a cover",
|
||||
platforms={DOMAIN},
|
||||
required_domains={DOMAIN},
|
||||
device_classes={CoverDeviceClass},
|
||||
),
|
||||
)
|
||||
|
||||
@@ -83,6 +83,32 @@ async def test_close_cover_intent(hass: HomeAssistant, slots: dict[str, Any]) ->
|
||||
assert call.data == {"entity_id": f"{DOMAIN}.garage_door"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("intent_type", "initial_state"),
|
||||
[
|
||||
(cover_intent.INTENT_OPEN_COVER, "off"),
|
||||
(cover_intent.INTENT_CLOSE_COVER, "on"),
|
||||
],
|
||||
)
|
||||
async def test_cover_intent_does_not_match_other_domains(
|
||||
hass: HomeAssistant, intent_type: str, initial_state: str
|
||||
) -> None:
|
||||
"""Test HassOpenCover/HassCloseCover do not match an entity of another domain."""
|
||||
await cover_intent.async_setup_intents(hass)
|
||||
|
||||
hass.states.async_set("light.garage_door", initial_state)
|
||||
|
||||
with pytest.raises(intent.MatchFailedError) as err:
|
||||
await intent.async_handle(
|
||||
hass,
|
||||
"test",
|
||||
intent_type,
|
||||
{"name": {"value": "garage door"}},
|
||||
)
|
||||
|
||||
assert err.value.result.no_match_reason == intent.MatchFailedReason.DOMAIN
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("slots"),
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user