diff --git a/custom_components/mass/intent.py b/custom_components/mass/intent.py index 5627aeb1..483ab55f 100644 --- a/custom_components/mass/intent.py +++ b/custom_components/mass/intent.py @@ -39,7 +39,7 @@ ALBUM_SLOT = "album" RADIO_SLOT = "radio" PLAYLIST_SLOT = "playlist" -DONT_STOP_SLOT = "dont_stop" +RADIO_MODE_SLOT = "radio_mode" SLOT_VALUE = "value" @@ -140,8 +140,7 @@ def __init__(self, hass: HomeAssistant) -> None: vol.Optional(ALBUM_SLOT): cv.string, vol.Optional(RADIO_SLOT): cv.string, vol.Optional(PLAYLIST_SLOT): cv.string, - # TODO: Implement dont_stopß - # vol.Optional(DONT_STOP_SLOT): cv.boolean, + vol.Optional(RADIO_MODE_SLOT): cv.string, } async def async_handle(self, intent_obj: intent.Intent) -> intent.IntentResponse: @@ -159,9 +158,10 @@ async def async_handle(self, intent_obj: intent.Intent) -> intent.IntentResponse album = slots.get(ALBUM_SLOT, {}).get(SLOT_VALUE, "") radio = slots.get(RADIO_SLOT, {}).get(SLOT_VALUE, "") playlist = slots.get(PLAYLIST_SLOT, {}).get(SLOT_VALUE, "") - # TODO: Implement dont_stop - # dont_stop = slots.get(DONT_STOP_SLOT, {}).get(SLOT_VALUE, False) + radio_mode_text = slots.get(RADIO_MODE_SLOT, {}).get(SLOT_VALUE, "") radio_mode = False + if radio_mode_text: + radio_mode = True if track: media_item = await mass.music.get_item_by_name( track, artist=artist, album=album, media_type=MediaType.TRACK @@ -214,6 +214,7 @@ def __init__(self, hass: HomeAssistant) -> None: slot_schema = { vol.Any(NAME_SLOT, AREA_SLOT): cv.string, vol.Optional(QUERY_SLOT): cv.string, + vol.Optional(RADIO_MODE_SLOT): cv.string, } async def async_handle(self, intent_obj: intent.Intent) -> intent.IntentResponse: @@ -227,7 +228,10 @@ async def async_handle(self, intent_obj: intent.Intent) -> intent.IntentResponse mass = config_entry.runtime_data.mass mass_player_id = await self._async_get_matched_mass_player(intent_obj, slots) query = slots.get(QUERY_SLOT, {}).get(SLOT_VALUE) + radio_mode_text = slots.get(RADIO_MODE_SLOT, {}).get(SLOT_VALUE, "") radio_mode = False + if radio_mode_text: + radio_mode = True if query: if not config_entry.data.get(CONF_OPENAI_AGENT_ID): raise intent.IntentHandleError( diff --git a/custom_sentences/en/music_assistant_PlayMediaAssist.yaml b/custom_sentences/en/music_assistant_PlayMediaAssist.yaml index 3c801b22..90afac4b 100644 --- a/custom_sentences/en/music_assistant_PlayMediaAssist.yaml +++ b/custom_sentences/en/music_assistant_PlayMediaAssist.yaml @@ -5,10 +5,10 @@ intents: # TARGET AN AREA - sentences: - - " {artist} in [the ]" - - " {album} [by {artist}] in [the ]" - - " {track} [by {artist}] in [the ]" - - " {playlist} in [the ]" + - " {artist} in [the ] [((with)|(using)) {radio_mode}]" + - " {album} [by {artist}] in [the ] [((with)|(using)) {radio_mode}]" + - " {track} [by {artist}] in [the ] [((with)|(using)) {radio_mode}]" + - " {playlist} in [the ] [((with)|(using)) {radio_mode}]" - " {radio} in [the ]" expansion_rules: play: "((play)|(listen to))" @@ -20,10 +20,10 @@ intents: # TARGET A NAME - sentences: - - " {artist} [the ]{name} []" - - " {album} [by {artist}] [the ]{name} []" - - " {track} [by {artist}] [the ]{name} []" - - " {playlist} [the ]{name} []" + - " {artist} [the ]{name} [] [((with)|(using)) {radio_mode}]" + - " {album} [by {artist}] [the ]{name} [] [((with)|(using)) {radio_mode}]" + - " {track} [by {artist}] [the ]{name} [] [((with)|(using)) {radio_mode}]" + - " {playlist} [the ]{name} [] [((with)|(using)) {radio_mode}]" - " {radio} [the ]{name} []" expansion_rules: play: "((play)|(listen to))" @@ -39,10 +39,10 @@ intents: # CONTEXT AWARNESS - sentences: - - " {artist}" - - " {album} [by {artist}]" - - " {track} [by {artist}]" - - " {playlist}" + - " {artist} [((with)|(using)) {radio_mode}]" + - " {album} [by {artist}] [((with)|(using)) {radio_mode}]" + - " {track} [by {artist}] [((with)|(using)) {radio_mode}]" + - " {playlist} [((with)|(using)) {radio_mode}]" - " {radio}" expansion_rules: play: "((play)|(listen to))" @@ -65,3 +65,6 @@ lists: wildcard: true radio: wildcard: true + radio_mode: + values: + - "radio mode" \ No newline at end of file diff --git a/custom_sentences/en/play_media_on_media_player.yaml b/custom_sentences/en/play_media_on_media_player.yaml index f04d412e..9125983d 100644 --- a/custom_sentences/en/play_media_on_media_player.yaml +++ b/custom_sentences/en/play_media_on_media_player.yaml @@ -3,13 +3,13 @@ intents: MassPlayMediaOnMediaPlayer: data: - sentences: - - " {query};in [the ]" + - " {query};in [the ] [((with)|(using)) {radio_mode}]" expansion_rules: play: "((play)|(listen to))" player_devices: "((speaker)|([media] player))" "on": "(on|using)" - sentences: - - " {query}; [the ]{name} []" + - " {query}; [the ]{name} [] [((with)|(using)) {radio_mode}]" expansion_rules: play: "((play)|(listen to))" player_devices: "((speaker)|([media] player))" @@ -19,3 +19,6 @@ intents: lists: query: wildcard: true + radio_mode: + values: + - "radio mode"