openHAB integration to Spotify Web Connect API (player)

hey, did you find a solution to your problem? I am facing the exact same issue.

Hi, can anybody please give me a hint?
I installed the binding and configured the bridge with the ID and the SECRET. But when I go to http://openhabianpi:8080/connectspotify nothing appears. In the openhab.log I find: {“error”:“invalid_grant”,“error_description”:“Invalid refresh token”} - verify that Spotify Client ID and Client Secret are correct! But I just copied from spotify dashboard…
Thank you!
Pascal

What did you install? Because the connectspotify page should work and you need it to get the refresh token.

I copied org.openhab.binding.spotify-2.2.0-SNAPSHOT_20170910.jar to \OPENHABIANPI\openHAB-share\openhab2-addons…That was all I did

On http://openhabianpi:8080/connectspotify I get no error but just a blank site

I’ve just seen, I must install from market place…now it works!

1 Like

Hi there,

I recently installed the spotify binding and i really do like it! I just have one thing i’ve been trying to figure out: is it possible for me to create an item called remaining and see the time remaining on the song there like M:ss? If yes, how do i do that?

Thanks in advance,

jvank

Hi i am new as well… and still at your point 5…

how you get it managed to write in the spotify_client_id and secret?

Thanks for help…

Frank

hey there=)

U can do it with the console however since I didn’t get that to work yet I recommend to just use spotify_client_id.sendCommand(“XXX”) and so on for the secret and then trigger this rule with a Switch Item

Hey,

thanks for that integration.

Where can I find the custom Widget shown on the screenshots?
I somehow did not manage to find it on github.

The op isn’t that long has has like two links… Everything you want is clearly explained and has links.

Edit: I’m a dick the second link is dead. I thought it went here Matrix Theme for HABPanel

saidly the link is dead and the other Widget i found in the comments doesn’t show anything it all. What am i missing here?

Sorry my bad I just assumed it went here

@bulletprooffool saw your comments on shuffle.

I thought we could just send ‘shuffle’ or ‘shuffleoff’ to spotify_action but no?

Be keen to know how you do it. I’d like to create a button for shuffle. I copied your modified script but it broke things entirely! Couldnt even play, reverted back and its OK again.

Which sections are required to be added for shuffle support?

Cheers

@bulletprooffool still alive :smiley:

@bulletprooffool can you tell us more about how you got shuffle to work? Ive tried for days LOL please!

Hi and sorry for not replying.

Did you replace the code in your python script? (see post 166 above) You need to make sure that the script remains executable etc.

You’ll need the exec binding (which I assume is already going for you to be able to run the python script)
Also, if you edit the script, make sure to verify the executable state and ownership of the file.

Once you have done that, create some items in your items file:

String spotify_shuffle_state

Switch spotify_shuffle

Shuffle on is:
/usr/bin/python /etc/openhab2/scripts/spotify.py shuffle

Shuffle off is:
/usr/bin/python /etc/openhab2/scripts/spotify.py shuffleoff

you could create simple rule like:

rule "Map and update spotify shuffle status"

when

Item spotify_shuffle_state changed

then

logInfo("INFO","spotify_shuffle_state : "+ spotify_shuffle_state.state);

if(spotify_shuffle_state.state == "True"){

    spotify_shuffle.postUpdate(ON)

}

if(spotify_shuffle_state.state == "False"){

    spotify_shuffle.postUpdate(OFF)

}

end

and

rule "Map switch change to post spotify update"

when

Item spotify_shuffle changed

then

if(spotify_shuffle.state == ON){

    executeCommandLine("/usr/bin/python /etc/openhab2/scripts/spotify.py shuffle")

}

if(spotify_shuffle.state == OFF){

    executeCommandLine("/usr/bin/python /etc/openhab2/scripts/spotify.py shuffleoff")

}

end

If you really wanted you could reduce that to a single rule, or even just bind the actions to the items.

I now use the newer Spotify binding from Spotify Connect Binding available which works trial well, but if you are happy with what you are using, there is no real need to change it.

Good luck :slight_smile:

Fantastic! thank you :slight_smile:
Ill give this a go! Appreicate the informative reply Alan

Hi @bulletprooffool
Thanks

Got it working! by sending True or False to the string item :slight_smile:

@patrick

I cant seem to get this to function. Clearly I dont understand how to send this.

Ive managed to find the URI figures for each playlist, but the update or send command doesnt trigger the playlist.

smarthome:update spotify_action play “spotify:user:spotify:playlist:37i9dQZF1DX8jkCXwOBEz9”

or

smarthome:send spotify_action play “spotify:user:spotify:playlist:37i9dQZF1DX8jkCXwOBEz9”

Any guidance please :slight_smile: