I installed Hass OS on a Raspi and installed the Spotify Connect addon. This works great; I can play music on my raspi from my phone. I now would like to send these sounds to two other raspis on which I attached two hifiberry amp2s which are connected to speakers in my living room and kitchen. As far as I understand I could use snapcast to sync these two speakers. I read a lot about mopidy as well, but I’m not sure whether I actually need mopdiy.
So I searched for Snapcast and mopidy addons and integrations. I found this snapcast integration, but that only seems to be able to control an installation of snapcast. From the Snapcast docs I read that snapcast can read from stream sources such as named pipes, alsa or stdout from a process. I guess that means that the Spotify Connect app could somehow pipe the music stream to snapcast, but I’m unsure whether that is supported at all.
So my question; how could I proceed from here? Is there a way that I can install snapcast (and if needed mopidy) onto my Hass OS installation? And could I pipe the music from spotify connect to snapcast? All tips are welcome!
Hello,
I have done something simmilar, but I have one major thing different. I´m running HASS in Docker Supervised.
This allows me to install any linux package, so I installed snapserver on the same Pi, where HASS is running in Docker.
I then have three raspis-zero with a HiFiBerry-DAC, where snapclient is installed on dietpi. I control the whole setup with home assistant, and I´m piping music “into snapserver” from librespot/raspotify.
I do not know if you can “pipe” the music/stream from the SpotifyConnect addon, but maybe it is possible.
Here’s a setup that will give you a full house audio system. HA is simply used to interface with a Mopidy server that runs multiple copies of mopidy with it’s spotify integration. Snapcast is used to to enable playing out to multiple outputs. The multiple copies of mopidy enable you to have different music playing out different speakers. Mopidy iris is used to give the ability to build playlist and more.
@fraintt - Thanks for the info. Good to know that it is at least possible!
I was first thinking of also setting up HASS Supervised, but it seems to be quite a pain in the ass. I just found this custom hass addon repo which adds containers for snapserver and librespot to Hass.io. I would prefer that over doing things manually since it’s easier to replicate. Unfortunately that repo hasn’t seen any love in the past half year and things don’t start up for me. I just forked the repo and I’m now using that code as a starting point. I fixed some first errors, but now running into other ones. Hopefully I can get things running.
Two more questions:
Do I understand it correctly that I don’t need Mopidy since I can directly pipe sound from librespot to snapserver?
I hadn’t heard of raspotify before. Do you use librespot or raspotify? And why?
ps. also thanks for the tip of dietpi. I hadn’t heard of that either.
ps2. I’m actually surprised that this isn’t mature code yet. I would’ve expected that everyone wants this.
@kramer65 I also found these addons, but I was not able to change the configuration to pipe music/stream “into” the snapserver, I cannot remember what exactly the issues was back then, but this was also one problem. (I just looked through the “issues” on the github, and it seems like there are several things not working as of now… )
For your mopidy question, you do not need mopidy, if you are not planning to play music from your local media library (pc, or a music folder on a NAS somewhere)
I looked into my config, and I´m using librespot, but I´m starting it with snapserver.
As you can see, I also abandoned piping the stream from librespot to snapserver, but I´m calling librespot directly with snapserver. (Also had some issues there… )
I´m only piping mpd output, because I´m using it to perform TTS-Notifications on the Multiroom-SoundSystem (Snapserver)
Additionally, I installed airplay, so I can stream content also from Apple Devices.
@fraintt - Thanks for that message. I spend a couple hours on this and finally managed to run librespot, snapserver and a snapclient all on my laptop. After that I built a Dockerfile which includes librespot and snapserver. I can now connect Spotify on my phone to that container and then play the sound from a snapclient on my laptop.
Tomorrow I’ll have to see how I can run the container in Home Assistant, including exposing the ports (not sure where I can expose/map ports in a HA Addon). I then just have to point the snapclient on my laptop to the HA ip address. From there I just need to build the dietpi image and install snapclient on there.
So I’m making progress! But now it’s time to sleep…
Initially, I also spent hours to get it running… but when it is, there are no problems. Remember to make backups or take notes how you installed it, so in case of a failure you can easily re-do it.
Regarding docker, I love it, but Im more a “GUI” type, so if you want, check out “Portainer” AddOn, which as an GUi for docker, also easy to manage ports etc