Snapcast Server, Snapcast Client and librespot repository

Hey guys,

I wanted to show you my current work :slight_smile:

Add this in Hass.IO Addon-Store:
https://github.com/raph2i/hassio-addons

snapcast-server: takes audio via fifo in /share/snapfifo

snapcast-client: connects to a snapcast server, plays audio via usb sound etc.

librespot: Open Source Spotify client library with Spotify Connect capability

Every container is build on your machine, librespot takes about 15 minutes to build (Synology DS918+, amd64)

In my case i added mopidy from hassio-addons/edge which is also connected to snapcast.
Now i can play Spotify in all rooms, or webradio via Mopidy etc.
My next step is to implement TTS for special rooms. (cooking timer)

Mopidy-Config:

    {
      "name": "audio/output",
      "value": "audioresample ! audio/x-raw,rate=44100,channels=2,format=S16LE ! audioconvert ! wavenc ! filesink location=/share/snapfifo/mopidy"
    }

I’d be happy about some comments/trouble etc. :thinking:

raphii

8 Likes

raphii,
Have you managed to TTS via snapcast? I have a trouble with this. All works fine (webradio to snapcast clients; automation to media_player.mpd) but automation to TTS , to entity_id: media_player.snapcast_client_31008b4ef2b2c27b does not!! at the same time the automation sets volume successfully to this snapcast media_player …

With this extra settings in option section of mopidy-config i get an error:

usage: mopidy [-h] [--version] [-q] [-v] [--save-debug-log] [--config FILES]
              [-o OPTIONS]
unrecognized command: !

I’ve tried even to use escape character for double quotes but still the same error.

{
  "local_scan": true,
  "options": [
    {
      "name": "local/media_dir",
      "value": "/share/mojamuzika/"
    },
    {
      "name": "m3u/playlists_dir",
      "value": "/share/playlist/"
    },
    {
      "name": "audio/output",
      "value": "\"audioresample ! audio/x-raw,rate=44100,channels=2,format=S16LE ! audioconvert ! wavenc ! filesink location=/share/snapfifo/mopidy\""
    }
  ]
}

Any hint?

1 Like

You’ve got an typo in audio output!

""audioresample…

in my setup (105) it looks like this:

  • name: audio/output
    value: >-
    audioresample ! audio/x-raw,rate=44100,channels=2,format=S16LE !
    audioconvert ! wavenc ! filesink location=/share/snapfifo/mopidy
1 Like

I wanted to try this. But starting the snapcast server already results in an error:

Start Snapserver...
2020-02-23 11-55-33 [Notice] Settings file: "/var/lib/snapserver/server.json"
2020-02-23 11-55-33 [Err] Error reading config: [json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal

Hey Marcus,
i am updating the repo right now, there is an issue with config handling since snapcast 0.16
I’ll keep you updated

1 Like

I’ve a work in progress version on the update_snapcast branch.
It seems like, there is an issue with snapcast itself and / or alpine Linux.
Further reading:
https://github.com/badaix/snapcast/issues/554
https://github.com/raph2i/hassio-addons/commit/b196b67712aad232dc43166bc96e0e1dc261b02e

Hey Marcus,
the new version is now available.
Maybe you have to restart HassIO / Supervisor to get the new version pulled.
And please deinstall and reinstall the Plugin.

1 Like

Working fine, thanks for the update. I still get the same error in the log, but it doesnt terminate the process anymore.

In order for the new version to be pulled i had to remove and re-add the repo.

badaix, the maintainer of snapcast, said that the error is intended and okay.

nice to hear that its working now!

Hi, I am trying this setup, but when trying to add mopidy, it lists it in the add-ons repo, but states it is not available for me. Wondering how I trace back which dependency I am missing ? I am currently running on rasbian stretch for other reasons and wondered if it could be that?

I just realized that upon restarting the server addon (it crashed) all the saved names, latency settings and mutes are reset. Is it possible to make them persistant for a restart?

This will be fixed in the next snapcast release, see: https://github.com/badaix/snapcast/commit/7376c7709ce3239af3c33aaca2c95481735d8f39

Which homeassistant version are you using? What is your hardware?

snapcast_client wont work on synology DSM anymore.
This needs further investigation™.

Just saw that badaix will make the server.json configurable. Great news :slight_smile: Looking forward to 0.19 release.

However, now I’m trying to make it work somehow for the current release.
I was thinking of using NodeRed JsonRPC Node to send the latency data for the client after every restart. But I have not yet been able to make it work.
Any other idea for this?

Got the solution. With the TCP Node its very “easy” to set the settings at restart of the addon.

One TCP Listener to detect when it reconnects.
And a TCP Request Node sending the raw JSON RCP Data.

Hi! Did anyone ever attempt or manage to integrate mopidy over the mpd integration as an entity into HA?

I would like to control what and when mopidy plays something via node-red(used for an alarm-clock), but I can’t find a way to talk to mopidy directly. I noticed that the docker-img doesn’t contain the mpd-extension and doesn’t forward port 6680 to the host either, so I can’t even attempt to send some data over the websocket api.

Maybe someone came further and found a solution to this :grin:
If not I will probably head over to git and maybe try to ask at the repo.

(Sorry to post in this topic, I just didn’t find any other place where people were using the edge version of the addon)

EDIT: Solved!

1 Like

Hi Raphii, are you planning for a new release that includes the option so save the config user editable now its included in the 0.19 release?

Hi!
Sure, i think in about 1-2 weeks :slight_smile:
Feel free to submit a pull request :wink: