I created a custom component called PlexClients out of necessity as the built-in Plex component didn’t meet my needs.
Here are the advantages and disadvantages of this component over the HA
standard media_player.plex component
Advantages:
No discovery needed (queries your plex server directly for connected players)
Control volume (media_player.plex doesn’t even show the volume control)
Displays proper player names (i.e. Living Room Apple TV instead of Plex Web Safari - This is because media_player.plex grabs the name from the session instead of the player object)
Works with all Plex Clients (media_player.plex never displays the below)
Mobile (iPhone, iPad, etc)
PlexConnect (How earlier generation Apple TV’s can access Plex)
Displays episode specific data (when playing a season, media_player.plex will only display the first episode name and TV show thumbnail)
Current episode thumbnail
Current show and episode name
Current season and episode number
Shows disconnected clients as idle (when a player disconnects, media_player.plex keeps the player as ‘playing’ and adds a hidden player as ‘idle’.)
No configurator, plex.conf, or plex token required (this probably works for me because I’ve set Plex to NOT require authentication for my local LAN)
Disadvantages:
Crappy, hardly tested, non-supported code
Probably more
To Do:
Clean up code
Resolve local names (i.e. “Jesse’s Macbook” instead of “Plex Web (Safari)”")
Dynamically create an HA group with all players
Separate the group between local and remote (using plex_client[‘player_location’])
Remove playback control (ex. SUPPORT_PLEXCLIENT = None) per player type
Limitations:
Can’t retrieve current volume (but can set)
No functional playback controls on PlexConnect clients
No functional playback controls on web clients (probably same reason above)
No functional playback controls on ios clients (apple thing?)
Feel free to improve this code and even incorporate into HA (which I do not have the time to do) - I just ask that you let me know (so I can add your improvements or migrate to something better).
Thanks - I’ll need help as I can’t spend too much time figuring out how the process works and then working through the process (maybe the process is not as big a deal as I think)
Also does anyone know how to add/remove a group, add/remove group members, and force HA to refresh or display them. I also want to add a feature of dynamically create group memberships (i.e. a group of actively connected clients, disconnected clients, and any client that has ever connected).
As is, I have to add each client I know about to a group in order for HA to display them. I’d rather have HA display any client that connects.
check out dev-service for details around it but it’s pretty straight forward.
Easiest way I can think would be to create a group/plexclients.yaml (for those using !include_dir_merge_named group) where you could generate or update the file and force a refresh using group.reload.
file could look like:
active:
name: Active
entities:
- plexclients.roku
inactive:
name: Inactive
entities:
- plexclients.appletv
allclients:
name: All
entities:
- plexclients.roku
- plexclients.appletv
You probably have forgotten to mention chmod +x in your instruction for plexclients.py.
I changed from media_player.kodi to media_player.shield_android_tv in automation section for controlling my living room lights and as you mentioned, I can’t control the Plex client from Home Assistant. In the bright side, this could replace Kodi as I use it in conjunction with Plex addon and automation. However, the media player won’t show up in Home Assistant unlike Kodi and to do that, I had to start a movie or play music or something. Another downside is it takes a couple of seconds until the poll interval is up and Home Assistant will notice that I have either started or paused the playback. For that, I would have to make a feature request in Plex forum for a feature to send a command whenever I pause or play the movie.
Thank you for the custom component. This is why I love the Home Assistant community so much.
Kyle - I’m trying to do dynamic grouping (i.e. The component will group for you) which ha does example for automations (ex. Group.all_automations). The code has to be out there somewhere - just need to find it
More improvements coming in a few days - like a duration/progress bar (which shows how much of the video has played), and off button (which stops the video - sorry, no start), and hopefully mute and unmute
I set this up yesterday and while it shows the info and thumbnails accurately none of the media controls seem to work for me; volume, play/pause/next. I downloaded the plexclients.py from the link in the thread yesterday and followed the instructions. My PMS is running on my ShieldTV (2017) like your screen shot.