diff --git a/homeassistant/components/assist_pipeline/pipeline.py b/homeassistant/components/assist_pipeline/pipeline.py index 764a036bb35..f71e3681f5b 100644 --- a/homeassistant/components/assist_pipeline/pipeline.py +++ b/homeassistant/components/assist_pipeline/pipeline.py @@ -19,7 +19,14 @@ import wave import hass_nabucasa import voluptuous as vol -from homeassistant.components import conversation, stt, tts, wake_word, websocket_api +from homeassistant.components import ( + conversation, + media_player, + stt, + tts, + wake_word, + websocket_api, +) from homeassistant.const import ATTR_SUPPORTED_FEATURES, MATCH_ALL from homeassistant.core import Context, HomeAssistant, callback from homeassistant.exceptions import HomeAssistantError @@ -130,7 +137,10 @@ SAVE_DELAY = 10 @callback def _async_local_fallback_intent_filter(result: RecognizeResult) -> bool: """Filter out intents that are not local fallback.""" - return result.intent.name in (intent.INTENT_GET_STATE) + return result.intent.name in ( + intent.INTENT_GET_STATE, + media_player.INTENT_MEDIA_SEARCH_AND_PLAY, + ) @callback diff --git a/homeassistant/components/media_player/__init__.py b/homeassistant/components/media_player/__init__.py index da773a7eb29..ea9dd0adcfd 100644 --- a/homeassistant/components/media_player/__init__.py +++ b/homeassistant/components/media_player/__init__.py @@ -104,6 +104,7 @@ from .const import ( # noqa: F401 ATTR_SOUND_MODE_LIST, CONTENT_AUTH_EXPIRY_TIME, DOMAIN, + INTENT_MEDIA_SEARCH_AND_PLAY, REPEAT_MODES, SERVICE_BROWSE_MEDIA, SERVICE_CLEAR_PLAYLIST, diff --git a/homeassistant/components/media_player/const.py b/homeassistant/components/media_player/const.py index 990acb4c497..4415b9ab7d1 100644 --- a/homeassistant/components/media_player/const.py +++ b/homeassistant/components/media_player/const.py @@ -43,6 +43,16 @@ ATTR_SOUND_MODE_LIST = "sound_mode_list" DOMAIN = "media_player" +INTENT_MEDIA_PAUSE = "HassMediaPause" +INTENT_MEDIA_UNPAUSE = "HassMediaUnpause" +INTENT_MEDIA_NEXT = "HassMediaNext" +INTENT_MEDIA_PREVIOUS = "HassMediaPrevious" +INTENT_PLAYER_MUTE = "HassMediaPlayerMute" +INTENT_PLAYER_UNMUTE = "HassMediaPlayerUnmute" +INTENT_SET_VOLUME = "HassSetVolume" +INTENT_SET_VOLUME_RELATIVE = "HassSetVolumeRelative" +INTENT_MEDIA_SEARCH_AND_PLAY = "HassMediaSearchAndPlay" + class MediaPlayerState( StrEnum, diff --git a/homeassistant/components/media_player/intent.py b/homeassistant/components/media_player/intent.py index 2cca51af4ad..c3ae6615b81 100644 --- a/homeassistant/components/media_player/intent.py +++ b/homeassistant/components/media_player/intent.py @@ -30,6 +30,15 @@ from .const import ( ATTR_MEDIA_VOLUME_LEVEL, ATTR_MEDIA_VOLUME_MUTED, DOMAIN, + INTENT_MEDIA_NEXT, + INTENT_MEDIA_PAUSE, + INTENT_MEDIA_PREVIOUS, + INTENT_MEDIA_SEARCH_AND_PLAY, + INTENT_MEDIA_UNPAUSE, + INTENT_PLAYER_MUTE, + INTENT_PLAYER_UNMUTE, + INTENT_SET_VOLUME, + INTENT_SET_VOLUME_RELATIVE, SERVICE_PLAY_MEDIA, SERVICE_SEARCH_MEDIA, MediaClass, @@ -37,16 +46,6 @@ from .const import ( MediaPlayerState, ) -INTENT_MEDIA_PAUSE = "HassMediaPause" -INTENT_MEDIA_UNPAUSE = "HassMediaUnpause" -INTENT_MEDIA_NEXT = "HassMediaNext" -INTENT_MEDIA_PREVIOUS = "HassMediaPrevious" -INTENT_PLAYER_MUTE = "HassMediaPlayerMute" -INTENT_PLAYER_UNMUTE = "HassMediaPlayerUnmute" -INTENT_SET_VOLUME = "HassSetVolume" -INTENT_SET_VOLUME_RELATIVE = "HassSetVolumeRelative" -INTENT_MEDIA_SEARCH_AND_PLAY = "HassMediaSearchAndPlay" - _LOGGER = logging.getLogger(__name__) diff --git a/tests/components/assist_pipeline/test_pipeline.py b/tests/components/assist_pipeline/test_pipeline.py index fc2d6d18a6a..b2ee4e9c5e3 100644 --- a/tests/components/assist_pipeline/test_pipeline.py +++ b/tests/components/assist_pipeline/test_pipeline.py @@ -12,6 +12,7 @@ import voluptuous as vol from homeassistant.components import ( assist_pipeline, conversation, + media_player, media_source, stt, tts, @@ -682,6 +683,17 @@ def test_fallback_intent_filter() -> None: ) is True ) + assert ( + _async_local_fallback_intent_filter( + RecognizeResult( + intent=Intent(media_player.INTENT_MEDIA_SEARCH_AND_PLAY), + intent_data=IntentData([]), + entities={}, + entities_list=[], + ) + ) + is True + ) assert ( _async_local_fallback_intent_filter( RecognizeResult(