Anyone want to help me build Raspotify / Librespot add-on for Hass.io?

@wwill This is what you should do to try to make it work
I will assume you have command line knowledge

First make the add-on run with a config that doesn’t make it quit (with HDMI as output for exemple)
Then, log in to your raspberry with this method : https://home-assistant.io/developers/hassio/debugging/
This will connect you via SSG to the main host and not the hassio ssh container

After your logged type docker ps to get the list of running container
Find the the CONTAINER ID corresponding to the IMAGE or NAME containing “addon-spotify_connect”
Then type docker exec -it <container_id> bash
You will be logged to the add-on container itself
It is running on a debian stretch with ALSA and raspotify installed

You can then try different librespot or alsa commands to run a new instance of librespot directly from the shell.
Note that this will not stop or change the one launched by the add-on so, set it to another name to test it

The add-on is running the latest fork of librespot (which has been very busy the last few days)
All options are listed here : https://github.com/librespot-org/librespot/wiki/Options

If you find a way to make it work to USB, explain it to me and I will update the add-on to make it work directly with the right config

@victorcerutti Thanks! I will try that :slight_smile:

@wwill Hey, just did a test with a jack headphone and I discovered that it didn’t play via jack when supposed too. There is indeed a bug with the audio output.
I found a way to fix it, using this doc :

when in the container :
amixer cset numid=3 1 switch ouput to speaker
amixer cset numid=3 0 switch ouput to hdmi

If you managed to ssh to the container, could you type one of this command while playing on song with spotify-connect ?
If none works, maybe try with only amixer cset numid=3

I need to fix my add-on so that it works with speaker output but would love to get your comment on this so that I can fix USB output too !

@victorcerutti Can you go on Discord?

IT WORKS!

“hw:1” did the trick.

I really thought I did try that, turns out I spent a lot of hours on alsa and parameters for nothing.

Thank you so much @victorcerutti! Now, get @frenck to spread this awesome add-on to the people :heart_eyes:

Small edit: I tested now, and it works great on a Raspberry Pi 3, but not on the Pi Zero.

I’m glad it now works on your usb card !

Hi @victorcerutti, I’ve got Home Assistant running independently on Raspbian and was wondering if I could go about installing this, or if it only works with hass.io. Would love to hear from you!

Hi @PotatoFairy. Add-ons only work with hass.io
But my addon is quite simple as it only install Raspotify : https://github.com/dtcooper/raspotify

You can easily install it on your Raspberry Pi following the documentation.
Or just execute curl -sL https://dtcooper.github.io/raspotify/install.sh | sh

Ah, I misunderstood - I was under the impression that this would allow me to control Raspotify with Home Assistant. I have Spotify streaming through Mopidy, but was interested in controlling it through both Spotify Connect and Home Assistant. Thanks though!

Have you tried to use https://home-assistant.io/components/media_player.spotify/ ?
This seems like what you need

I have a question for you @victorcerutti. When the Librespot Org guys releases bugfixes and updates, will you update this, or could I just rebuild the add-on?

@wwill Good question. The add-on use the simple install script from https://github.com/dtcooper/raspotify which itself install the latest librespot version available

So, if librespot is updated a rebuild should also update the add-on. The only thing I see which may prevent that is that docker can cache the built container. I don’t know if the hassio rebuild function is forcing a no-cache build. But anyway, if you haven’t rebuilt it lately, it should update to the new version.

Unfortunately I had to move my raspberry which is no longer close to my amp and speakers (it was too far for the z-wave range) and I am no longer using it.

So if something gets broken after a librespot update I might not see it, don’t hesitate to ping me here and I will look at it

1 Like

Hi @victorcerutti

I’m new to the Home Assistant, am having a problem trying to install the repository onto my Pi - it just errors out. would you be able to hlep?

Ta :slight_smile:

Hi there, thanks for the Add/On! Was looking for something like this. I already have a raspi with raspotify in the network and wanted to use the hass.io for that too.

But it cancels with the following error

INFO:librespot: librespot (raspotify v0.11.3) 431be9e (2018-05-18). Built on 2018-05-30. Build ID: GZE2acOG
WARN:librespot_core::apresolve: Failed to resolve Access Point: HTTP error
WARN:librespot_core::apresolve: Using fallback "ap.spotify.com:443"
INFO:librespot_core::session: Connecting to AP "ap.spotify.com:443"

The other raspotify in the same network works great, so im not sure if the connection is the problem. any ideas?

Hi, Does anyone know how I can get this addon working with the Mopidy-cast addon for multi-room streaming? There is an option in the Raspotify config

#BACKEND_ARGS="–backend alsa"

Which I think needs to be

BACKEND_ARGS="–backend filesink location=/tmpfs/snapfifo"

This happened to me when I started using Pi-Hole on my network. Whitelisting Spotify domains solved the issue:

spclient.wg.spotify.com
apresolve.spotify.com