Play from Music Server on Speakers

Long time lurker, first post here. I apologize if this has been covered, but I could not find details on what I am looking for here.

So I have been tinkering for awhile, and now I am looking to integrate my music with HA (trying to avoid all the dedicated apps!). I have several Sonos speakers that I would like to play music on without having to first setup everything on the Sonos app. It would also be nice to play music on my connected smart TVs.

I have most of my media on a Plex Media Server on a different machine. HA is running in docker on a PI4 with raspbian lite.

My understanding is HA cannot play media from PMS unless its playing it through a Plex client on a device. So, in order to play my music on any device, I will need to host it differently. Research shows me that many folks recommend MPD, but that seems pretty old. Is there a better solution? If not, how should I host MPD - in a separate container in docker?

Thanks for any help yall provide!

Any chance you also have a Plex Pass subscription? I maintain the plex integration and I’ve been tinkering with ways for HA to send music hosted on Plex to Sonos speakers. Not working yet, but I think there’s promise. However, in order to use Plex’s Sonos APIs, you’ll need a Plex Pass.

I do have a Plex Pass. So far, the only way I have been able to get this to work with Sonos is to enable remote sharing in Plex. I would rather not have that open for security reasons but if its what I have to do then I will.

My experimenting has led me to believe that you still need to setup the things you want to play in Plex through the Sonos app. Not sure if thats the case or not yet though.

The Plex Pass feature lets you control Sonos speakers via the native Plex apps. Browsing Plex from within the Sonos app is a different method. I’m trying to see if it’s possible to replicate the first method from HA, where you could send media_player.play_media commands to the speakers.

That would be ideal. The issues I have run into for that are twofold. One - do you select the Sonos speaker as the target, or Plex on Sonos? My understanding is you have to select a Plex client on a device. I have not been able to get HA to see my Plex client on Sonos. Second, how do you know what to name the media_content_id?

It’s not possible in HA today, but I believe it’s achievable with more development work.

I think so too.

I have been able to do a sort of work-around. In the sonos app you can link music library to a network drive (location of Plex media files). From there you can use HA to tell the Sonos to play from the library. Not a good long term solution, but works.

Also, if remote access is enabled on Plex Server then HA can see the Plex client on Sonos.

I’ve added a feature to allow playback of Plex music directly to Sonos speakers: https://github.com/home-assistant/core/pull/36177. It should be in the upcoming 0.111 release.

2 Likes

It looks like that feature still requires remote access to PMS. Any progress on having this be local only?

No. The current method relies on Plex APIs. Local control should be possible using the undocumented Sonos API. I tried that initially but ran into some roadblocks and haven’t had a need to revisit since. Do you have a Plex Pass?

Yes - I have Plex Pass. You’ve also helped me a great deal on discord this morning.