This is also the argument I meet back when I raised the issue (making it a non-issue) - however I don’t see this behavior on my iPhone or MacBook spotify apps. Once in a while maybe, but not as much - maybe they do something to discover the devices more aggressively or something like that.
I am far from proficient with all of this, but I had an idea that I thought may be worth sharing. When I try to cast to google devices via Spotify on my desktop, I cannot see any of the google devices. I can only see the desktop I am on and a Firestick. The issue is referenced here (https://community.spotify.com/t5/Desktop-Windows/Spotify-Connect-amp-Google-Home/td-p/4642461) and I can confirm that I see all of my devices on my phone, but not from my desktop.
Maybe the limitation is with the Spotify API or the way that Home Assistant is using it, because it functions very similarly to the way that using Spotify on my desktop does. If I start playing music on a google home (via voice command or casting from my phone), I can see the google home on my desktop Spotify client in the devices menu but the moment I switch it to my desktop via the devices menu on my desktop the google home disappears. This is the exact same way that sources show up on my HA front-end and it behaves the same if I switch devices from the HA front-end.
Again, I have no idea how to begin remedying this, but I figured I would throw it out there in case someone who has the knowledge wants to take it and run with it at some point. Maybe there is a way to utilize the iOS or Android API to see google devices with more reliability.
The problem is indeed with Spotify API. There’s a few issues on Spotify open. I have been researching a bit. Google Assistant can actually start the cast too. Hence, I was thinking of a workaround to make a request to Google Assistant to start the cast, then take over the control in Home-Assistant. In that sense, I wonder whether the Google Assistant SDK Add-on could make it work. Does anyone has it installed to check whether it’s possible to make REST/HTTP calls or use it in scripts?
I think I could indeed dig up ids using Spotify Rest API as per the link shared by phairplay.
But how do you use spotify in automation? I tried to use spotify.play_playlist service as described on https://www.home-assistant.io/integrations/spotify/, but it reports no activ device found (I can play on one and Rest API reported it back!)
Sure. This is really ugly, but I haven’t looked at it for a couple of years and it works. I had some strange issues with lists starting with the same song and volume so there’s quite a lot of room for improvement. Again, it does what I want it to do…
There is not much to look at. The current integration in 0.105 shows all sources provided by the Spotify API. There is no filtering on our end for that.
Yeah, we’ve settled that this is a Spotify API problem…
But @peglegreg is right… mobile apps have a different way of fetching the available sources on the local network, since they all show as available most of the time. Isn’t there any way for the HA integration to make a scan the same way the mobile apps do instead of fetching the sources from the API?
Yes, but not only…
For instance, my Samsung TV, my PS4… they show up in my android app but not on the desktop app, which also gets the source list from the API.
There’s only one source available at all times and that’s my Yamaha receiver. I wonder why…?
Why are the Chromecast devices listed in the Spotify Lovelace Card, while they are not available in the official Spotify API, and thus not in the sources of the media_player in HA? Anyone knows?
My wife’s Spotify account also doesn’t list any device. I can stream to Chromecast devices now through Spotcast, but I have other devices I want to start playback on (HEOS in my case). None of these are in the source_list of the media_player entity of the Spotify integration of my wife, until I start the playback myself manually through the Spotify app on her phone. Then the source_list is populated as it should be.
Also checked the api of Spotify and got this returned:
This has been an issue for years and it is unfortunately a limitation in the Spotify integration/API.
The good news is that depending on what speakers you have there might be ways to work around it.
If your speakers are Cast compatible (might also work with Spotify Connect) I highly recommend the spotcast custom component mentioned a few posts above.