Spotify Connect Binding available

Tags: #<Tag:0x00007f387edf3f28>

This topic is to give some visibility to the Spotify Binding, If you search for Spotify Binding you will get all kinds of hits, from python scripts to widgets, and some threads about the binding, but they contain mostly old links. And none that promote this new binding as it is available. This binding was initial developed by @astenlund74 and I continued his work

For anyone wanting (or using) Spotify with openHAB there is a Spotify Binding available. While this binding is not yet part of any release, it’s very easy to install the binding because it’s available in the Eclipse Market Place.

To install the binding, enable the Eclipse Market Place in Configuration system with maturity level beta and than the binding will be available in the list of bindings in PaperUI.

The documentation for this binding can be found here (Once the binding is merged I’ll update the url):

Note: The binding in the Eclipse IoT Market place uses the OAuth2 module of openHAB that has been made available in openHAB verison 2.4.0. An older version of the binding is still available, but it won’t be updated with fixes: https://github.com/Hilbrand/openhab2-addons/releases/tag/spotify_old

If you have the updated version of the binding from the Eclipse IoT Marketplace that supports the deviceName as id make sure you have the version that shows in the title Spotify Binding (Beta 30/04/2019 21:00) or a later timestamp

I’ll be updating this message when the binding status in openHAB changes.

6 Likes

Hey there=)

somehow I can’t see the binding in the paper UI. I installed the market place and even with Production/Stable level I can’t see the binding in the PaperUI, even after a reboot of OpenHAB. I made sure that “Include Bindings” is turned on. Do you have any idea?

Did you try the level that I suggested: Beta The level Production/Stable is higher than Beta level. So anything on Beta level is not necessarily available on Production/Stable level. So in this context by using the word even you seem to wrongly interpret how levels work.

If I was able to read I wouldn’t have this problem, all fixed
Thanks!^^

1 Like

Dear Hilbrand, thank you for your great binding. It’s working very well.

The only issue I have is that contrary to the spotify app on PC or mobile devices it does not allow to easily select the active device with habpanel.

I was wondering if it could be possible to make “deviceName” a R/W channel so that we could select the device to play on.

I have also noticed that “deviceName” does not provide the spotify nickname of the active device but it gives the same information than deviceId. Could that be fixed?

1 Like

Looking at the binding documentation, it seems like you can already do this:

deviceName - Name of the currently active Connect Device, set the device ID to transfer play to that device.

I just tried it and it does work with Spotify clients on phones and PCs when the app is running. Changing it to a Google Home device sadly doesn’t work, but I think this is due to the architecture of the devices. Spotify doesn’t have any control over it the moment you change the running “cast app”.

Does anyone know whether it’s possible to force the Home Mini/Chromecast to launch the Spotify app?

The deviceName description is conflicting with the fact that deviceName is a read only channel. it only gives the name of the active device but does not allow to change it

Yes the description seems to be wrong. It’s not read only.

I am confused… I am using Paper UI and when I configure the Spotify Player Bridge Thing I have only the option to show the Active Device Name channel that is a read only channel.

I could not find a read/write Device Name channel.

There is a DeviceID channel with read/write. For me this works just perfect.

I may not look at the right place but attached is the list of all available channels I could see in Paper UI for the Spotify binding. Are you referring something else?

Nope, the second one from the top, Active Device ID, this one puts out the same info as Active Device Name but works as a read/write channel

My Bad, I was looking for a text field on the right of Device Name and never looked at the list below… so stupid of me

I’ve made some changes to the Spotify binding. The new binding is available in the Eclipse IoT Market place

Note 1: This changes some of the channels. So it requires the things to be readded
Note 2: This version depends on OAuth client in openHAB and therefore requires openHAB 2.4.0 or higher

  • The deviceName was a option list with id as key, name as value. However that is not usable in rules. In rules only the id can been seen, so it’s impossible to create a rule that checks on a name.
    This change adds a new channel devices specific for selecting and changes the deviceName channel back to only displaying the name.
    Also changed it’s possible to select a player by setting the deviceName or deviceId.
  • For playlists this was the same problem. Therefor a new channel was added playlists that can be used to select a playlist.
    Another new playlistName channel is added that shows the name of the playlist being played.
  • Changed using the device name as representation property instead of the id. This because some devices get a new id when rebooted.
  • Fixed the bug were the derived playlist name from the playing status didn’t match with the id in the selection list. As a result of that problem when selecting a playlist and the active status was returned the playlist didn’t show what playlist was playing.
4 Likes

Thank you, hilbrand, for the awesome work - it’s highly appreciated!
There’s a minor error in your example in the github-readme:
The first and third items in the spotify.items have the same name (Player spotifyTrackPlayer) which caused a warning.
Would you like to have a pull request on github for this? I never did one but if it saves you even a minute of work to say “yes” than do it yourself I’ll happily contribute!

And one question: Do you have an idea how to DennisVonDerBey mentioned challenge with casting to a chromecast or similar? You mention in the readme that they’re not visible when not active and even when added manually as a device I have no idea how to get a ruleset in place to wake up the chromecast device, transfer spotify over and then take control via your … thing :smiley:

Any hints or research sources are welcome.

Cheers!

Thanks for pointing this out. I’ve updated the docs. Since the pr is still open it was simple to just add it.

I have not specifically looked into this. I think it was possible with the chromecast binding. Maybe a rule that triggers on change to play, send signal to chromecast, than schedule another play command after some time to give chromecast some time to wake up.

Hey @hilbrand,
I’m not sure if I stumbled upon a bug or it’s a user error>
While most API-calls work just fine, including cover art and Progress I’ve found a few which are simply never populated:

  • trackDurationMs
  • trackDuration
  • trackNumber

All others which I tested work just fine and update live (e.g. trackProgress, album cover, names, etc).
The only pattern for them I’ve noticed is that all of those have an underscore in the spotify API (track_number, duration_ms, etc). Not sure if that helps though.

The (working, except those three) configuration is:

Player spotifyDevicePlayer	"Player"	{channel="spotify:player:user1:devicePlayer"}
String spotifyDevices       "Active device [%s]"   {channel="spotify:player:user1:devices"} 
Player spotifyTrackPlayer   "Player"               {channel="spotify:player:user1:trackPlayer"}
Switch spotifyDeviceShuffle "Shuffle mode"         {channel="spotify:player:user1:deviceShuffle"}
String spotifyTrackRepeat   "Repeat mode: [%s]"    {channel="spotify:player:user1:trackRepeat"}
String spotifyTrackProgressMs "Track progress: [%s]" {channel="spotify:player:user1:trackProgressMs"}
String spotifyTrackProgress "Track progress: [%s]" {channel="spotify:player:user1:trackProgress"}
String spotifyTrackDuration "Track duration: [%s]" {channel="spotify:player:user1:tackDuration"}
String spotifyTrackName     "Track Name: [%s]"     {channel="spotify:player:user1:trackName"}
String spotifyAlbumName     "Album Name: [%s]"     {channel="spotify:player:user1:albumName"}
String spotifyArtistName    "Artist Name: [%s]"    {channel="spotify:player:user1:artistName"}
Image  spotifyAlbumImage    "Album Art"            {channel="spotify:player:user1:albumImage"}
String playlists            "Playlists [%s]"       {channel="spotify:player:user1:playlists"}

Thanks again for the work! Let me know if I can do something to get more information (or if I made a mistake)

Cheers!

(edit> fixed the file)

Hey!
Does anyone else receive this bug?


Channels, item names and everything else are good. Item linking was enabled when creating all items.
The items from my sitemap arent linked properly to the item definitions …

PS:
It was the item linking, delteded and recreated the bridge and it works fine.

Hello Hilbrand. I have some trouble with the latest Beta version.

I have noticed that the Spotify Player Bridge get stuck (not responding to any commands) after few minutes of playing with it in PaperUI while the previous version was working without any problem.

Is 4326451 - 1.0 the correct binding version?
Is there any specific actions to install correctly this update?
How could I reset it ?
Thanks in advance for you help

Hi All

Does anyone know if volume, for whatever the currently playing device, or no device is available? I dont want to adjust volume per device, just overall.

Further, in Patricks spotify python script he had an Item which was a string that held ALL the playlists, is this available? I can see the playlists and playlistName only show the current playlist.

Thanks!