Skip to content

Commit

Permalink
Allow radio mode to be passed on intent query (#2913)
Browse files Browse the repository at this point in the history
  • Loading branch information
baukita authored Sep 14, 2024
1 parent 831f05e commit d79038e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion custom_components/mass/intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def slot_schema(self) -> dict | None:

async def async_handle(self, intent_obj: intent.Intent) -> intent.IntentResponse:
"""Handle the intent."""
# pylint: disable=too-many-locals
response = intent_obj.create_response()
slots = self.async_validate_slots(intent_obj.slots)
config_entry = await self._get_loaded_config_entry(intent_obj.hass)
Expand All @@ -72,6 +73,7 @@ async def async_handle(self, intent_obj: intent.Intent) -> intent.IntentResponse
)

query = slots.get(QUERY_SLOT, {}).get(SLOT_VALUE)
radio_mode = False
if query:
if not config_entry.data.get(CONF_OPENAI_AGENT_ID):
raise intent.IntentHandleError(
Expand All @@ -86,6 +88,7 @@ async def async_handle(self, intent_obj: intent.Intent) -> intent.IntentResponse
return response
media_id = json_payload.get(ATTR_MEDIA_ID)
media_type = json_payload.get(ATTR_MEDIA_TYPE)
radio_mode = json_payload.get(ATTR_RADIO_MODE, False)
else:
artist = slots.get(ARTIST_SLOT, {}).get(SLOT_VALUE, "")
track = slots.get(TRACK_SLOT, {}).get(SLOT_VALUE, "")
Expand Down Expand Up @@ -113,7 +116,7 @@ async def async_handle(self, intent_obj: intent.Intent) -> intent.IntentResponse
media_type=media_type,
media_id=media_id,
enqueue=None,
extra={ATTR_RADIO_MODE: False},
extra={ATTR_RADIO_MODE: radio_mode},
)
except MusicAssistantError as err:
raise intent.IntentHandleError(err.args[0] if err.args else "") from err
Expand Down

0 comments on commit d79038e

Please sign in to comment.