Spotify Connect Binding

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.
5 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)

1 Like

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!

I had something similar. It looks related to the http timeout I reduced. It looks like this causes it to silently stop. I’ll look into this. In the mean time I’ve updated the binding in the market place with a new version that uses a larger timeout. This should fix the issue.

There is a volume channel on the player bridge. But I don’t think you can set the volume if no device is availble.

The channel playlists has all playlists. playlistName shows only the currently playing playlist.

Thanks for the fast reply hilbrand. I couldn’t see it in your readme file or am I blind?

For some reason, my channel for playlists is either blank, or displays only 1 string.

Search for deviceVolume

Where do you see this? For example if you use this in a sitemap it should be a Selection

Hi Hilbrand i see this in the oh2 console

I assume that is a limitation or intended functionality of the console. It only shows the selected playlist or nothing if no playlist is selected. If you query via the rest api you would get a list of playlists. That is something that a widget can use.

Fair enough! Heres hoping someone developers a lovely HabPanel widget for this. That’s been my biggest hurdle. It’s very difficult to map over to Patrick’s widget. I had a good 4hr stab at it, but I couldn’t get the widget to populate the playlist names or the devices.

Nor can I get your sitemap example to work

09:31:46.309 [WARN ] [del.core.internal.ModelRepositoryImpl] - Configuration model 'spotify.sitemap' has errors, therefore ignoring it: [4,5]: mismatched input 'Player' expecting '}'
[16,3]: missing EOF at 'Frame'

I did a check of the sitemap example. It looks like the example is not correct. It works when usingDefault instead of Player in sitemap. I’ll update the readme.

There is another widget to show playlists that should work with this binding:

1 Like