PlexDevices - Custom Media Player Component

I have tested with the latest version of PMP but still fail. To overcome this, I have changed to RasPlex. It works.

Good to hear

Anyway, I am just wondering. Is it only me or is it confirm that PMP is not supported?

Can someone who is using PMP on RPi do a test by playing a playlist?

Did you update ha? I noticed the same behavior after updating (even with the standard media_player.plex). I believe I updated again and it corrected itself.

I updated to 38.1 but not 38.2 yet.

I was looking at my setup from my tablet yesterday and NONE of my media players were looking right and I think that may have been a local cache issue on the browser because they are looking better on my desktop this morning.

I’m going to update to 38.2 later and clean up my media players entries and move them to a separate yaml file. I’ll let you know how I make out and then I can test the last version again.

I’m sorry you have to refactor again, but I’m looking forward to it - this seems like a much better approach.

UPDATE POSTED - Refactored

The component is now 90% media_player.plex code with my changes added in. I lost the slight speed advantage of my previous code but this makes the code smaller, less complex and less likely to break, and more likely to maintain backwards compatibility. I also defaulted several key enhancements to off for even more backwards compatibility. To enable these enhancements (my recommendation), simply add them to your config:

media_player:
  - platform: plexdevices
    include_non_clients: true
    use_episode_art: true
    use_dynamic_groups: true  

Scroll up to the first post for links to the latest Code and Documentation

1 Like

Will give this a try tomorrow and report back. Previous issues seemed to be related to my browser cache. I guess with all the new front end work by @balloob, I had to clear my cache.

I’ll take a look at this latest version soon.

I was looking at your last version of code and was going to suggest you remove the direct xml access and stick with the plexapi. But, I found another bug in the plexapi and am working with the developer to get it resolved. They were reading /status/sessions and mapping to plex.session() - and at the point that the ‘player’ object is loaded it would attempt to connect by building a url from the IP address and port of the ‘player’. But, my session xml doesn’t contain the ‘port’ for the client so the ‘player’ field would be ‘None’.

It turns out that on my Plex Server I don’t have any /clients listed. None of my Rokus, Android clients, etc. I have found the only reliable place to find devices is via plex.tv/devices.xml - but this requires the login.

I also suggested that plexapi decouple the playQueue from the playMedia. So, the developer can create a playQueue including a ‘shuffle’ option and pass that playQueue object to the playMedia command.

OK - as a quick FYI the Plex Server uses GDM to discover others servers and players on the network.

On my server I had GDM turned off.

I just turned it on and got a listing of connected players through the /clients URL.

Note: this is for discovering local clients.

I think there were instructions for this once but I can’t find now. Create a custom_components directory?

In the same directory as your configuration.yaml, create a new folder called ‘custom_components’ - inside that, create another folder called ‘media_player’ then drop the plexdevices.py inside the media_player folder.

Testing this now; note that the readme.md has platform: plex instead of platform: plexdevices.

thank you… wasn’t sure which way it should be. :slight_smile:

I’m trying to test this in place with the existing Plex client and figuring out which is which isn’t easy.

I use a nvidia Shield as my new Plex server and finally figured out what my missing ‘third’ media player was.

I get one for the Standard Plex client, one for the Shield as a Chromecast device and one for the Plexdevices Plex client.

Entity-wise, this shows up as:

media_player.shield
media_player.shield_2
media_player.shield_3

Unfortunately naming them isn’t as easy as it appears that they get entity names according to the order they get initialized and that doesn’t appear to be in a set (and consistent) order.

I think for testing purposes, I’m going to need to disable the standard Plex client.

Can we get the username added to the card?

Also, for the groups, is it possible to have a single card with a line description/status for each device?

AppleTV    Playing    Quantico    S02E04    mrpicklehead
Pixel      Paused     Arrow       S02E10    jimbob
Roku       Playing    The Flash   S01E08    XXcooldudeXX
Samsung    Idle
iPhone     Idle
iPhone     Idle

OK, I got some things sorted out and tests on the ShieldTV look good. I can control the media and while the display of the state seems to be a little laggy, the actual response on the client side is immediate.

I think my volume controls would work to but I have to change some settings on the Shield so it’s not controlled by the AV Receiver.

I can also report that this client works really well in the Universal Media Player and all controls in the plexdevice client still work in Universal Media Player.

Even with the standard Plex client commented out, I am still getting a third instance, but I am thinking that it may be due to discovery. We’ve been discussing this here:

@JesseWebDotCom - is there anything specific I can test for you in my setup?

Quick reply - sounds like it’s working well. If you guys can:

  • please test with media_player.plex off (that means don’t reference it in your config and turn off discovery)
  • compare your results between this component and media-player.plex
  • compare between this component and your plex now playing screen

Everything should be working (within the noted limitations). I did notice and plan to code for a scenario where the plex server says media is playing but you can see the duration is 0 or the position hasn’t moved. Let me know of any other scenarios you spot and send me details/screenshots. I plan to wrap this up and submit to ha this weekend as an update to the current plex component

Thanks again

documentation updated

I was contemplating changing the entity id’s as I too hate the ambiguous names. I’d change them to client ids - they would be ugly, but unique. I think the ID would only change if the plex client was reinstalled on a given device - so there’s risk but less than what’s currently (i.e. anyone can rename their device at any time). Let me know your thoughts and I’ll see if that’s doable over the next few days.

Kyle - I don’t think I can do anything about state cards as it should use the default media_player card. If you have an example on how to change it or separately how to add additional attributes to a device (i.e. so I can add username), let me know.