Plex Play Media (Movie, TV Show, Playlist)

Thank-you, that was helpful. I completely deleted the integration, and started over. Following the integration docs, I can get a single song to play with the MUSIC content type, but, I can’t seem to get a playlist to work, using the following:

'1582866973363':
  alias: Plex Test
  sequence:
  - data_template:
      media_content_id: '{ "playlist_name" : "Oldies", "shuffle": "0" }'
      media_content_type: 'PLAYLIST'
    entity_id: media_player.plex_plex_for_roku_roku_ultra
    service: media_player.play_media

Now, there are no errors in the log, it simply does nothing. Any more ideas? Thank-you.

I’ve found some Plex clients have trouble with playlists. Do you have another Plex client you could test against?

Now that I think about it, this might be reported by the client in its list of supported features. I’ll make a note to look at that and perhaps add a check in the integration.

Thank-you for the follow-up. I will check a different client, at my next available opportunity, and let you know the results.

I am having the same issue c.dawg describes above with his playlist test script. I see that Plex automatically creates entities in HA, but it seems they immediately become unavailable in HA once any playback is stopped. Is the script not working because from HA’s viewpoint the entity is no longer available? …Or should this script be “waking up” the entity?

In short, what I am trying to do is to start from HA a Plex music playlist and have it play on an Echo device. Invoking playlist playback via voice works fine (though this is just Alexa/Plex integration). Has anyone gotten this to work?

Using this integration to control Alexa devices is not possible, as they do not run Plex clients and requires a different API. If controlling an Alexa speaker is your only problem, please stop reading here. :slight_smile:

The integration has two ways of detecting a client:

  1. Active playing sessions
  2. Local network discovery

If a client is only showing as available when playing media, it means the Plex server only knows about its active sessions and cannot see the player device on the local network to control it. Normally this local discovery requires both Plex client & server to be on the same subnet and the client has the “Advertise as player” option enabled. In a Docker install, this is usually not the case and requires some specific networking changes or use of a UDP repeater.

Thanks. Appreciate the detailed response. Figured that might be case re: Alexa/Plex.

For those of you interested in playing Plex music on a Sonos speaker, I’ve added a feature for that in the upcoming 0.111 release: https://github.com/home-assistant/core/pull/36177

Anyone having issues playing playlists, this is working for me:

  alias: 'Plex: Play TV Playlist'
  mode: single
  sequence:
  - data:
      media_content_id: '{ "playlist_name" : "adfg", "shuffle": "1" }'
      media_content_type: playlist
    entity_id: media_player.plex_plex_for_windows_joel_pc
    service: media_player.play_media
1 Like

Hi jjlawren - I’m new to the party here and have just started setting things up to be able to play my media from PLex to my Sonos speakers using HA. plex.play_on_sonos works great to play specific artists but I couldn’t see how to make it work for a playlist. Is that possible?

Good question. At the moment that won’t work.

I’m in the process of updating this feature to work like the new Plex->Cast integration: https://www.home-assistant.io/integrations/cast/#plex. I tested my local development changes with sending Plex playlists to Sonos and they work just fine. I’ll submit the PR when I can.

Thanks for the very speedy response. I shall look forward to trying out the new feature!

Finally got around to this and it will be in the 2021.2.0 release. It’s a breaking change to move away from the (admittedly) odd way of the Plex-specific service of plex.play_on_sonos and to use the standard media_player.play_media service instead. The difference is the media_content_id payload needs “plex://” in front of it for Sonos (and Cast) devices.

Check the docs on the upcoming change here: https://next.home-assistant.io/integrations/plex#sonos-playback

2 Likes

Hello jjlawren. Have you seen the issue that if you run SERVICE MEDIA_PLAYER.PLAY_MEDIA command the media title or source does not show up in the Plex Sensor? If i manually select the source in Plex, the Plex Sensor shows what is playing. However, if I run the play_media service, nothing is shown as playing in the Plex Sensor.

Is the Plex client based on AndroidTV perhaps (Nvidia Shield, Fire device, etc)? This sounds like an issue that some Plex clients have when they’re controlled remotely: https://github.com/home-assistant/core/issues/31599. This problem has been reported to Plex. Not much we can do about it until it’s fixed upstream.

Yes I am using an Nvidia Shield. Thanks for the information. Other than that everything works perfectly with my system. Just wish I could show what is playing if I launch something through a home assistant service call. One day!

Thanks Joel for this.
It is working for me as well.

1 Like

Hi @millsx2,
Do you have a code example for using REST commands to wake up unavailable players? All of my Plex media_players are showing as “unavailable” in HA so using media_player.play_media doesn’t do anything.

Thanks

You can use the plex.scan_for_clients service to discover controllable clients. If this does not work, you may be running multiple subnets or have network restrictions in place.

Thanks @jjlawren, unfortunately when I run that command via Developer Tools, nothing happens and I don’t see anything in the logs or logbook.
The NAS running Plex Media Server, the PC running HA and the TV that I am trying to watch Plex on are definitely on the same subnet and I don’t have any network restrictions in place as far as I know.
My Plex client is going to unavailable as described by others here so in Developer Tools I set it to idle and then tried to use media_player.play_media to watch a TV episode as described in the docs but nothing happens at all. Can you recommend anything else that I could try?

Thanks for your help and your work on the Plex integration.

What type of TV and is it a standard Plex client?