Idea for Binding: Spotify Connect binding

Hi Hilbrand,

It is nice to see that the binding is updated!
I am also very happy that the album image is now embedded inside the binding. :smiley:

Unfortunately the binding has a bug at my OpenHAB.
The data is only updated when a track is started/paused or skipped from within openhab.
When Spotify is controlled form elsewhere (e.g. my pc) the data (title, artist and stuff) isn’t updated. :frowning:

Also the player bridge keeps switching between online and offline as I can see in the log. I hope you can help me with it, if you need more information about the bug I would like to hear it!

Also I really miss the custom Spotify request which was available in version 2.2.0, because I use this to retrieve a list of my playlist into openhab. Is there a reason why you deleted it?

  • Jordo

It should update the track info when controlled from elsewhere, this might indicate it doesn’t poll correctly. And might be related to the bridge switching on/off. Can you run it with log level DEBUG and see if that gives any more details. If you had an earlier version you might try cleaning the cache.

I’m not sure what you mean with the custom Spotify request I don’t think I removed anything. I’ve only set the trackPlay channel to advanced. Meaning it doesn’t show up by default in PaperUI if you add it. But you can enable it by configuring it in the edit mode of the item in PaperUI under channels Show more. Can you give me some more information on what you mean?

Thanks for your fast reply!

I will try the logging tomorrow and let you know if I can find anything. About the cache, which one and how can I delete it, because I just removed version 2.2.0.

In version 2.2.0 (they were already removed in 2.2.3) there were two items named “CustomRequest” an “CustomReply”. With the custom request you could make an API call to the Spotify servers for things like playlist information or more detailed information about an album (depending on the request).

The json answer from the server then was stored in customreply. With these 2 items it was possible use every api function of the api without them being in the binding.

I hope it is more clear this way.
Otherwise let me know.

  • Jordo

The cache is the folder in the samba map openhab2-userdata/cache. You can remove/empty the cache folder (you might need to stop openhab to make it possible)

I’ll check the history of the binding development to see if I can find it back and see why it was removed.

Ah, thankyou!
I will try this in combination with the debug log and keep you updated.

I am curious if you can find something.
Maybe I can send some screens or something if not.

  • Jordo

Try first cleaning the cache and if that doesn’t resolve the issue enable debug.

I can’t find anything about it. In the pull request history, which I continued developing I can’t find no such channel. On the other hand it’s still possible to do something like this. There is the acccessToken channel which can be used to construct a query, possible via exec or http binding (not sure which, haven’t used them). In this thread you can find other people doing this. Although this might run into scope rights. I changed the default access scopes requested by this binding to only what is needed by the binding itself. So it won’t ask for access to read private playlists. This might be a cause of the problem?

I cleane the cache
Sometimes the sync. continues. Sometimes not, so I will try it with the debug editor.
Nice function though that the song progress keeps track!

Hmm, weird, I really used it until yesterday haha.
Can send you version 2.2.0 if you want to see it?
Otherwise I will use the exec binding with curl or something indeed.

This can give problems for that yes

Can I change the default scope if I want?

I did some more searching. I found a reference to it in the binary repository: GitHub - astenlund74/org.openhab.binding.spotify-binary: Binary build of the org.openhab.binding.spotify
But nowhere in the code I could find it. It won’t be difficult to add I think. Also I think I’ll add a channels to get the list of playlists/albums/artists. This seems like a useful addition.

Only by changing the code of the binding I think. One option for me could be to change the code to simply add all scopes.

Hmm, weird that the code has no components in it for this function.
As specially because it worked very well.
But a function the retrieve things like playlists and the url of the album picture would be really usefull.

Would be nice if that can be a setting or just ask permission for all player related things.

I have debugged the binding and received an unexpected error during poling (in info log)
I will send it to you in a private message.

UPDATE
Latest version is working okay now

An update on the Spotify binding (new jar available at the same place as before):

  • Added playlist channel that is propagated with the state options of the playlists and will show the name of the playlist in case a playlist is being played.
  • Changed deviceName channel. It will is also propagated with the available devices and can be used to transfer play to another device by setting the Spotify device id as string argument (id is key, name is value).
  • Internally I’ve rearranged the code to be (more) compatible with the new OAuth2 interface of ESH. But since the ESH implementation would required some changes to work the ESH interface is not used (and would also make it impossible to use the binding with older version of openHAB). There need to be some updates to the documentation and some readability and therefor these changes are not yet pushed to the pull request.

With the deviceName channel changes it’s looks like the need for a thing for each specific player is not really adding any value. Everything can be done from the bridge thing I think. So I’m doing some more research if these player specific things are needed anyway, and if possible just remove them. So if you have any opinion about it let me know.

Hi @hilbrand, I’m looking forward to give your Spotify binding a try. Unfortunately I seem unable to install it, using manual (configuration files and Karaf console).
I copied the jar file to the addons directory and it did not get picked up. I did make sure to set the rights correct. The OH daemon is running under openhab user and the file has RWX for that user and is owned by that user and group:

:/opt/openhab2/addons# ls -al
total 100
drwxrwxr-x 2 openhab openhab  4096 Oct 17 17:30 .
drwxr-xr-x 6 openhab openhab  4096 Oct 14 22:13 ..
-rwxrwxr-x 1 openhab openhab 85154 Oct 17 17:46 org.openhab.binding.spotify-2.4.0-SNAPSHOT.jar
-rw-rw-r-- 1 openhab openhab    70 Oct 12 15:30 README

When trying to install manually in Karaf console with bundle:install org.openhab.binding.spotify it gives an error:

openhab> bundle:install org.openhab.binding.spotify
Bundle IDs:
Error executing command: Error installing bundles:
        Unable to install bundle org.openhab.binding.spotify: org.osgi.framework.BundleException: Error reading bundle content.

bundle:info org.openhab.binding.spotify gives:

openhab> bundle:info org.openhab.binding.spotify

Spotify Binding (240)
---------------------

Any idea what’s wrong?

It should pick up the binding directly if you place it in the addons folder. If I type the commands you mentioned I get the exact same message, and on my system the binding is installed. What version of openHAB are you running? Possible clear the cache and see if that makes a difference. Or try installing another binding in the addons folder and see if that gives the same problems. See what bundle:diag and/or bundle:status gives are result.

Hmm, a simple restart of OH fixed it. I run 2.4.0-SNAPSHOT Build #1389, btw

@hilbrand could you set this up as a marketplace binding?

Good idea: https://marketplace.eclipse.org/content/spotify-binding-beta

Ok can you scope it to run on 2.3 stable?

I think it should run on 2.3. I haven no 2.3 installation present so can’t test it right now, but do you have problems installing it?

I think he means that you need to mention it as stable in the market. By then people who have there market settings set on stable can download it too.

I don’t see it as a marketplace binding in paperui- assumed this was why?

Thanks
Andrew

If you set your market settings to beta. You can find the binding in the paperui.

  • Jordo