diff --git a/homeassistant/components/cover/intent.py b/homeassistant/components/cover/intent.py index 2915b8425d3c..4cfe7d7c514e 100644 --- a/homeassistant/components/cover/intent.py +++ b/homeassistant/components/cover/intent.py @@ -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}, ), ) diff --git a/tests/components/cover/test_intent.py b/tests/components/cover/test_intent.py index 1af3d5120012..a8ec75038c0c 100644 --- a/tests/components/cover/test_intent.py +++ b/tests/components/cover/test_intent.py @@ -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"), [