openHAB integration to Spotify Web Connect API (player)

Fixed it. I had to empty the access token fields by setting them to NULL. Unreal… so annoying lol! Then I reauthed and it worked

can you please tell me how to do that?

Did you run the script? post your results after executing it because I dont know what the problem you have is.

Hello! My spotify.py is not working! I installed everything right! When I run “Python spotify.py play”, everything updates correct, I see the the device where spotify is open, I see the song that has been paused, but spotify doesn’t start playing.

Successfully posted state to OpenHab: spotify_current_track = Billionaire (feat. Bruno Mars)
Successfully posted state to OpenHab: spotify_current_artist = Travie McCoy
Successfully posted state to OpenHab: spotify_current_cover = https://i.scdn.co/image/73d8767c4e95067253383308046e48a02be0cc49
Successfully posted state to OpenHab: spotify_current_duration = 211160
Successfully posted state to OpenHab: spotify_current_progress = 43527
Successfully posted state to OpenHab: spotify_current_playing = OFF
Successfully posted state to OpenHab: spotify_current_device = MY-LAPTOP
Successfully posted state to OpenHab: spotify_current_volume = 100
Successfully posted state to OpenHab: spotify_current_context_uri = spotify:user:1110568069:playlist:6nRDPUcRygLtf6XhSFbyWB
Successfully posted state to OpenHab: spotify_current_device_id = 61bb4283f3ea2b4b636537f8c54f8f87bc9b1c4f
Successfully posted state to OpenHab: spotify_current_progress_percent = 20.61
-> Success
Successfully posted state to OpenHab: spotify_lastConnectionDateTime = 2018-09-05T08:33:25+0000
Done in 1.81030702591 seconds

Hi Guys,

I’ve tried so setup Spotify. But in step 7 I received this error:

pi@raspberrypi:~ $ bash /etc/openhab2/scripts/spotify.py
/etc/openhab2/scripts/spotify.py: Zeile 5: import: Kommando nicht gefunden.
/etc/openhab2/scripts/spotify.py: Zeile 6: import: Kommando nicht gefunden.
/etc/openhab2/scripts/spotify.py: Zeile 7: import: Kommando nicht gefunden.
/etc/openhab2/scripts/spotify.py: Zeile 8: import: Kommando nicht gefunden.
/etc/openhab2/scripts/spotify.py: Zeile 9: import: Kommando nicht gefunden.
from: can't read /var/mail/myopenhab
from: can't read /var/mail/myopenhab
from: can't read /var/mail/myopenhab
/etc/openhab2/scripts/spotify.py: Zeile 16: ACCOUNT_URL: Kommando nicht gefunden.
/etc/openhab2/scripts/spotify.py: Zeile 17: API_ROOT_URL: Kommando nicht gefunden.
/etc/openhab2/scripts/spotify.py: Zeile 18: REDIRECT_URI: Kommando nicht gefunden.
/etc/openhab2/scripts/spotify.py: Zeile 19: VOL_INCREMENT: Kommando nicht gefunden.
/etc/openhab2/scripts/spotify.py: Zeile 21: Syntaxfehler beim unerwarteten Wort `('
/etc/openhab2/scripts/spotify.py: Zeile 21: `class spotify(object):'```

What is the problem? What is wrong?

Thanks!
1 Like

Sorry no answers to the script problem, just hijacking this thread to inform about the new Spotify binding :smile: . I’ve picked up development and have a version that is available for test/usage. More information, updates and feature request can be found in the Spotify binding thread: Idea for Binding: Spotify Connect binding

1 Like

i stuck here too…try it since hours, can anybody help please?

Hi,

I am at a point with my OpenHAB installation to enable additional services so also I want to add Spotify. I tried several times but my test run of the python script still stucks at this point:

[21:39:07] openhabian@openHABianPi:/etc/openhab2/scripts$ sudo /usr/bin/python /etc/openhab2/scripts/spotify.py
Successfully got state from OpenHab: spotify_client_id
Successfully got state from OpenHab: spotify_client_secret
Successfully got state from OpenHab: spotify_access_token
Successfully got state from OpenHab: spotify_refresh_token
Successfully got state from OpenHab: spotify_token_issued
Successfully got state from OpenHab: spotify_token_expiry
-- Calling Service: Update
 -> Failure:  <type 'exceptions.ValueError'>
Successfully posted state to OpenHab: spotify_lastConnectionDateTime = 2018-10-07T19:40:08+0000
Done in 0.319853067398 seconds

I tried it several times and changed my setup and tried again but still the same issue. I noticed that some others also got this issue but I don’t find a suitable solution for this.

Can you help me?

Can anyone help?

I don’t know how to help you with the python script, but you could try the binding mentioned in the post above😊

1 Like

Hi,

Thanks. I haven’t seen this but I will give it a try. Thank you

I was able to get all the way through this set up but i am like the others and can’t figure out how to get this running through habpanel. Anyone have any idea?

I cannot for the life of me figure out where to add the client_id and secret_id. Can someone point me in the right direction?

I’ve spent probably upwards of 20 hours trying to figure this out. I’m willing to do the work to learn how to do all of this stuff…but it’s incredibly difficult for me to find the right reading/learning materials for anything beyond the wiki documentation. So if anyone has suggestions for the best way to learn, going forward, i’m totally open to that too.
Thanks!

Thanks

Did you try installing the Spotify Binding? It’s available in the Eclipse Market Place? I don’t know if someone already ported the widget in the topic to be usable with the binding, but you can also use:

Thanks for responding. Yeah I should have mentioned this one. I was able to figure the one you just linked this morning andgot it into habpanel. But I was hoping to have more flexibility re: choosing devices and selecting certain playlists and such. And now that I have to type this out i’m questioning my decision to use something that looks like it’s not getting updates…

Ultimately, I want the ability to pick and choose devices, play certain playlists, etc in habpanel. Does this exist? if it not, where would I begin in terms of learning how to make it myself?

The Spotify Binding supports both play lists and list of devices. I guess it’s possible to either start with the widget of this topic and the one I mentioned and modify them. This can be done in happanel itself. It’s a little bit hard to find. If you have added the widget: in edit mode of a panel, in ‘add widgets’ down in the list click on the small ‘wheel’. This should show you the page of custom widgets. Clicking on the widget opens it in edit mode and then you can add playlists and select devices (devicename as a selector)

I see, that makes sense. I just went in and started playing around with those, and at those point that’s good enough for me. great actually.

Thanks for taking the time to get me going in the right direction again, I really appreciate it!

Hi Guys. Does anyone know how to make the active device name show the name of the device instead of the numeric value?

With openHAB 2.4 and the lastest version of the Spotify Binding it should just show the name (With Selection in sitemap you can make it selectable)

Hmmm. I am on openhab 2.4 and i installed the binding from the eclipse iot store. I’m trying to get this to show in habpanel and not on the sitemap. Is there something im doing wrong or is there a newer version of the binding?