Starting a Spotify Playlist on Chromecast

What I have:
Chromecast Audio

What I want:
To cast Spotify playlists to a Chromecast device.

For now I can cast an mp3 or similar to my Chromecast-devices using the PlayURI-channel.

I am guessing what I need is:

  1. Some way of authenticating to Spotify
  2. Maybe something that converts a playlist URI to a URI Chromecast can play.

Is there a best practice method to do this?
Or a (preferably easy) way of doing this?

I do not need a fancy front end player or something, just something I can trigger through events when pushing physical buttons.

1 Like

Install Spotify Binding:

When you have installed and set-up Spotify binding, you can make use of “spotify_track_to_play”:

	rule spotify_play_BAD_SOV

	Item KNX_CastHovedsov_Play received update ON or
	Item KNX_CastBad_Play received update ON

	logInfo("Bathroom", "Received command PLAY")
	if(SpotifyPlayerBridge_SpotifyConnectDeviceName.state!="Audio Gruppe" && SpotifyPlayerBridge_SpotifyConnectDeviceName.state!="Bathroom"){
	logInfo("Cast", "No cast devices in use, starting Playback on Bathroom")
	sendCommand(Spotify_Bathroom_TrackToPlay, "spotify:user:YOURUSER:playlist:YOUR_PLAYLIST_URI")
	sendCommand(Spotify_Bathroom_DeviceShuffle, ON)
	logInfo("Bathroom", "Playing YOUR_PLAYLIST on Bathroom and Shuffle Activated" )
	//logInfo("Cast", "Bathroom or Audio Gruppe already in use") 
	if(SpotifyPlayerBridge_SpotifyConnectDeviceName.state=="Audio Gruppe" && SpotifyPlayerBridge_SpotifyTrackPlayerControl.state != PLAY){
	logInfo("Audio Gruppe", "Active and State NOT play")
	sendCommand(SpotifyPlayerBridge_SpotifyTrackPlayerControl, PLAY)
	logInfo("Audio Gruppe", "Starting playback")

Best regards

Thanks @sjef86.

Why isn’t this binding available under addons?

It’s still under development. I’m picking up where @astenlund74 left off but haven’t started work on it yet.

I’m trying to get my UniFi binding merged and then I will start working on updating the Spotify binding.

1 Like

My Chromecast is not always available and even if I save his device ID if the Chromecast didn’t play something for the last 5 minutes it won’t change the device for my chrome cast

Hi @sjef86,

Does this also work when the spotify connect device thing (chromecast) is not currently playing spotify?
I installed the bindings and configured some rules. When I am already streaming to chromecast I am able to start a playlist from url with the “track_to_play” command. However when I am not casting anything, chromecast will not receive commands…
How did you manage this?

kind regards

Hello, is there an other link where i can download the spotify binding? The link in the post above seems to be broken. Thanks

The Spotify binding is available in the Eclipse market place. Enable the market place with debug access level in PaperUI and it becomes available for install.

Thanks im going to give it a try

I have a Chromecast device on the same network as openHAB. If I connect my phone to that network, so that it sees the Chromecast, then I can use the Spotify binding in openHAB to control Spotify and play music on the Chromecast.
But as soon as I disconnect my phone from the WiFi network, the Chromecast thing (that came through the Spotify binding) goes offline, and – obviously – I can’t play music on it anymore, unless I connect my phone to the WiFi network again.

Is it possible to make openHAB discover the Chromecast device through the Spotify binding, so that it wouldn’t rely on my phone being available? Or is there any other way I can play music from Spotify on the Chromecast?

It’s a common problem with Spotify connect
devices. See my other comment. It applies to the Chromecast too:

Hi All,
I installed the binding (2.4) without any hitch, I can read all the values from the Thing, and I can discover any devices that Spotify streams to.

Unfortunately, I can’t seem to control my Spotify account.

I have a:
Bridge @ spotify_player_Paul_trackPlayer, and a
Device @ spotify_device_Paul_3c3c_devicePlayer

I try this in my Rule:

        sendCommand(spotify_device_Paul_3c3c_trackPlay, "spotify:user:spotify:playlist:37i9dQZF1E358oZ9hslUxp")
        sendCommand(spotify_player_Paul_trackPlay, "spotify:user:spotify:playlist:37i9dQZF1E358oZ9hslUxp")
        sendCommand(spotify_device_Paul_3c3c_devicePlayer, "PAUSE")
        sendCommand(spotify_player_Paul_trackPlayer, "PAUSE")

But it does nothing.

When I manipulate Spotify on my phone, it changes the Items appropriately.

I should also note, that I only have the free Spotify. Do you need the Premium?

Can you control from PaperUI or any other openHAB UI, starting/stopping?
According to the binding documentation you need a premium account, although I heard Spotify changed this. But I don’t know if that is true, so I’m assuming a premium account is still needed.

PowerUI also doesn’t work for toggling the play/pause. :frowning:

Do you mean it doesn’t work with a free account. In that case that’s a restriction of the spotify api.

Correct, the free account doesnt let me control (write) state.

Hi All

Im using the old spotify script written by Patrick

I’m trying to use a single button, to send playback to a device. The button works fine, turning the unit on, but it wont play the playlist.

This playlist works fine when using patricks Habpanel code, which sends the following:

<div class="sceneLatest" ng-repeat="playlist in playlists" ng-class="{true:'on', false:''}[itemValue('spotify_current_context_uri')==playlist.uri]" ng-click="sendCmd('spotify_action', 'play ' + playlist.uri)">

But doesnt if I send my playlist uri , which comes up in the openhab console when playing.

It seems my syntax is wrong, but I’m unsure what I actually need here.

Any suggestions?

My rule:

rule "Aeotec 'WallMote' - Ensuite "
        Item BedRoom1_AeoButton_Scene received update
        var int sceneNumber = BedRoom1_AeoButton_Scene.state as DecimalType

        switch (sceneNumber) {

       case 1.0 : {
            logInfo("Aeotec Button Bedroom", "Button 1 1x press: " + sceneNumber)
             if (Ensuite_WXA50_Power.state == OFF) {
                 spotify_action.sendCommand('play', "spotify:playlist:7g8kXqj2ncZjxtqT5DuI6r")
             if (Ensuite_WXA50_Power.state == ON) {
                 spotify_action.sendCommand('play', "spotify:playlist:7g8kXqj2ncZjxtqT5DuI6r")



If you have a Premium subscription of Spotify, you can connect Spotify with Google Chromecast and then stream Spotify to Chromecast. This is the traditional method to cast Spotify to Chromecast. However, you could have a try of the ultimate solution to play Spotify music on Chromecast or Chromecast Audio. You could download Spotify playlist to mp3 with TunesKit tool.

To get started to listen to the Spotify playlist via Chromecast, there are two ways to do this. The most common way is to cast Spotify to Chromecast from iPhone or Android devices with the help of the Spotify app and Spotify Connection. The way is available for Spotify Premium users.
Another way for free users is to use a professional Spotify Downloader to convert Spotify songs offline and transfer them to Google Play Music and then use Chromecast to stream Spotify for playback.

Do you have Spotify Premium or not ? if you have Premium,it could easily to achieve,but is you are using the free account you may need to settle for the right tool, that is, Tunelf Spotify Music Converter. It will carefully convert Spotify music to a playable format, suitable for any media player or device. :smiling_face_with_three_hearts: