diff --git a/homeassistant/components/spotify/media_player.py b/homeassistant/components/spotify/media_player.py index 3ace16ff48c7..eb41dd77928e 100644 --- a/homeassistant/components/spotify/media_player.py +++ b/homeassistant/components/spotify/media_player.py @@ -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 diff --git a/tests/components/spotify/test_media_player.py b/tests/components/spotify/test_media_player.py index dbaf66ce897e..33a7789c8e82 100644 --- a/tests/components/spotify/test_media_player.py +++ b/tests/components/spotify/test_media_player.py @@ -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"),