Yeah exactly. You already implemented a refresh at the end of the song and in some other scenarios, things I had custom automations for so that’s great and saves me some maintenance. With support for a state refresh on demand to support external triggers such as the one I have by looking at the Chromecast, your integration is great out of the box while not limiting people adding their own logic on top
@thlucas another thing that gives users options while not breaking current functionality, is to add a configuration setting like “auto start/stop when turning mediaplayer on/off”.
I’d like to explicitly start/stop music, for instance in these 2 scenarios:
- I’m listening to music at home, get in my car where Android Auto/Spotify picks up playing and I can enjoy music. 5 minutes after I leave home, my automation that shuts everything off triggers: lights, tv, receiver, chromecast, etc. Of course, I turn the Spotify entity off as well, to stop it from polling. At that moment, the music stops in my car
- When my gf or me ask the Google Home to play music, it automatically starts playing music on my Chromecast. I detect that and an automation triggers that starts my receiver and activates my Spotify ‘activity’ (custom concept I introduced), which also needs to turn on the Spotify entity but not resume playing as something is already playing.
Especially the first scenario is annoying, is this something you would consider implementing? If it helps with the administration/your workflow, I can also create feature requests in Github.
Hello Todd,
I have several dashboards where spotifyplus is on each one. Is there a way that, for example, only a specific player can be selected on dashboard “A”?
Best regards
Stefan
@ReinierZon
I can add the requested functionality for both scenarios, but it will default to current behavior: at turn on, play is resumed; at turn off, play is paused. You will have to explicitly turn it off via the SpotifyPlus configuration settings. I would also split them into two separate options, one for turn on resume and one for turn off pause.
Note that for the turn off scenario, if pause is disabled then Spotify will continue playing on the selected device until you pause / stop the player via an external player (e.g. Spotify Mobile, web, desktop, etc). You can’t pause it via an HA service call, as that will automatically turn the player back on.
As for the turn on scenario, I don’t think the disabling of the resume play will help you in regards to Chromecast devices. This is because Chromecast devices do not use the Spotify Connect Zeroconf protocol to control the device. They use the Google Cast protocol, which involves sending a cast message to the device, which then starts a Spotify embedded client app on the device that will then control the player. The cast protocol require that you resume play within a specified number of seconds on the selected device, otherwise the Spotify embedded client app times out and the activation of the device fails. The disabling of the resume play will work fine for other Spotify Connect Zeroconf device types (e.g. Sonos, Bose, Denon, etc).
Hopefully that makes sense, without getting too technical.
@Richi
Hi Stefan,
I don’t think that can be controlled via integration settings (e.g. any integration, not just SpotifyPlus), as it’s specific to a dashboard.
However, you might be able to define multiple SpotifyPlus cards on the dashboard (one for each entity), then use the “visbility” settings to show / hide the appropriate card(s) that you want depending on the conditions.
I must confess that I have not used the “Visibility” functionality in HA, so I’m afraid I cannot be of much help there.
@ReinierZon
FYI - just released a new version of the SpotifyPlus integration.
Be sure to check out the SpotifyPlus Card Dashboard as well.
[ 1.0.113 ] - 2025/04/12
- Added service
trigger_scan_interval
to trigger a scan interval sequence, which will update HA State values from content currently being played on the user’s Spotify account. Use this service if you have external processes or automations that detect changes to the Spotify Player. This service will then force the integration to immediately scan the Spotify Web API Player for updated player state. - Added configuration option Auto Pause on Turn OFF to automatically pause the Spotify Player when the media player is turned off (enabled by default) or not (disabled).
- Added configuration option Auto Resume on Turn ON to automatically resume the Spotify Player when the media player is turned on (enabled by default) or not (disabled).
Thanks! Bought you a couple pizzas
They new changes all seem to work perfectly, thanks!
While testing I noticed some strange behavior, which probably has to do with the difference between Google Cast and Spotify Connect. As mentioned, I like to be able to ask Google to play something, which is does and now the Spotify entity turns on perfectly so the tablet in my kitchen shows my HA dashboard and the Spotify app on the Google Nest Hub in my living room also starts and shows what is playing. So everything is working fine, until I switch songs with the HA SpotifyPlus entity.
At that point, the new songs starts playing but the Spotify app on the Nest Hub stops. It’s as if the SpotifyPlus integration stops the casting and then takes over with Spotify Connect? The regular Spotify integration does not do this and neither does the Spotify Android app.
Is this something you can look into/change? If you require more information or logs or anything, let me know!
@ReinierZon
I think I might know what is going on … to confirm, you do the following:
- ask Google to play something.
- kitchen tablet displays HA dashboard with SpotifyPlus Card that show what is playing.
- Spotify App on living room Google Nest Hub also starts and shows what is playing.
Is the above correct?
Questions (before you switch songs from HA):
- in step 1 above, did you ask Google to play something on the living room Nest Hub?
- what is the source that is displayed in step 2 HA dashboard SpotifyPlus Card player section? is it the Google Nest Hub device name?
- what is the device name that is displayed in step 3 Nest Hub Spotify App? does the source name there match the HA dashboard SpotifyPlus Card source name?
now select a new track from the HA SpotifyPlus entity.
Questions (after you switch tracks from HA):
- what is the source that is displayed in step 2 HA dashboard SpotifyPlus Card player section? is it the Google Nest Hub device name?
We may have to run an advanced SmartInspect trace to see what is going on, as I cannot get this to happen on my Google Nest Audio device; note that I do not have a Nest Hub, so it might be bahving differently.
@ReinierZon
Thanks for your support with the pizza’s, much appreciated!
Hi, regarding the steps I take you’re almost right:
- I ask Google on the Nest Hub to play music. This is the only thing I ask, as I have set the Nest Hub’s default music device set to my Chromecast.
- At this point the Spotify app on the Nest Hub starts and it starts casting to the Chromecast and continues playing whatever I was listening to.
- Home Assistant sees that the Chromecast starts playing and then turns on the SpotifyPlus mediaplayer entity (and my receiver :)). I am currently not using your SpotifyPlus card, but the regular Spotify card that I have tweaked a bit with cardmod which then of course also shows what is playing on my dashboards (both in the kitchen and on my phone).
- Now when I press the next track button on one of those dashboards, the Nest Hub appears to stop casting because it stops the Spotify app. Music continues on the Chromecast though.
To answer your questions:
- I do not ask the Nest Hub explicitly nor do I ask it to play on a specific device. When I’m downstairs and prompt Google something, the Nest Hub responds even though other Google devices also pick up my question. So for the sake of this scenario, you can say that I am asking the Nest Hub. However, the Nest Hub has the Chromecast set as default music device, so it uses that device to cast Spotify to.
- I need to get back to you on this on Wednesday, as I’m currently not at home and can’t install and look at the SpotifyPlus card player right now or ask the Nest Hub something. I am pretty sure the source attribute of the SpotifyPlus mediaplayer entity is always Chromecast and never Nest Hub. I assume the card uses that attribute? I also think it would be playing music with the Nest Hub speaker if that would be the source, but it’s always using the Chromecast that is plugged into my receiver.
- Also need to have a look when I get back home. I do know for certain that the Android Spotify app on my phone lists the Chromecast as source.
- Will check Wednesday
There is something that I found weird. The source list has 2 Chromecast devices and I think both interact with the same device when I was testing, but I also need to double check that Wednesday. Could be that I remember incorrectly and that one is the Chromecast at my girlfriend’s place:
I’ll also generate those SmartInspect traces for you on Wednesday. Is the example config here OK to use or do you want me to alter some settings?
Yes, the example config will work fine. Let me know when you have a trace file, and I will setup a google drive space for you to transfer it to; do not attach it on the public forum.
Thanks
So I said today, but of course just as I wanted to test a few things for you, Spotify is down Will try again tomorrow.
Some more information, after this I’ll get the trace but maybe you already have a better idea based on these 2 screenshots.
I created a debug dashboard showing the SpotifyPlus card and some info of my Google TV remote entity, the Chromecast mediaplayer and the SpotifyPlus mediaplayer. The first image is the state when I ask the Nest Hub to play music:
The second image is after I pressed the next track button:
You can clearly see the sp_device_id changed and that the casting is no longer happening. The SpotifyPlus integration is configured with the device id that is used while casting with the Nest Hub, although what my expectation would be is that the integration doesn’t do anything with this default device if another device is already playing:
I also see why earlier I thought it didn’t matter which device is configured as default. Even though I have the cf2 device (the one used while casting) as default, it still resumes playback on the 8b2 device if I initiate playback with the SpotifyPlus integration.
This issue is caused by the 2 “Chromecast” devices having the same device name.
The skip next is passing in a device NAME (not device ID) to resolve, which is “Chromecast”. When it performs the lookup, it looks for a device name (not id) of Chromecast" and finds the
8b258c417c92a7566248d599ac9971ebe1667803device instance. The active Spotify Player device is "Chromecast (cf2252e92ff7b12f1065ccfd5653c597)", which is a different device. So the integration switches to the
8b258c417c92a7566248d599ac9971ebe1667803` device id that was resolved.
I think all you need to do is rename one of the “Chromecast” devices to something else (e.g. “Chromecast Ella”, “Chromecast Reinier”, etc).
Here are the log entries that show what is happening:
Spotify Connect device skip next (deviceId = Chromecast)
Spotify Connect active device detected: "Chromecast" (cf2252e92ff7b12f1065ccfd5653c597)
Spotify Player device "Chromecast" (8b258c417c92a7566248d599ac9971ebe1667803) was found in the Spotify Connect Devices collection (by Name)
SpotifyClient http request: 'https://api.spotify.com/v1/me/player/next?device_id=8b258c417c92a7566248d599ac9971ebe1667803' (with urlparms)
Thanks. I’ll try when I get home. Not sure where the 2 Chromecasts come from, I only have one and also both devices are being shown as active/playing in the SpotifyPlus Anyway, I’ll have a look. Maybe one is the built-in app for casting (it starts an app called Mediashell when I do that) and the other the actual Spotify app that I also have installed on the Chromecast, not sure. If that’s the case I’m not even sure I can rename them.
Might be a nice improvement though, to always look up/reference device by their outside of the GUI?
I used to call by device id, but those were failing for restricted devices which do not supply a device id to the Spotify Web API playerstate.
I might be able to adjust that logic for Chromecast devices though, as they are not considered restricted. I’ll keep you posted.
Ahh that’s pretty annoying. From Spotify’s side it’s not yet possible to change the name. There is feature requests for it with quite a lot upvotes, but it is marked as ‘not right now’: [Connect] Change Device Name in Device List - Page 8 - The Spotify Community
I’m not sure what information you have available in the integration, but instead of making an exception specifically for Chromecasts maybe it’s more future proof to pass the device id if you have it and name if you don’t and then add an additional boolean parameter to indicate whether you’re dealing with a restricted device (to prevent having to detect whether the string you receive is a name or an id)?
I’ll be able to check what I can do with the Chromecast when I get back home, probably Sunday.
If I find the time I’ll also check if I can clone your repo and maybe help out myself and create a PR. No promises though Is it possible to do stuff like remote debugging? Or simulate things in some way?