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

Hey guys!

I’ve been using Raspotify for a little while, and I am very satisfied with it. I’m running it on a Pi Zero next to my stereo, where I also have 2 other Pi 3’s doing various stuff. Suddenly it hit me that it would be nice to have a Raspotify/Librespot add-on for Hass.io, since it would free up my Pi for other projects. It also seem to be fairly easy to run, and Librespot is docker ready.

Anyone want to help me build it? I know nada about how to make add-ons (tried the guides already)

I think it would be super useful! :grinning:

I need this as well
I will try to make a raspotify addon tomorrow :slight_smile:

Hello,

Just pushed a first version here

This is my first add-on, it’s still a bit experimental and a work in progress
If you want to give it a try, all comments are welcome !

Victor

Victor, you are THE MAN!

Are you using the built in HDMI or jack for output? Are you able to get any sound?

I’m using the USB DAC on my Hegel receiver and I get this message:

INFO:librespot::player: Track “Purple Light - Few Wolves & Bastiaan Remix” loaded
ALSA lib pcm.c:8403:(snd_pcm_set_params) Rate doesn’t match (requested 44100Hz, get 48000Hz)
thread ‘’ panicked at ‘called Option::unwrap() on a None value’, /checkout/src/libcore/option.rs:335:20
note: Run with RUST_BACKTRACE=1 for a backtrace.

Probably just a small hickup, but I was wondering if you get the same message.

Thanks,

I’m using HDMI which is splitted by an hdmi matrix.
The sound quality is very good this way.

Which “speaker” option did you set ? The default one is for hdmi : "hw:0,1"

Also, can you copy what you have in the logs between [Info] Show audio device and Starting spotify connect ?

I’m working on an update which will support more options from librespot (bitrate, initial_volume) and allow to run multiple instances on the same add-on.

how does this work? The DAC converts the digital audio for a not amplified signal that needs an amplifier?

My receiver has an USB input that gives far better sound quality connected directly in the USB port of the Pi, than when I used AUX to RCA cables from the Pi or via an USB soundcard. I was actually blown away how big the difference was. Less noise, clearer quality (USB soundcard cost 1 dollar on eBay) and signal was stronger, so fewer turns on the volume knob. Next step up will probably be a HiFi-berry or something (higher bitrate, more direct transport over i2s), but then again Spotify itself will be the bottleneck soundwise.

Regarding my connectivity issues, i use “hw: 1,1”. See log below. I suspect there might be some ALSA settings involved.

[Info] Show audio device
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Audio [DigiHug USB Audio], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Audio [DigiHug USB Audio], device 1: USB Audio [USB Audio #1]
Subdevices: 1/1
Subdevice #0: subdevice #0
Starting spotify connect

@anon35356645
I haven’t tried cause my HDMI solution is fitting my need, but there are also hats for raspberry that connects to the GPIO pins.
This one for exemple : https://www.justboom.co/product/justboom-dac-hat/

pardon my newbness. WIth that HAT form the two RCA jack I have to connect to an amplifier, correct?

WHat you think of the solution of using USB ???

this becasue without a specific HAT, the signal is not good probably?

Yes, you’d have to connect it to an amplifier.
Sorry, I cannot compare to USB as I never tried any of the two solution.

Can you try with "hw=1,0" ?
Have you ever used another add-on (ie. snips, modipy, google assistant) with this kind of configuration for the output ?

Just to let you know, I published a new version of the add-on (0.5 instead of 0.1).
It adds a lot of configuration options, as well as the possibility to run multiple instances of librespot
Documentation is here https://github.com/victorcerutti/hassio-addons/tree/master/spotify-connect

You will have to change your config in hassio but it’s really straightforward

USB is the next best thing to a dedicated hat for the Pi. The signal from the aux output is not the best (it’s a 35$ computer, not a HiFi component). Noise is the most noticable problem you get out of the AUX-RCA cable, so USB is a good upgrade.

@victorcerutti 1,0 is the input part and will give out a broken pipe error. 99 % sure the 1,1 setting is correct. Only tried Google assistant on jack output, so no experiences there. But I’m upgrading now, and will keep you posted. Again, thank you a million times for putting your time into this, your my favourite person on the interwebs nowadays! :grin:

1 Like

The audio output of the RPi is good only for some bleep blop alert sounds, absolutely bad for music. It’s not a DAC but a PWM signal smoothed and filtered with a pair of capacitor and a pair of diodes.

does this require you to have Spotify Premium?

Yes, it does.

Ok, I think I’m stuck @victorcerutti . I can see your add-on works perfectly on HDMI, no errors there. I tried installing 0.5 but I get the same error. Since the DAC works with Raspotify, which is also based on librespot, this should be able to work as well. Hardest part here for me is the Docker-world, because I know nothing of it. Am I able to access ALSA inside hass.io somehow? I think what I need to do (what worked on Raspotify installed on raspbian lite) is disable the built in BCM2835, and make the DAC default output. Is that even possible in a docker environment?

Also, I’m running on a Pi Zero right now, I don’t know if that is a bad idea.