Idea for Binding: Spotify Connect binding

spotify
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(SpotifyDeviceHandler.java:99) ~[?:?]

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

	at java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90) ~[?:?]

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

	at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) ~[?:?]

	at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498) ~[?:?]

	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) ~[?:?]

	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[?:?]

	at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230) ~[?:?]

	at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196) ~[?:?]

	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]

	at java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:449) ~[?:?]

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

	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) ~[?:?]

	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[?:?]

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

	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[?:?]

	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[?:?]

	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[?:?]

	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[?:?]

	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]

	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[?:?]

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

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

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]

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

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

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]

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

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]

==> /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

@hilbrand

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.