Unable to trigger media_player.play_media for a Plex client on Apple TV

If running Plex or HA in Docker, you’ll need to run in “host” networking mode for the local network client discovery to work.

Remember you may need to trigger the button.scan_clients entity a short time after launching the Plex app.

It’s running in host mode and I have tried the button.scan_clients. It’s strange that it briefly worked, and overnight, it became broken again.

I see that the next update of Plex Media Server contains a fix for:

(Player) Controlling a player didn’t work in some cases (#14567)

I hope that relates to the Apple TV. Will report back once the update is available for everyone.

I really appreciate all your help! Thanks a lot!

I’m having the same issues as you. Please report back if you find any fixes!!

Hello,

I have na issue where when I does launch plex app, the play button I’ve coded does not work at all(grayed out)

However if I manually start a movie with my roku remote, then everything works fine in home assistant.

Could this be related to that scan button that people are talking about in the comments?

I’m using a roku not Apple, but I feel like it may be a related issue?

Launching a Plex client app unfortunately does not notify the integration that it’s available to use. You’ll need to either trigger a scan for clients (using the button entity) or wait for the next scheduled scan, which can be several minutes. Starting playback on the device directly will notify the integration about the new client, but that usually defeats the purpose of having an automation.

Thanks for the reply. I think this helps me.

So I have and input field. Where I type in any move and click the play button. It immediately launches the title on any of my my 6 Roku decices(depending on which tv I have selected of course)

Works perfect except for when I first launch the app.

Few minutes in or after something is playing I can play 100 movies in a row with ten text search field
And it works perfect.

So In my case I think it makes perfect sense to initiate that scan upon app launch. Am I explaining this correctly? Would you agree? And is that scan command In the comments above what I should add to the launch script?

Probably. Power on the device, launch the Plex app, sleep for a couple seconds to allow the Plex app to become active enough to respond to scan requests, trigger the scan via button entity, wait for media_player entity to become active.

To be clear - there are multiple threads where people ARE doing the scan and this functionality is still broken.

Even if I actively play some content on Plex, then try to control it - I am unable to do anything with it. Yes, the Plex app is configured for control, I’ve checked every setting I could possibly find diving into the forums here.

I am having the same issues…

The Apple TV starts PLEX as a source without issues and in the PLEX integration in HA the player shows unavailable UNTIL I actively play something. Then in HA it shows up as playing and has the details of what is playing. Even in HA if I try and go into the active player and PLAY the media FROM HA via that integration, ignore the service calls stuff, it still doesn’t work. I think the problem is either on the PLEX side or the HA integration side.

I’ve based my automation and testing on threads like this and previous threads from years ago so I know it has worked but something changed that isn’t working.

For the FOLKS who are working and have worked for years like this I’d love to see what you are doing and if it is actively working now.

Here is what I am seeing in the logs when trying to play something via Plex but the client is online and actively playing something:

2023-12-19 11:35:56.275 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139872660546496] Client is not currently accepting playback controls: Plex (Plex for Apple TV - Apple TV)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 238, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 799, in async_play_media
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/plex/media_player.py", line 487, in play_media
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Client is not currently accepting playback controls: Plex (Plex for Apple TV - Apple TV)