How to add a snapcast volume ui to balenaSound?

First, a huge shout-out for a really great product (and for a very cunning strategy to expose people to BalenaCloud!!!) I have has some very limited experience in running and maintaining a fleet of 12 raspberry Pis, with common software but different configurations, and I see the amazing benefit of using balenaCloud. It is an amazing product and I love the simplicity+power of the dashboard. (I must admit I am really a little out of my depth regarding docker containers, but willing to learn. )

I successfully installed balenaSound on 4 Pi4s and the snapcast server works really well. The one improvement I would like to explore is the ability to configure the snapcast server to sync over some devices and not over others. I found these two (https://github.com/badaix/snapweb and https://github.com/atoomic/snapcast-volume-ui) project which installs a small webserver on each Pi and which allows configuration of the snapcast server through the JSON::RPC API.

The second project has references to a containerized version here https://github.com/atoomic/snapcast-volume-ui#using-a-docker-container.

Is it possible to add a container to the current balenaSound setup? Can you please point me to a tutorial on how to do this? Are there specific issues I may need to take into account that come to mind?

Thanks and advance for your thoughts and help.

Hi there, welcome to our forums and thanks for the kind words about both balenaCloud and balenaSound, I’m glad you are liking them!

Adding a local UI to balenaSound to allow extra “live” configuration is something we’ve wanted to do for a while now. I’ve been personally working the past few weeks in the new major release of balenaSound (v3.0) which won’t include this just yet but it will have the foundations needed to do so. I’d say v3.1 or v3.2 will definitely have a UI that will enable you to do what you want, this will probably come towards the end of the year.

In the meantime, I can help you explore the alternatives you’ve linked. I think I have tried both in the past with mixed results. I definitely don’t recommend you try the snapcast-volume-ui one since it’s very outdated, I don’t think I got it to work with modern versions of snapcast. snapweb on the other hand should work fine provided you set it up correctly. I’ll give you a few pointers to start with, then if you are stuck let me know!

Let’s asume you’ll deploy the snapweb UI.

  • The project is just a web page (HTML/JS/CSS files), so you’ll need to create a docker container to act as a webserver. There are many tutorials online about how to achieve this, I liked this one that uses nginx: https://cjadkins.com/docker/2018/10/30/serving-a-static-web-page-docker.html. Just bare in mind that the tutorial is not for Rasbperry Pi’s so it asumes an x86 architecture, the base image the dockerfile is based on won’t work on RPi’s, you’ll need to use the ARM variants, for example FROM arm32v7/nginx for RPi 4 instead of FROM nginx:alpine. This tutorial will show you how to write a Dockerfile and how to edit a docker-compose.yml file to create a container based on that Dockerfile. Both are needed.
  • Next, I noticed the snapweb webpage tries to connect to the snapcast server based on the window.location property (see this line of code). This is no good for us because our snapcast server is in a separate docker container. You’ll need to edit that to be let snapcontrol = new SnapControl('multiroom-server', 1780);, that should be enough for the webpage to find the snapcast server based on the container name instead.
  • Lastly, snapweb connects to a special port on the snapcast server, 1780. The snapcast server container (multiroom-server) does not allow traffic by default to that port, so you need to fix that. This can easily be done by adding - 1780: 1780 to the ports section of said container in the docker-compose.yml file. It should read:
  multiroom-server:
    build: ./core/multiroom/server
    restart: on-failure
    ports:
      - 1704:1704
      - 1780:1780
    volumes:
      - snapcast:/var/cache/snapcast

I think those changes should be enough, though I might be missing something. In any case, if you try it let me know and I’m sure we can figure it out!