within the last weeks, I had the idea for a spotify connect binding. This binding should allow for controlling a spotify connect device anywhere in your network (or any device logged in with your account) and it should be independent of the system providing the Spotify connect service (e.g. a Sonos or a Denon receiver).
There a two interesting libraries that could be useful: the official (but closed-source) library from spotify or an open-source reimplementation in Rust called librespot which is e.g. available for arm systems like RPi. However, the examples are either implemented in Go or in Rust. I do not have any idea of how to use them from Java (ok, there is a Java/Rust bridge using JNA, but I have no experience and no idea of how to use it).
Is here anyone how is familiar with Rust or Go and would help me in supporting the implementation of a Spotify Connect binding?
FYI the Rust project uses protobuf to define and marshal data, that part could probably be reused in a java binding (MIT licensed) , but Iām not volunteering
Funnily enough whilst searching for some background info on Spotify Connect, this thread came up.
One of the more recent project takes the work of librespot and wraps a web server around it with REST API. The project, spotifyd-http, like librespot is also written in Rust.
Iāve been able to setup the spotifyd-http web server in my network (using a Ubuntu VM - Rust didnāt seem to play nicely on my RPi2) and written a very rough (lots of hardcoding) OH2 binding which allows control of Spotify Connect devices (PLAY/PAUSE/NEXT/PREV only atm).
Itās not as clean as a fully integrated Spotify Connect implementation in Java but until someone ports librespot to Java (and that person is unlikely to be me!) itās a start.
Once Iāve tidied my code up Iāll push it to github for those interested.
spotifyd-http is really new project, I was not aware of yet. However, it looks promising. I am looking forward for your code.
I also found an article about how to create JNIāble C libraries from Rust. I will give it a try within the next days and will report my experience.
Beside this article, the spotcontrol library is now completely available in Go, which might allow to make use of the gobind utility that creates a Java wrapper (originally used for Android applications).
The code is a long way from being as clean and tidy as Iād like as Iām struggling slightly with the concept of Things and their bridges - I donāt seem to have gotten my head around the lifecycle and the communication concept.
Having said that, as a proof-of-concept (read: contains bugs and issues), my code does control my Spotify Connect players when running a spotifyd-http server.
I am getting OpenHab going - want to wrap it together with an Amazon Echo dot for some Jarvis style interaction.
My house is mostly automated already - but until this point it has been driven using Simple Remote.
I do still plan on using Simple remote (most of the time), but also want to be able to start my audio up using just voice.
I have an old Android TV box which simply runs Spotify 24/7 and is connected via both Aux and HDMI to various AV receivers around the house. I can control all of these using OpenHab - so I can create a rule that is driven by the echo to start all of these up - but I am unable to get the actual Spotify stream to start playing on the Spotify Connect.
Iāll be following this project.
All I need is to be able to start a playlist (for now I am happy to hardcode my favourite playlists as items in OpenHab), play, pause, skip and stop.
Looks like you are just about there
Are you planning to wrap this as an official OpenHab add-on eventually?
I am also looking at this and planning to see if it would be possible to use spotcontrol together with the exec binding. This would in theory at least enable me to launch a playlist on a Spotify Connect enabled device (my receiver). But it remains to be tested.
@bulletprooffool
My setup is echo connected to my amplifier, spotify linked up in the alexa app. Then you can tell her to play your playlist.
So I do not really see the point of making buttons in OH for spotify, however it would be nice to be able to play youtube videos with alexa on my tv. I read that pushbullet and tasker could be used for this, so I assume you can do the same approach for your spotify:)
I have several AV receivers plugged into and an Android TV box that us new repurposed as single Spotify server.
Plugging Alexa in directly is no good as I need the voice to work on the little speaker all the time and would not that voice going out over all 14 speakers!
I have tasker invoking Spotify on the android but now using the http binding as a trigger with auto remote.
I see IFTTT now can trigger events when a new Spotify track plays on the echo. So my idea is to control Alexa as usual, but whenever something plays via Spotify on Alexa, trigger an event that tells the android box to take over the Spotify stream.
In addition, Iāll use the hue binding to trigger the next button on the Spotify server every time I say something like āAlexa, turn track upā - with a simple rule on OH that then fire an ever to Automremote to tell tasker to invoke the āNEXTā button on Spotify.
Wow, thats a big setupā¦
I have 5 echos, one in each room, where I only have speakers in living room and bathroom, but you have a point it would be nice to have her not stop music if you want to switch lights on for instance. So keep me posted on your progress.
Is someone still using this binding?
It works great now at my openhab, but after an hour i still can control the playback only things like song title and artist will stop updating.
Have the same problem with spotify connect binding. After an hour i still can control everything but the song, artist, album and duration will stop updating.
The binding is really great - can anybody fix this bugs?