mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Add support for restricted playback devices in Spotify (#96794)
* Add support for restricted devices * Add support for restricted devices
This commit is contained in:
parent
772fb463b5
commit
a69b5a8d3b
@ -120,9 +120,6 @@ class SpotifyMediaPlayer(MediaPlayerEntity):
|
||||
|
||||
self._attr_unique_id = user_id
|
||||
|
||||
if self.data.current_user["product"] == "premium":
|
||||
self._attr_supported_features = SUPPORT_SPOTIFY
|
||||
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, user_id)},
|
||||
manufacturer="Spotify AB",
|
||||
@ -137,6 +134,16 @@ class SpotifyMediaPlayer(MediaPlayerEntity):
|
||||
)
|
||||
self._currently_playing: dict | None = {}
|
||||
self._playlist: dict | None = None
|
||||
self._restricted_device: bool = False
|
||||
|
||||
@property
|
||||
def supported_features(self) -> MediaPlayerEntityFeature:
|
||||
"""Return the supported features."""
|
||||
if self._restricted_device:
|
||||
return MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
if self.data.current_user["product"] == "premium":
|
||||
return SUPPORT_SPOTIFY
|
||||
return MediaPlayerEntityFeature(0)
|
||||
|
||||
@property
|
||||
def state(self) -> MediaPlayerState:
|
||||
@ -398,6 +405,9 @@ class SpotifyMediaPlayer(MediaPlayerEntity):
|
||||
self._playlist = None
|
||||
if context["type"] == MediaType.PLAYLIST:
|
||||
self._playlist = self.data.client.playlist(current["context"]["uri"])
|
||||
device = self._currently_playing.get("device")
|
||||
if device is not None:
|
||||
self._restricted_device = device["is_restricted"]
|
||||
|
||||
async def async_browse_media(
|
||||
self,
|
||||
|
Loading…
x
Reference in New Issue
Block a user