LLM: skip local handling of search media query (#154496)

This commit is contained in:
Paulus Schoutsen
2025-10-17 09:18:47 -04:00
committed by GitHub
parent e4071bd305
commit 3990fc6ab2
5 changed files with 44 additions and 12 deletions
@@ -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
@@ -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,
@@ -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,
@@ -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__)
@@ -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(