From 3046329f4f77baa3817437fda0151c40834d5e36 Mon Sep 17 00:00:00 2001 From: Markus Jacobsen Date: Tue, 18 Jun 2024 14:00:27 +0200 Subject: [PATCH] Add Tidal play_media support to Bang & Olufsen (#119838) Add tidal play_media support --- homeassistant/components/bang_olufsen/const.py | 2 ++ .../components/bang_olufsen/media_player.py | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/bang_olufsen/const.py b/homeassistant/components/bang_olufsen/const.py index 91429d0f9b010d..25e7f8e15dc566 100644 --- a/homeassistant/components/bang_olufsen/const.py +++ b/homeassistant/components/bang_olufsen/const.py @@ -54,6 +54,7 @@ class BangOlufsenMediaType(StrEnum): FAVOURITE = "favourite" DEEZER = "deezer" RADIO = "radio" + TIDAL = "tidal" TTS = "provider" OVERLAY_TTS = "overlay_tts" @@ -118,6 +119,7 @@ class WebsocketNotification(StrEnum): BangOlufsenMediaType.DEEZER, BangOlufsenMediaType.RADIO, BangOlufsenMediaType.TTS, + BangOlufsenMediaType.TIDAL, BangOlufsenMediaType.OVERLAY_TTS, MediaType.MUSIC, MediaType.URL, diff --git a/homeassistant/components/bang_olufsen/media_player.py b/homeassistant/components/bang_olufsen/media_player.py index 0ce8cd22249bd8..5c214a3fb17608 100644 --- a/homeassistant/components/bang_olufsen/media_player.py +++ b/homeassistant/components/bang_olufsen/media_player.py @@ -638,20 +638,20 @@ async def async_play_media( elif media_type == BangOlufsenMediaType.FAVOURITE: await self._client.activate_preset(id=int(media_id)) - elif media_type == BangOlufsenMediaType.DEEZER: + elif media_type in (BangOlufsenMediaType.DEEZER, BangOlufsenMediaType.TIDAL): try: - if media_id == "flow": + # Play Deezer flow. + if media_id == "flow" and media_type == BangOlufsenMediaType.DEEZER: deezer_id = None if "id" in kwargs[ATTR_MEDIA_EXTRA]: deezer_id = kwargs[ATTR_MEDIA_EXTRA]["id"] - # Play Deezer flow. await self._client.start_deezer_flow( user_flow=UserFlow(user_id=deezer_id) ) - # Play a Deezer playlist or album. + # Play a playlist or album. elif any(match in media_id for match in ("playlist", "album")): start_from = 0 if "start_from" in kwargs[ATTR_MEDIA_EXTRA]: @@ -659,18 +659,18 @@ async def async_play_media( await self._client.add_to_queue( play_queue_item=PlayQueueItem( - provider=PlayQueueItemType(value="deezer"), + provider=PlayQueueItemType(value=media_type), start_now_from_position=start_from, type="playlist", uri=media_id, ) ) - # Play a Deezer track. + # Play a track. else: await self._client.add_to_queue( play_queue_item=PlayQueueItem( - provider=PlayQueueItemType(value="deezer"), + provider=PlayQueueItemType(value=media_type), start_now_from_position=0, type="track", uri=media_id,