Idea for Binding: Spotify Connect binding

Tags: #<Tag:0x00007f0148a74388> #<Tag:0x00007f0148a74248>

(Jordo) #143

My application was not meant for parsing it into HTML.
I found a script on the internet for retrieving the background color (like the one showed on screen by chromecast), based on the image.

But i will test it if the data will work in an html image tag.
Is this what you mean?:

<img src="data:image/jpeg;base64, IMAGEDATA" />
  • Jordo

(Hilbrand Bouwkamp) #144

Yes that’s correct.

(Jordo) #145

This works when parsing the string into the image src tag.
But for the other application i mentioned, I need to decode the image first.
But that is not what the binding is meant for haha.

Thanks for help!

  • Jordo

(Gytis) #146

Thanks for the binding, all working fine.

Now what I would like to do is create some sort of UI in habpanel that would allow me to select the playlist, or album or category to play. There is no such channel afaik in in the binding, so I would have to create it.

Binding provides spotify:player:spotify:accessToken so I can use that to access spotify API. Now afaik i have two options:

  1. Implement this whole thing in habpanel widget on client side only (checked cors headers - all seem to be good)
  2. Implement it on server side via rules and commands (e.g. with cron time, fetch user playlists, albums and store them as JSON responses in item config, and them parse them on the client side and render)

I’m somehow leaning more towards the 1) solution, but maybe someone has already done this?

(Hilbrand Bouwkamp) #147

Playlist is available in the binding, but album or category not. I would also go for 1 because otherwise you probably keep polling the data in the background, while it probably won’t change that much. (Having a playlist channel, might already be a bit of an overreach). I’ve not checked, but the spotify api has a lot of access rights options. The binding request only access to what it needs, so you might have access problems. If that is the case let me know and I’ll update the binding.

I don’t know if somebody has done it. There is a habpanel widget that was developed before the Spotify Binding was developed that uses a python script (openHAB integration to Spotify Web Connect API (player)). That widget could serve as a starting point (it should become simpler as parts of that widget are handled by the binding and no need to install python or configure the python script). I don’t know if someone has worked on it, it has been referred before but I’ve not seen an updated version.

(Simon) #148

Actually this is my first post here…
I´ve a more generic question - after reading and implementing Hilbrandts spotify binding:
The UI implementations work perfectly when having a native spotify client engaged.
I want to conrtol spotify only via the OH UI and use rasperry attached soundbar.
Trying to have “only” the openhab based Client doesnt startup anything (SpotifyPlayerbridge_ActiveDeviceName doesnt update to the Spotify Connect Device Thing).

BTW: My Spotify Bridge is working as it nicely updates the token upon “Authorize Player” on http://<my_raspberry>:8080/connectspotify

Thanks for your time and quick feedback!


(Hilbrand Bouwkamp) #149

This seems a recurring issue. Some devices don’t seem to be visible on the spotify api when not played via something like the spotify app on a phone. Possible because the device itself doesn’t communicate with spotify. Then the spotify app once active reports it to spotify and then it’s visible. It’s probably also not possible to play on such device when playing from the browser.
A solution is to have always some program running that’s making the device visible via the spotify api. I don’t know if this can be done depending on what spotify application you install on the raspberry pi.
In case you want to see details you can enable trace or just call the spotify api to get a list of devices directly with the accestoken that the binding has available in a channel.

Starting a Spotify Playlist on Chromecast
(Gytis) #150

… and it works, together with Spotify Control widget, good enough. Sadly though spotify does not expose Editor Picks, Made for User, or any other advanced categories.

Auth token scope is enough for getting your user info and your playlists. So all working fine. the only issue remaining - I see my controller loading twice and therefore executing requests twice to spotify. Probably could solve that with angular $http built in cache

(The Generator) #151

Hello everyone,

I have installed the binding and it seems to be working with one device (my iphone) so far.
Here lies my problem: I have 4 Sonos-Speakers, I would like to add as new devices.
In the Spotify-Iphone-App, the Sonos-Speakers are always visable and directing sound to the sonos speakers works without a flaw from within the app.

Unfortunately the API seems not to be aware of the Sonos-devices:



  "device": {
    "id": null,
    "is_active": true,
    "is_private_session": false,
    "is_restricted": true,
    "name": "Wohnzimmer",
    "type": "Speaker",
    "volume_percent": 31


  "devices": [
      "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "is_active": true,
      "is_private_session": false,
      "is_restricted": false,
      "name": "iPhone",
      "type": "Smartphone",
      "volume_percent": 100

It seems the API is aware of the device “Wohnzimmer” but has no ID wheras “iPhone” (id xxxx’d out) seems to be the only one working device.

I assume this must be a problem with the spotify api, or am I missing something?

There has been a discussion on github about “adding devices to spotify”:

… and some “workaround” utilizing the Web Playback SDK:

Has anyone the same issues, or some advice?

Cheers and happy new year,

(Marc) #152

hey i know its been a while since you posted that, but did you find a solution? i have the same issue atm. thanks in advance

(Andrew Pawelski) #154

Nope all I get is the device Id I have given up on this binding

(Marc) #155

hm. thats bad - anyone else maybe hast a hint on this?

(Unparagoned) #156

I played about with @pmpkk cool python script and opehab panel. I’ve modified both significantly for various features, like making the script able to handle various inputs so you can stick voice commands straight into it. So now since device ids do change, you can type part of the device name instead. That way the command “play Bathroom” works much more reliability than the device id and it much easier to to use in rules.
But my main aim is to to make something that lets me collect and search across my songs. It’s kind of ridiculous that it’s impossible to easily search across or even view all your songs. They had a great menu item called “My Music” which had all your songs from your playlists and that you had starred. Then got rid of it… Now the best chance you have is if you don’t listen to music and the songs feature with a max of 10k is sufficient for you.
I was wondering if it’s worth trying to port some of the features over? I’ve never worked directly with binding before but just used rules and scripts to do my thing.

(Andrew Pawelski) #157

Hi have you posted your script and mods on habpanel posts? I too use this as I can’t get this binding to work for me with names and would be very interested in expanding the use of what I have working in habpanel