Idea for Binding: Spotify Connect binding

Tags: #<Tag:0x00007fe0660e9d10> #<Tag:0x00007fe0660e9ba8>

(Hilbrand Bouwkamp) #123

@boehan I’ve done some investigation and testing myself and found an issue with starting play of inactive devices. I’ve fixed it and updated the market place binding. If you reinstall the binding from the market place it should work now. Thanks for the feedback, it gave me an idea where to look and identify the problem.

(fuslwusl) #124

I’m using this binding an it works great. But my Amazon Echo gets discovered as an new thing on every restart - so my list of Amazon Echos gets longer and longer. Does anyone have a solution for this problem?

(Hilbrand Bouwkamp) #125

@fuslwusl If a device is getting added every time, it means the identification to identify a device changes every time. It would mean the id changes every time. Can you confirm this is the case? The id is available as the Spotify Device ID in a Spotify Device configuration. It would also mean a Amazon Echo added as Spotify Connect Device Thing before might not be usable anymore as the id has changed. Is that also the case?

(Andrew Pawelski) #126

So i have upgraded to 2.4 milestone 7, cleared the cache and still have the same issue - device name on the bridge shows the UID - anything else I can try?

(Hilbrand Bouwkamp) #127

Did you recreate the thing? By removing it and then add/discover it? In a sitemap configuration you should use Selection instead of Text. But that doesn’t make a difference in PaperUI.

(fuslwusl) #128

Thanx for your feedback. The device was detected with a new device id but it was usable with both thing items. I removed all items and added the devices again and now the problem seems to be gone for the moment. Is there a way to view and if necessary clear some of the detected spotify connect device ids in the openhab database?

(Mikael Lysdahl) #129

@hilbrand, really nice binding you have put together here.
However, I am experiencing some problems getting it to work with my Sonos speakers.

It works fine if i start up my Sonos from Spotify connect on my phone or laptop.
Then i can see it changes the device type from laptop/smartphone to speaker, but the device id does not change, so I am guessing my speakers don’t have their own unique ID.

I tried to start up Spotify though the Sonos app, with the result that the binding can’t see spotify is active and i don’t receive any information (track artist cover etc), and can not either control.

I am missing something here?

(Hilbrand Bouwkamp) #130

I’m not sure what is happening. It might be the Spotify api doesn’t return the device, or returns the information in a way not expected by the binding. You can enable TRACE logging on org.openhab.binding.spotify. This will dump the json returned by the Spotify Api. This will give some insight in what can be expected. If you are unsure about how to interpret the data you can send me the logging (you can send it via a private message) and I’ll have a look. Don’t forget to set logging back to normal (DEFAULT) otherwise your log will be spammed :slightly_smiling_face:

(Mikael Lysdahl) #131

Thanks for your swift reply hilbrand.
I have no clue what to look for in the log, not even sure if got your suggestion executed correctly, my log did suddenly get a LOT of information, so something did happen.

Can you give me a hint what to look for in the log, just so i don’t send you 50000 lines of non usable log lines :smiley:?

(Hilbrand Bouwkamp) #132

You’ll probably see a lot of json data. That’s what is returned by the Spotify API. The refresh rate in the Spotify Bridge Binding is by default set to 5 seconds. You can change this a little higher for the test, because that triggers the large json data sets, and than test specific use cases. and see what the log contains. I should not have a problem browsing through those lines.

(Mikael Lysdahl) #133

I messaged you my log after playing a bit around with the binding.

I found that whatever i do on my HABpanel, play, pause, next, change playlist etc. stops my spotify from playing when i connect to my sonos speaker through my phone or laptop.

Like start up spotify on my phone and start a track -> change device to sonos speaker -> interact with spotify biniding on my HABpanel -> spotify stops…

(Christian) #134

I’m having some issues with the beta binding from market. I can’t get my spotify bridge to stay ONLINE… I see this in my logs every 60 seconds:

2018-12-20 17:14:45.388 [hingStatusInfoChangedEvent] - 'spotify:player:dd997e5e' changed from OFFLINE to ONLINE

==> /var/log/openhab2/openhab.log <==

2018-12-20 17:14:45.571 [INFO ] [nternal.handler.SpotifyBridgeHandler] - Unexpected error during polling status, please report if this keeps ocurring: 

java.lang.NullPointerException: null

	at org.openhab.binding.spotify.internal.handler.SpotifyDeviceHandler.updateDeviceStatus( ~[?:?]

	at org.openhab.binding.spotify.internal.handler.SpotifyBridgeHandler.lambda$8( ~[?:?]

	at$1MatchSink.accept( ~[?:?]

	at java.util.ArrayList$ArrayListSpliterator.tryAdvance( ~[?:?]

	at ~[?:?]

	at ~[?:?]

	at ~[?:?]

	at ~[?:?]

	at$MatchOp.evaluateSequential( ~[?:?]

	at$MatchOp.evaluateSequential( ~[?:?]

	at ~[?:?]

	at ~[?:?]

	at org.openhab.binding.spotify.internal.handler.SpotifyBridgeHandler.lambda$7( ~[?:?]

	at$2$1.accept( ~[?:?]

	at$2$1.accept( ~[?:?]

	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining( ~[?:?]

	at ~[?:?]

	at ~[?:?]

	at$ForEachOp.evaluateSequential( ~[?:?]

	at$ForEachOp$OfRef.evaluateSequential( ~[?:?]

	at ~[?:?]

	at ~[?:?]

	at org.openhab.binding.spotify.internal.handler.SpotifyBridgeHandler.updateDevicesStatus( ~[?:?]

	at org.openhab.binding.spotify.internal.handler.SpotifyBridgeHandler.pollStatus( ~[?:?]

	at java.util.concurrent.Executors$ [?:?]

	at java.util.concurrent.FutureTask.runAndReset( [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301( [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:?]

	at java.util.concurrent.ThreadPoolExecutor$ [?:?]

	at [?:?]

==> /var/log/openhab2/events.log <==

2018-12-20 17:14:45.629 [hingStatusInfoChangedEvent] - 'spotify:player:dd997e5e' changed from ONLINE to OFFLINE

My spotify bridge connect refresh period is set to 60 sec.

(Hilbrand Bouwkamp) #135

@MikaelL From your logging the Sonos device is not available on the Spotify API. This means you can only play it via or the other devices. When playing from the Sonos app I’m not sure what happens. Possible it uses an old Spotify api, meaning it’s not visible in the API used in te binding. I would suspect it also doesn’t show up if you open the Spotify App. You then can’t select the Sonos app or see it’s playing on the Sonos App. Is that right?

(Hilbrand Bouwkamp) #136

@sjef86 I think that was a bug in an older version of the binding (I thought I uploaded a newer version of the binding, I’ll check). Or do you know if you have the latest version?
If I remember correctly this was due to some device player that is added but is not correctly initialized or half deleted. Brute force was to remove all devices and recreate them (Or see which device player thing isn’t correctly configured anymore).

(Sascha Billian) #137

I know this isn’t mainly adressing the binding itself, but has anyone else the problem that the spotify device IDs change from time to time?
I am using two amazon echos, and they tend to go offline when rebooted since the spotify device id changed.
Therefore I have to look for new devices, copy the ID and change the ID on my existing devices
Is there any known workaround for this?

(Hilbrand Bouwkamp) #138

I have no solution for it build in (yet). Maybe also keep track of the device name?

(Jordo) #139


Is it also possible to get the image url instead of the image as image type?
This makes it a lot easier to use it in custom widgets or on external UI’s.

  • Jordo

(Hilbrand Bouwkamp) #140

Technically it’s possible, but the binding doesn’t support it. I’ll have a look into it. But would it make it a lot easier? For example you can pass the state data from the image channel directly into a HTML image tag as src and that would work. That’s not different than passing a url.

(Jordo) #141

Hmm, I have to take a look for that then.
For an other script I also fixed it, I converted the base64 to an image to process it.
Thanks though!

  • Jordo

(Hilbrand Bouwkamp) #142

If your passing it to html I don’t think you should need to convert it. Let me know if it works for you by passing the data directly.