-
-
Notifications
You must be signed in to change notification settings - Fork 28.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spotify: Missing random_song: true #31607
Comments
Curious about the same thing... |
The shuffle service is available for enabling shuffle play on media players. |
@frenck the shuffle service will only make the next songs random and not follow the playlist. However even if the shuffle service is enabled, when you call media_player.play_media with a playlist URI it will always start at the first song of the playlist and if shuffle is on it will then pick a random second song. the |
So, to fix this, we need to push out the current shuffle state when starting a playlist, right? That way, you can enable shuffle, and start a playlist. Any playlist started when shuffle is enabled on the media player, will start a playlist at random. How does that sound? |
@frenck yes that sounds good. Although I could image use cases where people would like to start a playlist at a random song and then continue in order of the playlist. Therefore we could also opt for a extra attribute to the media_player.play_media service called something like "shuffle_start" or "random_start" or something like that. This attribute would control if the first song was random or not, and the shuffle service would control what happens for all next songs. I don't have a strong prefrence, but I think a extra attribute would provide for a bit more flexibility. |
Turn off shuffle again 😉 automation: set shuffle on, start playlist, set shuffle off. I don't think actual new features to the system are needed for implementing that kind of logic. Besides, adding new features to core parts of the system, need good general uses cases and need to be approved as an architectural proposal. |
@frenck so obvious, how could I have missed that. So then indeed just making sure the playlist starts random if shuffle is turned on using the shuffle service would fix this! |
shuffle function isn't accessible to the frontend like it used to be. Am i missing something? |
This comment has been minimized.
This comment has been minimized.
@artaxx81 I marked your post hidden, I really suggest you change your attitude quite a bit since your tone could get you banned. You are violating our Code of Conduct. As for the issue, it is being discussed here, in this issue, how we can resolve this in a way that is more fitting for Home Assistant compared to the previous implementation. We all work towards a better piece of software, your comment doesn't really help with that. |
Hi Frenck, I've just deleted the post. Sorry for that but I am really depressed because of that. I was working very hard on a very important project which is broken now. I promise that I will clear up myself! |
OK, I found a workaround (not pretty but it does the trick): I am starting the whole thing with an input_boolean, then I select the playing device with a
with entity_id and source. Then I start the playlist with
and
After that I set shuffle on with
And after this I force the playing device (!) to jump one song forward with
As I mentioned: Not pretty but It works. The delay between trying to play the first song and skipping to the next is so low that you will only mention it because it's showing up for a split second. The curious thing is that when I do a media_player.media_next_track on the spotify player it plays always the same NEXT song. It only works when I am doing a media_player.media_next_track on the real playing device. I am using Volumio. I am not able to say if this works on other playing devices as well! I think the problem is that you cannot set shuffle before starting the playlist (only after). The random_song: true attribute of the play_playlist service was apparently able to do that or it used another API call for start playing a playlist with a random song. For now that shown workflow above does the trick for me! I hope this will help someone and I would like to apologize for the first hidden and now deleted post of mine. I am working hard on myself to fit into here as I am very new to github! Thank you all! |
This comment has been minimized.
This comment has been minimized.
Just found an error in my solution. The right order is:
If you first set the playing device and start the playlist after that it will arbitrary play the playlists first song obstinately! |
The file |
I don't think it works setting shuffle on before start playing a playlist. The service for me it always starts first music with shuffle off script:
|
This adds a solution to the missing random_song:true attribute that was in the spotify.play_playlist service. This fixes issue: home-assistant#31607
@frenck I just made a PR that schould fix this issue, based on the constructive discussion we had. |
This was discussed in PR #31933, and will add a summary to this issue for future reference. So here I made a test case, with the currently released code, as in available in 0.105. This is the official Spotify client, connected with my Premium account. I have used Home Assistant 0.106.0b1 for this recording (which has the same code as 0.105). ℹ️ Please note the recording below shows the intended working of starting randomly in a playlist, but without any modification to the code base.Verified in the above recording:
Lovelace configuration used for this demo - title: lab
path: lab
badges: []
cards:
- type: media-control
entity: media_player.spotify_frenck_nl
- type: button
name: Shuffle off
tap_action:
action: call-service
service: media_player.shuffle_set
service_data:
entity_id: media_player.spotify_frenck_nl
shuffle: false
- type: button
name: Shuffle on
tap_action:
action: call-service
service: media_player.shuffle_set
service_data:
entity_id: media_player.spotify_frenck_nl
shuffle: true
- type: button
name: Start Hackers playlist
tap_action:
action: call-service
service: media_player.play_media
service_data:
entity_id: media_player.spotify_frenck_nl
media_content_type: playlist
media_content_id: 'spotify:playlist:5PyDUMge81u29mYxQV949t'
icon: 'mdi:planet' The current implementation follows the API specs, as concluded, there may be clients out there that don't follow the spec. As figured out by @starkillerOG in this comment: #31933 (comment) |
Unfortunately it is also broken on the Logitech Media Server Spotify client: that is also reseted to non-shuffle mode by play_media service call... :( For example I have morning alarm with a Spotify playlist started on LMS by Home Assistant, and ever since the old Spotify component is gone, this always starts with the first song. Not too convenient. I understand it is not the fault of Home Assistant, but the point is we used to have a working solution with the old Spotify component, but not anymore. |
@realthk you can use spotcast, a custom component available on HACS. |
@starkillerOG Thanks, but I don't use cast (apart from Google Home Hub as TTS annoncement). |
I think I am having similar issues with my Raspotify integration. Spotify is set to shuffle, Forked-Daapd is set to shuffle. I can see it enabled in Spotify. But starting a playlist adds it to the queue and plays in that order. I cannot replicate the screenshot above. It plays the same starting song every time and can't shuffle because the queue is filled with the playlist. Really not sure what the issue is. I am calling the playlist the same way as above, but keep getting the same song and my queue filled with the ordered list. |
The problem
First of all thank you for the improvements to the new sportify integration!
The new Spotify integration has depricated the spotify.play_playlist service.
That service supported "random_song: true" to start your playlist at a random song instead of always the first one. I do not think this is possible to do using the media_player.play_media service.
It is really annoying to always have to listen to the same first song of a playlist using shortcut buttons in HomeAssistant. Therefore I really loved the "random_song: true" option.
Can this option be re-added to the media_player.play_media service to get this functionallity back?
Or how can this be done using the media_player.play_media service?
Environment
Problem-relevant
configuration.yaml
Traceback/Error logs
Additional information
The text was updated successfully, but these errors were encountered: