openHAB integration to Spotify Web Connect API (player)

Its difficult to explain whats occuring, but basically nothing is working in the HabPanel app

I cant change volume etc, but as mentioned the script was 100% successful.

Ive no idea where to look, any thoughts?

Hi, I installed everything and the details are being shown, but the control buttons are not working. Any help? Thanks

Havent given up! lol Ive checked my redirect URI, its accurate. Auth works fine… just this token stuff! driving me BONKERS!

So i removed the spotify app and recreated it. Ran through it all and now I get token expired :confused:

I deleted and recreated the items also. And recreated the app inside the developer console.

kris@openhab2:~$ /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 Token Refresh Service
{'client_secret': 'XXXXXXX', 'redirect_uri': 'http://XXXXX:8080/static/spotify-auth.html', 'client_id': 'da428608f68b4dd08bcc0e6df4489ddc', 'refresh_token': 'AQA10dco3Bds-4JLd_oJi-Y4vo63r9Q_JFtp2KdYD1RUcROaR1maK38yoTD0I80iW9r5R3QA2eu4Twf0vToV2BVOKvsycCTOp0XiSK4vE_-jl89sXIIPED-9CsttRTz-EN8', 'grant_type': 'refresh_token'}
{'Content-Length': '63', 'Keep-Alive': 'timeout=600', 'Server': 'nginx', 'Connection': 'keep-alive', 'Date': 'Fri, 31 Aug 2018 11:35:36 GMT', 'Content-Type': 'application/json'}
{u'error_description': u'Invalid client', u'error': u'invalid_client'}
-- Calling Service: Update
{u'error': {u'status': 401, u'message': u'The access token expired'}}
 -> Item node missing from response :(
-- Calling Service: Get Devices
 -> Device List Failure:  <type 'exceptions.KeyError'>
-- Calling Service: Get Playlists
{u'error': {u'status': 401, u'message': u'The access token expired'}}
 -> Playlist List Failure:  <type 'exceptions.KeyError'>
Successfully posted state to OpenHab: spotify_lastConnectionDateTime = 2018-08-31T11:35:36.000+0000
Done in 1.38954114914 seconds
kris@openhab2:~$

Kim did you fix this? ive got the same issue

I have the issue that the data is displaying but the buttons for play, pause, next and volume are not working
Dont know whats the issue. Pls help?

@unparagoned does the Web API need access back into your network for this to work? ie this redirect mechanism

Further what is the access token? is it the very long string printed in the URL after you sucessfully run the spotify auth?

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: