Skip to content

Commit 3990fc6

Browse files
authored
LLM: skip local handling of search media query (home-assistant#154496)
1 parent e4071bd commit 3990fc6

File tree

5 files changed

+44
-12
lines changed

5 files changed

+44
-12
lines changed

homeassistant/components/assist_pipeline/pipeline.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@
1919
import hass_nabucasa
2020
import voluptuous as vol
2121

22-
from homeassistant.components import conversation, stt, tts, wake_word, websocket_api
22+
from homeassistant.components import (
23+
conversation,
24+
media_player,
25+
stt,
26+
tts,
27+
wake_word,
28+
websocket_api,
29+
)
2330
from homeassistant.const import ATTR_SUPPORTED_FEATURES, MATCH_ALL
2431
from homeassistant.core import Context, HomeAssistant, callback
2532
from homeassistant.exceptions import HomeAssistantError
@@ -130,7 +137,10 @@ def validate_language(data: dict[str, Any]) -> Any:
130137
@callback
131138
def _async_local_fallback_intent_filter(result: RecognizeResult) -> bool:
132139
"""Filter out intents that are not local fallback."""
133-
return result.intent.name in (intent.INTENT_GET_STATE)
140+
return result.intent.name in (
141+
intent.INTENT_GET_STATE,
142+
media_player.INTENT_MEDIA_SEARCH_AND_PLAY,
143+
)
134144

135145

136146
@callback

homeassistant/components/media_player/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
ATTR_SOUND_MODE_LIST,
105105
CONTENT_AUTH_EXPIRY_TIME,
106106
DOMAIN,
107+
INTENT_MEDIA_SEARCH_AND_PLAY,
107108
REPEAT_MODES,
108109
SERVICE_BROWSE_MEDIA,
109110
SERVICE_CLEAR_PLAYLIST,

homeassistant/components/media_player/const.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@
4343

4444
DOMAIN = "media_player"
4545

46+
INTENT_MEDIA_PAUSE = "HassMediaPause"
47+
INTENT_MEDIA_UNPAUSE = "HassMediaUnpause"
48+
INTENT_MEDIA_NEXT = "HassMediaNext"
49+
INTENT_MEDIA_PREVIOUS = "HassMediaPrevious"
50+
INTENT_PLAYER_MUTE = "HassMediaPlayerMute"
51+
INTENT_PLAYER_UNMUTE = "HassMediaPlayerUnmute"
52+
INTENT_SET_VOLUME = "HassSetVolume"
53+
INTENT_SET_VOLUME_RELATIVE = "HassSetVolumeRelative"
54+
INTENT_MEDIA_SEARCH_AND_PLAY = "HassMediaSearchAndPlay"
55+
4656

4757
class MediaPlayerState(
4858
StrEnum,

homeassistant/components/media_player/intent.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,22 @@
3030
ATTR_MEDIA_VOLUME_LEVEL,
3131
ATTR_MEDIA_VOLUME_MUTED,
3232
DOMAIN,
33+
INTENT_MEDIA_NEXT,
34+
INTENT_MEDIA_PAUSE,
35+
INTENT_MEDIA_PREVIOUS,
36+
INTENT_MEDIA_SEARCH_AND_PLAY,
37+
INTENT_MEDIA_UNPAUSE,
38+
INTENT_PLAYER_MUTE,
39+
INTENT_PLAYER_UNMUTE,
40+
INTENT_SET_VOLUME,
41+
INTENT_SET_VOLUME_RELATIVE,
3342
SERVICE_PLAY_MEDIA,
3443
SERVICE_SEARCH_MEDIA,
3544
MediaClass,
3645
MediaPlayerEntityFeature,
3746
MediaPlayerState,
3847
)
3948

40-
INTENT_MEDIA_PAUSE = "HassMediaPause"
41-
INTENT_MEDIA_UNPAUSE = "HassMediaUnpause"
42-
INTENT_MEDIA_NEXT = "HassMediaNext"
43-
INTENT_MEDIA_PREVIOUS = "HassMediaPrevious"
44-
INTENT_PLAYER_MUTE = "HassMediaPlayerMute"
45-
INTENT_PLAYER_UNMUTE = "HassMediaPlayerUnmute"
46-
INTENT_SET_VOLUME = "HassSetVolume"
47-
INTENT_SET_VOLUME_RELATIVE = "HassSetVolumeRelative"
48-
INTENT_MEDIA_SEARCH_AND_PLAY = "HassMediaSearchAndPlay"
49-
5049
_LOGGER = logging.getLogger(__name__)
5150

5251

tests/components/assist_pipeline/test_pipeline.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from homeassistant.components import (
1313
assist_pipeline,
1414
conversation,
15+
media_player,
1516
media_source,
1617
stt,
1718
tts,
@@ -682,6 +683,17 @@ def test_fallback_intent_filter() -> None:
682683
)
683684
is True
684685
)
686+
assert (
687+
_async_local_fallback_intent_filter(
688+
RecognizeResult(
689+
intent=Intent(media_player.INTENT_MEDIA_SEARCH_AND_PLAY),
690+
intent_data=IntentData([]),
691+
entities={},
692+
entities_list=[],
693+
)
694+
)
695+
is True
696+
)
685697
assert (
686698
_async_local_fallback_intent_filter(
687699
RecognizeResult(

0 commit comments

Comments
 (0)