mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Respect device volume support in Spotify media player (#192778)
This commit is contained in:
@@ -144,6 +144,8 @@ class SpotifyMediaPlayer(SpotifyEntity, MediaPlayerEntity):
|
||||
return MediaPlayerEntityFeature(0)
|
||||
if not self.currently_playing or self.currently_playing.device.is_restricted:
|
||||
return MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
if not self.currently_playing.device.supports_volume:
|
||||
return SUPPORT_SPOTIFY & ~MediaPlayerEntityFeature.VOLUME_SET
|
||||
return SUPPORT_SPOTIFY
|
||||
|
||||
@property
|
||||
|
||||
@@ -131,6 +131,23 @@ async def test_restricted_device(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("setup_credentials")
|
||||
async def test_device_without_volume_support(
|
||||
hass: HomeAssistant,
|
||||
mock_spotify: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test volume set is not supported when the device doesn't support volume."""
|
||||
mock_spotify.return_value.get_playback.return_value.device.supports_volume = False
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
state = hass.states.get("media_player.spotify_spotify_1")
|
||||
assert state
|
||||
assert (
|
||||
state.attributes["supported_features"]
|
||||
== SUPPORT_SPOTIFY & ~MediaPlayerEntityFeature.VOLUME_SET
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("setup_credentials")
|
||||
@pytest.mark.parametrize(
|
||||
("product", "supported_features", "model"),
|
||||
|
||||
Reference in New Issue
Block a user