openHAB integration to Spotify Web Connect API (player)

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:

Thanks @pmpkk ,
great work for this tutorial. I could keep it running :heart_eyes::heart_eyes:

OpenHab enthusiasts, has anybody solved the keep alive issue of Spotify devices? I tried to implement a rule that sends a volume command to the device every hour but still the device goes offline over night (my intention is to develop an alarm clock that plays music over a spotify connect device).
Thanks!

Hi Alan i assumed you used rules to do this, do you have examples of sending commands in rules to spotify_action, such as play with a URI because its not documented anywhere. Ive tried about 10 different ways, all fail.

I have reached this stage:
“Give the client id and secret to OpenHab”
how do I do it?

These question was never answered, and was looking for this.
Late but better than never, yes you need premium for playback function (start/stop/pause/,…), see:

a 403 FORBIDDEN response code will be returned together with the PREMIUM_REQUIRED reason.

1 Like

I have this problem when using the Spotify Binding too, but if you have other devices like Alexa or a Streaming System like Raumfeld then you need to start playback from there and voila, the binding is responding again.

Is it possible to control spotify on my sonos one and sonos play 1 as well?