Multi-room audio with Snapcast, Mopidy, and Home Assistant

You could make an iframe in HA and show the LMS interface in a HA card.

Ok. Just found out that the plug-in is available at http://192.168.2.8:9000/plugins/spotty/index.html?&player=00:00:00:00:99:01 so youā€™re saying I could create an iFrame with this URL within HA - as in https://www.home-assistant.io/integrations/panel_iframe/?

You will need to use a proxy and port forwarding in order to have https for your LMS url. Iframe only supports https and NOT http. Then it will work (I have it working). I found this on Reddit which got me started back then:

And this comment: https://reddit.com/r/homeassistant/comments/jkhg1n/_/gamkzwm/?context=1

By the way, since one of the latest HA updates the LMS integration also supports the Media Browser of HA. Just select Media Browser on the sidebar and then an LMS speaker. You can access and play everything in your LMS library through that (including Spotify, Deezer and Tidal if you have Online Music Integration setup in LMS). So if you only want that and donā€™t want the hassle of iframe cards, you can try that.

But this is getting extremely off-topic, since this thread is about Mopidy/Snapcast and not LMS.

3 Likes

Thatā€™s not completely true, my iframes to the mopidy webserver are all http and work fine. The problem is only when you access the Home Assistant instance with https, but I only use https for remote access (and remotely I donā€™t need access to these iframes and if I really need to I login through a VPN) and locally itā€™s all http (achieved with NGINX).

Yes, thank you for clarifying. That is what I meant to say. This is also stated on the docs:

You canā€™t embed sites using HTTP if you are using HTTPS for your Home Assistant.

So if youā€™re using SSL and have access outside your HA instance, make sure you use a proxy for your LMS server.

1 Like

Thanks. I guess I got some weekend work cut out :slight_smile: and agree, weā€™re off topic here.

Same here, been going round and round in circles. My setup and problems mirror @ThaNerd exactly.

I went round in circles trying to get this to work with the separate mopidy and snapcast add-ons too. Itā€™s just too hard without being able to edit the config file directly.

Iā€™m just using the mopidy cast addon now which just works out of the box.

Do you have a link to that please.
As all my speakers are Google and spotify is only real media source I use, Iā€™ve just used spotcast and the default Spotify integration for now.

https://github.com/bestlibre/hassio-addons/tree/master/mopidy_cast

Add bestlibre repository to add on store.

Iā€™m not sure youā€™d be able to use snapcast with google speakers though. I have snapcast clients installed on Android tv box and old android phones plugged into amplifiers and speakers (I donā€™t like spending money!)

Thank you.

Hi @aidbish, Where can I find the mopidy docker container?

I forked one in my repo and keep it updated here:

1 Like

Thanks a lot!

https://hub.docker.com/r/jaedb/iris

although the lastest images have removed the icecast integration, had to stick at a certain version
this also includes the iris interface

1 Like

Mine includes Iris as well, should be no problem to add icecast, let me know if you are interested.

@Burningstone Thankyou for the offer
i think the iris integration has dropped the icecast integration in its code so im not sure adding it into the image would help. my icecast is actually a seperate container and no way now to link them in new version of iris

Hello!

Let me share with you my weekend project.

Once you wrap your head around how the system works and what a Media Player Daemon (MPD) is, itā€™s trivial to script it out for clients.

After you set up Mopidy and snapserver with your clients, the home assistant part is easily done with the media player MPD platform component in config.yaml

I found that this Multi-room audio with Snapcast, Mopidy, and Home Assistant - Home Assistant is a really good source however, the network diagram is misleading. Really it doesnā€™t matter as long as you point to the server in the configurations.

I have Home Assistant with supervisor running in containers on a NUC, with various Pi interfaces to switch lights and whatnot.

So my weekend project was to convert all of the speakers Iā€™ve collected over time into smart speakers. I plugged in the speakers to the ras-pis and dedicated one as the host. This is my host pi:

Then Installed snapclient, snapserver, and mopidy on the host pi, you can find tutorials on how to do this, here is the one I used: Smart Home Whole Audio Part 1 - YouTube.

After I created the dedicated host pi I was able to connect it to Spotify by following the instructions and viola:

FYI It was a royal pain to get this up and running with my network configurations, but I managed and I hope it is easier for you.

Anyhow, then I created the client Mopidy Piā€™s. Iā€™m not going to include pictures the process and result is nearly identical, you just donā€™t install snapserver and point the snapclient to the snapserverā€™s IP

All of this was independent of Home Assistant. Connecting Home Assistant was much easier than I was expecting, you need to make sure that the Mopidy MPD python library is installed on each of the Mopidy clients as well as the host.

The cool developers for Home Assistant made it easy, itā€™s literally a config entry:

media_player:
  - platform: mpd
    host: xx.xx.xx.xx
    name: multiroom_controller
  - platform: mpd
    host: xx.xx.xx.xx
    name: office_pi
  - platform: mpd
    host: xx.xx.xx.xx
    name: living_pi

Here are the features youā€™ll get:

  1.  Independent client control (except for the host)
    
  2.  TTS on all of your speakers, individually addressable (except for the host)
    
  3.  Programmable automations for media
    
  4.  Full house synchronized audio
    
  5.  Turn any speaker into a smart home speaker
    

Unfortunately you canā€™t play individual songs from Home Assistant but you can with your handy dandy mopidy webapp.

11/10 Project, the reward when you get all of your speakers synchronized is out of this world.

For those of you who are wondering here is my mopidy network map I hope this helps

Should also open a chat in the mopidy forms for this as well since 95% of this is mopidy set up an home assistant barely plays a part other than the integrated mpd features.

Feel free to DM or reply if you have any questions on the setup.

Cheers!

Chase

1 Like

Thanks for sharing @ChaseGregoryCS your setup looks pretty awesome.

A few questions for you

  • What web and mobile clients are you using for mopidy?
  • How do you control the clients independently? My understanding is mopidy output feeds into snapcast server directly which is fed to each client. How do you choose one thing to play in room A and another to play in room B, and then how do you choose the same thing in rooms A and B but not C?
  • Does Spotify Connect work?
  • Does TTS interrupt the currently playing track/stream ? If so does it resume after the TTS is finished?

I am have a working Squeezelit/LMS setup that just works all the time, but I am missing TTS. Thereā€™s no seamless way to play TTS to the squeeze clients without interrupting the current playing track.

Youā€™re very welcome, Iā€™ll do my best to answer these for you.

So, there is a mopidy webserver called mopify that you can install with each mopidy instance. Each device that is running the mopidy daemon is a client and the only instance that is the Host is the one with snapserver. So, if you install the same libraries on each of the clients, you can have independently addressable audio clients. Just an FYI if you do install the mopify webserver it doesnā€™t work well on chrome, you have to use firefox.

You can also control it through home assistant with the MPD integration, if you tie in each of the clients to the integration, you can individually control each client that way as well with the correct tile.

Spotify Connect works, the caviot is that, only liked songs and playlist songs will move into mopidy. So build your playlist on spotify and play them on your audio system.

And TTS Does interrupt the current playback IF you use TTS on the snapserver instance. You can bypass it by using TTS on all of the other mopidy instances.

I hope that helps!