Add required_domains to the cover open/close intents (#181892)

This commit is contained in:
Francesco Sappa
2026-09-19 09:19:53 +02:00
committed by GitHub
parent 3c3841f21a
commit 6bc9bf89f7
2 changed files with 28 additions and 0 deletions
+2
View File
@@ -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},
),
)
+26
View File
@@ -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"),
[