Idea for Binding: Spotify Connect binding

spotify
binding
Tags: #<Tag:0x00007f014d18fd80> #<Tag:0x00007f014d18fbf0>

(Matthew) #22

Hey guys, I’ve taken over development of the spotify binding from @astenlund74

I’m just starting to dig into the code but I’ll see if I can fix this “after an hour” issue first :wink:


(Matthew) #23

@Jordo @fuslwusl I’ve been testing the binding for a few hours now and I can’t reproduce what you two are describing.

I’ve added the binding into my Jenkins build server: org.openhab.binding.spotify-2.3.0-SNAPSHOT.jar

Can you guys update to the latest version and see if you still have the same issue?

Thanks!


(Christian) #24

Hi Matthew,

I’ve been in contact with Andreas @astenlund74 several times, regarding the spotify binding. I struggle with the same timeout problems. We were thinking that the problem occurred when starting playback from a mobile device, with screenlock function activated. But I got the same issues when starting playback from my htpc which is on 24/7. I have not spent too much time on this since then. I can provide some logs if you are interested?

Best regards
Christian


(Matthew) #25

So now I’ve been able to reproduce this. I’ve setup a separate TRACE level log file on my OH2 instance to try and capture what’s going on here. We will get to the bottom of this :wink:


(Jordo) #26

Sounds great you have reproduced the bug. If i can do something to test, let me know!

Note:
The song title and stuff will continue update (for another hour) after restart the binding. Looks like some sort of time out. The commands are event based. So they cannot time out i think.

Question:
How do i update the binding? I have added it manually.


(Matthew) #27

The way I’ve always done it via the SSH console.

openhab> bundle:list | grep -i spotify
233 | Active   |  80 | 2.3.0.201804131657     | Spotify Binding

openhab> bundle:stop 233

openhab> bundle:update 233 https://jenkins.otr.mx/job/openhab2-spotify-binding/lastStableBuild/artifact/addons/binding/org.openhab.binding.spotify/target/org.openhab.binding.spotify-2.3.0-SNAPSHOT.jar

openhab> bundle:start 233

I’m not sure if this is the best way, but it has worked for me while developing the UniFi binding.


(Jordo) #28

Thanks!
I’ll try it as soon as possible.

Another little question.
For the url of the song image i made a rule myself with xml transformation. After i made a custom request to the Spotify api.
Is it possible to do this inside the binding?

  • Jordo

(Matthew) #29

Are you referring to the album artwork? I want to add support for this.

I’m still getting my feet wet with the Spotify API so I need to see what’s all exposed, but I know 100% the album artwork can be retrieved.


(Jordo) #30

Yes i am referring to the album artwork.
It can be retrieved out of the album information with the album URI.

But i understand that it is necessary to understand the binding it self first :wink:


(Matthew) #31

I’ve found the bug! The almighty NPE…


2018-04-16 08:35:52.799 [SpotifySession            ] - Calling Spotify Web API at GET:https://api.spotify.com/v1/me/player with:

2018-04-16 08:35:52.799 [SpotifySession            ] - Spotify Web API call attempt: 1
2018-04-16 08:35:52.850 [SpotifySession            ] - Response Code: 202
2018-04-16 08:35:52.850 [SpotifySession            ] - Response Data: 
2018-04-16 08:35:52.850 [SpotifySession            ] - Spotify Web API returned code 202 - There are no known user devices known to Connect Web API. Sleep 5s and retrying...
2018-04-16 08:35:57.853 [SpotifySession            ] - Attempt 1 failed.
2018-04-16 08:35:57.853 [SpotifySession            ] - Spotify Web API call attempt: 2
2018-04-16 08:35:57.903 [SpotifySession            ] - Response Code: 202
2018-04-16 08:35:57.903 [SpotifySession            ] - Response Data: 
2018-04-16 08:35:57.903 [SpotifySession            ] - Spotify Web API returned code 202 - There are no known user devices known to Connect Web API. Sleep 5s and retrying...
2018-04-16 08:36:02.904 [SpotifySession            ] - Attempt 2 failed.
2018-04-16 08:36:02.904 [SpotifySession            ] - Spotify Web API call attempt: 3
2018-04-16 08:36:02.952 [SpotifySession            ] - Response Code: 202
2018-04-16 08:36:02.952 [SpotifySession            ] - Response Data: 
2018-04-16 08:36:02.952 [SpotifySession            ] - Spotify Web API returned code 202 - There are no known user devices known to Connect Web API. Sleep 5s and retrying...
2018-04-16 08:36:07.954 [SpotifySession            ] - Attempt 3 failed.
2018-04-16 08:36:07.954 [SpotifySession            ] - Spotify Web API call attempt: 4
2018-04-16 08:36:08.003 [SpotifySession            ] - Response Code: 202
2018-04-16 08:36:08.003 [SpotifySession            ] - Response Data: 
2018-04-16 08:36:08.003 [SpotifySession            ] - Spotify Web API returned code 202 - There are no known user devices known to Connect Web API. Sleep 5s and retrying...
2018-04-16 08:36:13.003 [SpotifySession            ] - Attempt 4 failed.
2018-04-16 08:36:13.003 [SpotifySession            ] - Spotify Web API call attempt: 5
2018-04-16 08:36:13.053 [SpotifySession            ] - Response Code: 202
2018-04-16 08:36:13.053 [SpotifySession            ] - Response Data: 
2018-04-16 08:36:13.053 [SpotifySession            ] - Spotify Web API returned code 202 - There are no known user devices known to Connect Web API. Sleep 5s and retrying...
2018-04-16 08:36:18.053 [SpotifySession            ] - Attempt 5 failed.
2018-04-16 08:36:18.053 [SpotifySession            ] - Giving up on accessing Spotify Web API. Check network connectivity!
2018-04-16 08:36:18.055 [SpotifyHandler            ] - Exception caught in anonymous scheduled runnable task. This task will now stop.
java.lang.NullPointerException
	at org.openhab.binding.spotify.handler.SpotifyHandler.updatePlayerInfo(SpotifyHandler.java:358)[233:org.openhab.binding.spotify:2.3.0.201804131657]
	at org.openhab.binding.spotify.handler.SpotifyHandler.lambda$0(SpotifyHandler.java:273)[233:org.openhab.binding.spotify:2.3.0.201804131657]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_131]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_131]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_131]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_131]

This kills the polling thread so from here on out, no more status updates.

The binding continues to successfully refresh the authorization token so further control requests go through (play / pause / volume / etc…) but all status updates (track / album / device / etc…) stop the polling is dead.

I’ll have some free time these next few days where I’ll fix this and push a build and ask that you guys help me test it.


(Jordo) #32

I recognize the error message.
I will stay in touch for testing when you have coded an solution :wink:


(fuslwusl) #33

Great news and thank a lot for finishing this binding! I will test it as soon as you fixed this polling bug.


(Matthew) #34

I haven’t had the time to work on this one yet… but I will. I’ve got another binding I’m trying to get merged into master and there was some wonky logic / code there that I really needed to refactor.

I’m almost don with that and then I’ll move on to this one.

Will keep you guys posted.


(fuslwusl) #35

Hi Matthew, thanx for your interest in fixing the the spotify connect binding. Have you already had time to finish your binding? Would really like to help in testing the spotify connect binding and give you feedback if you like.


(Matthew) #36

Hi @fuslwusl

I’ve looked through the binding and have a plan of attack but unfortunately I haven’t had a lot of time to actually work on it. I’m knee deep with GDPR at work and I’ve been super busy working on the electrical part of my new house. I’ll eventually get around to working on this but just don’t have the time right now :frowning:

Will keep you posted.


Spotify Connect Binding - some issues
(fuslwusl) #37

Hi Matthew, thanx for your feedback. Just let us know when your stress level ist lower and you have a fixed version for testing. I wish you all the best with your projects!


(fuslwusl) #39

Hi, we have to wait and hope @mgbowman will fix the bug very soon.


(Jordo) #40

Hi @mgbowman,
Any progress so far with the binding?

  • jordo

(Matthew) #41

Hi @Jordo,

Unfortunately I’ve too busy with my house to be able to work on this. Once I’m settled in the new place and I clear the smoke from my new automation setup, I’ll get back into OH2 development. Until then, please don’t expect much of me :see_no_evil:

Matthew


(Hilbrand Bouwkamp) #42

I’ve picked up on this binding in consultation with @mgbowman , see also the pull request (although no work from me visible on this pr). I’ve already made some progress. It requires some significant work as there were over 80 review comments. This should also fix the bug. I planning to have this work done by the end of August.