From d79038ecf069c90bbd4b9caa2861e8db5ecde7de Mon Sep 17 00:00:00 2001 From: baukita Date: Sat, 14 Sep 2024 08:30:20 -0300 Subject: [PATCH] Allow radio mode to be passed on intent query (#2913) --- custom_components/mass/intent.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/custom_components/mass/intent.py b/custom_components/mass/intent.py index 836edcf7..6150de2b 100644 --- a/custom_components/mass/intent.py +++ b/custom_components/mass/intent.py @@ -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) @@ -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( @@ -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, "") @@ -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