Hmmm. Confused… what difference would random+shuffle give compared to just shuffle?
I can implement it if I understand a bit more
Shuffle will mean that songs after the currently playing one will be random.
In the code in the PR
_LOGGER.debug('Playing context uri using context_uri for uri: %s', uri)
client.start_playback(device_id=spotify_device_id, context_uri=uri)
if shuffle is True:
_LOGGER.debug('Shuffling...')
client.shuffle(shuffle)
Music will start playing the playlist specified in order followed by a shuffle command. This means that every single time the following command is sent, the first song of the playlist will always play first and the song following it will be random.
service: spotcast.start
data:
uri: my_playlist
entity_id: entity
shuffle: true
If my_playlist had the following items:
- Track 1
- Track 2
- Track 3
- Track 4
- Track N
Track 1 will always play first but can play a random track such as track 4, Track 2, Track 11, Track N afterward when shuffle is enabled.
Shuffle play will start playing a random song (from the start) between Track 1 and Track N and continue playing random songs afterward.
As I had mentioned, I think we can achieve shuffle play by starting the playlist at a random song and then turn on shuffle.
That is not what happened when I tested it today. It started with random songs in the playlist.
I’ll give it a shot and see if I get the same results.
…
I tested the change but unfortunately, I still have the same problem I’ve been having every now and then.
I can send the spotcast start command and the device(s) make the bloop noise but nothing ever happens. The Google home apps indicate that something is about to be cast and then it goes to not playing. Similarly, the Spotify media player component does not indicate that anything is playing, although it does add the device to the source list. If I manually switch the source using the Spotify application, it will continue playing with whatever Spotify was last playing.
After enabling debugging logs, the only messages I see are the following
DEBUG (SyncWorker_10) [custom_components.spotcast] Launching spotify app on Living Room
I never see any other message except for the “Found Chromecast devices”
Not sure if helpful, but whenever I had issues with the Google Home beeping but not playing, I’ve deleted the pycache-folder in Spotcast. That has always seemed to fix that issue.
This issue is known and is because hass didn’t upgrade pychromecast yet to 3.2.2. PR is merged but it hasn’t made it into 0.94.2. You need to wait for 0.94 or use a later version of hass unfortunatly.
See https://github.com/fondberg/spotcast/issues/15
I was finally able to have casting working again.
The shuffle feature seems to be working most of the times.
I also have the spotify component enabled and noticed that when spotify is in an idle state before the cast, the first song seems to always be the first song in the playlist. If I go to the next track, it will be random.
If the spotify state is in a state that is not idle, then everything works perfectly. A random song is played at the start.
I have dealt with this by creating a script that looks at the state and decides to the next track if the initial state was idle.
I would say this is a Spotify bug.
I will have a look to see if there is anything simple I can do to skip the first track, like adding thr index to the play request and see if it works
Just installed but I am also seeing the issue with the Google Chromecast beeping but then not playing anything. I guess I will downgrade or wait for the pychromecast update.
I just wanted to clarify though: does this component require that the spotify:
component is also enabled and configured?
Hass 0.95 is out now which includes the pychromecast update. I tested this morning and it seems to be working.
I just wanted to clarify though: does this component require that the
spotify:
component is also enabled and configured?
So I guess I have answered my own question: “no, the spotify component is not required”
Using the latest version and somehow also when the player is already playing, it takes some time to start another playlist. I remember before only the first request took some time. Any clue why?
Can you elaborate on what you mean with “player is already playing” and “takes some time to start another playlist”?
I mean what is the first player device and what is the second request for (same device or another one)?
If you mean that a playlist is playing on any spotify device and you want to transfer it to an idle chromecast device then it will take time as the time is spent in starting up spotify on the idle cast device
Sure @fondberg
With an automation, I’ll trigger this script:
{
"device_name": "Woonkamer Home Mini",
"uri": "spotify:user:jellevervloet:playlist:1W94pSsqF8xgIsoRCS6Po8"
}
After the automation is triggert it takes about 10-15 seconds before the music is actually playing on the the idle Google Home. When another automation is triggert, which plays another Spotify playlist on the same Google Home, it takes anoter 5-10 seconds untill the other playlist is actually started.
Before, when triggering another script to play another playlist on the same Google home which is already playing another playllist, the new playlists starts almost instantly.
{
"device_name": "Woonkamer Home Mini",
"uri": "spotify:playlist:0MpXwWIaYmiodOK6gPlBbM"
}
When selecting the Google Home in the Spotify app on my phone/desktop, the music is a lot faster playing on the Google Home. Not sure if it is right to compare those two?
I see. The 15 secs can happen if you are on wifi and your cast devices are slow to respond. I think around 6-10 secs would be the fastest I’m afraid due to the complicated nature of finding the device and starting spotify et.c.
This component tries to start anything regardless of current state so the best thing would be to check the state on the media player and use media_player.spotify direct if it is playing spotify already. That would cut the playback time to milliseconds
Thanks for your explanation. Good idea to check if the spotify player is already playing something.
Hi @fondberg !! Thanks for this amazing component!! I’ve been looking for this for a year!
I have a question… Is there any posibility to create a service who send a blank uri to all chromecast on the network each 1 minute for example, so you just “wake up” all the devices in sensor.chromecast_devices, to show them in Spotify Media Player? Do you understand what I mean?
Hi! It is not possible to have spotify started on more than one device at a time so it would not be possible to start spotify ahead of time on all devices
I took a look at this https://github.com/home-assistant/home-assistant/pull/24991/files#diff-30c01f11d37f5b0e61a763cfdd474421R276
It seems that the spotify integration will have random song feature.
Could something like this be added?
The random or shuffle start feature is not so hard. I have a PR that adds (https://github.com/fondberg/spotcast/pull/18) it but it needs the random value to start it. I like that the media player in the core code is waking up. I only started the CC because the token in HASS is to weak (needs the webplayer token to start playback on idle chromecast devices).
I just got a child which takes a lot of my time but maybe I’ll get some time to add the last touches in the PR unless someone wants to take over and complete the PR.
I finally came around to coding today. I added the random_song parameter as well as the shuffle param. I also added the much faster start which I got help from @soldag by reusing the discovered devices from the cast platform. It still falls back to a full network discovery if the device is not found in the already discovered devices. I also made the sensor optional and it needs to be added to the sensor section of the configuration manually to start.
I do have a problem though, I can’t test anything locally for some reason. I get 404 on all my play requests locally. I will test it on my hass BUT I want to get help testing it from you guys because I think it contains some great improvements.
The release is in a branch and I added a github release here: https://github.com/fondberg/spotcast/releases/tag/2.0.0.b1 and the PR is here https://github.com/fondberg/spotcast/pull/23.
Install by downloading the ZIP file and exrtact it in the custom_components directory and restart. See the README for the new params
Edit: I got it running on my hass. Shuffle seems to be a problem because of internal spotify api returns 404 with no device found BUT random and fast start seem to work