Respect device volume support in Spotify media player (#192778)

This commit is contained in:
Francesco Frison
2026-11-15 22:05:34 +01:00
committed by GitHub
parent d7cc33f9d8
commit 29c10d4c29
2 changed files with 19 additions and 0 deletions
@@ -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"),