core icon indicating copy to clipboard operation
core copied to clipboard

Plex clients (PlexAmp, Plex Player) show unavailable until they are active

Open Coder84619 opened this issue 1 year ago • 19 comments

The problem

I have a number of PlexAmp and Plex player clients on various devices: iPhone, iPad, Mac, Apple TVs, and nVidia Shield. When one of the clients is active, HA properly and instantly gets updates about the playing media. However, whenever a client goes idle for a period of time ALL clients show:

This entity is no longer being provided by the plex integration. If the entity is no longer in use, delete it in settings.

And if while I'm the entity dialog box that shows the unavailable state and play media, it instantly has the proper state. So it's like the PMS add-on tells HA the entity is no longer being provided while the client is idle, instead of passing along an idle state.

What version of Home Assistant Core has the issue?

core-2023.7.1

What was the last working version of Home Assistant Core?

unknown

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Plex

Link to integration documentation on our website

https://github.com/home-assistant/core/tree/dev/homeassistant/components/plex

Diagnostics information

home-assistant_plex_2023-07-10T05-30-49.373Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Coder84619 avatar Jul 10 '23 05:07 Coder84619

Hey there @jjlawren, mind taking a look at this issue as it has been labeled with an integration (plex) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of plex can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign plex Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


plex documentation plex source (message by IssueLinks)

home-assistant[bot] avatar Jul 10 '23 08:07 home-assistant[bot]

I'm seeing the same behavior with unavailable entities across the board

bharvey88 avatar Jul 22 '23 17:07 bharvey88

Any head way on this issue. I've been experiance the same.

sczepo avatar Aug 09 '23 11:08 sczepo

Same here, following.

ABEIDO avatar Sep 29 '23 08:09 ABEIDO

Same here, also following.

RedNo7 avatar Nov 08 '23 13:11 RedNo7

Same here.

premikkoci avatar Dec 07 '23 22:12 premikkoci

It is even worse than unavailable. Once you START playing the client is available in HA but none of the functions work like playing media or nothing.

When Plex is playing and trying to play media via HA using the simple UI and not service calls the following errors are thrown:

2023-12-19 11:41:13.919 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)

pyrodex avatar Dec 19 '23 16:12 pyrodex

Plex clients can only be considered "idle" if they are advertising their availability and can be remotely controlled. Otherwise the only information available is when the Plex server reports ac active playback session.

Make sure you've enabled "Advertise as a player" (or variations of that language) and try to trigger the button.scan_clients entity after the Plex client has been open for a few seconds to give it time to respond.

Some Plex clients seem to sometimes "forget" this setting during upgrades, so check it again in the Plex client settings if you believe you enabled it in the past.

Note: Plex clients must be directly connectable for controls to work. This means they must be reachable from the same network as your HA host.

If this is still not working, it's probably one of three things:

  1. The Plex client doesn't support remote control. For example, Plex Web clients (and non-HTPC desktop clients) had this feature removed a while back.
  2. Your HA setup cannot scan for clients using UDP multicast because of networking restrictions or HA running in a container without host networking.
  3. Plex clients are not logged in or not using the same account as the server.

jjlawren avatar Dec 19 '23 19:12 jjlawren

@jjlawren This is not the case. I have full control of my AppleTV Plex instance when there is media playing or paused. The instant the media stops (back button), the client is no longer available. This behavior is new, I used to be able to control the AppleTV Plex client as soon as the application was open. I even have an automation that when the AppleTV media source (input) changes to Plex, it scans for clients.

Teagan42 avatar Jan 20 '24 07:01 Teagan42

@jjlawren This is not the case. I have full control of my AppleTV Plex instance when there is media playing or paused. The instant the media stops (back button), the client is no longer available. This behavior is new, I used to be able to control the AppleTV Plex client as soon as the application was open. I even have an automation that when the AppleTV media source (input) changes to Plex, it scans for clients.

Same here.

hongliangl avatar Jan 30 '24 02:01 hongliangl

I had scripts to trigger certain playlists and now they don't work unless media is already playing. Previously, I could trigger these even if the plex client was not currently playing content.

kevinhaas avatar Feb 06 '24 18:02 kevinhaas

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Still a problem.

rspeicher avatar May 06 '24 19:05 rspeicher

It is most certainly still broken.

Coder84619 avatar May 06 '24 19:05 Coder84619

I had scripts to trigger certain playlists and now they don't work unless media is already playing. Previously, I could trigger these even if the plex client was not currently playing content.

Same experience here

mousemat86 avatar May 29 '24 20:05 mousemat86

Same here. Following

jaypdaly avatar Jun 13 '24 11:06 jaypdaly

Same here.

pranktap avatar Jun 29 '24 16:06 pranktap

My workaround is adding an if else condition if the player is unavailable after plex launched then reloading the plex intervention via script shows it as active. There may need to be a delay for a few seconds depending on your device then it’ll work until they fix this bug

pranktap avatar Jun 30 '24 05:06 pranktap

My workaround is adding an if else condition if the player is unavailable after plex launched then reloading the plex intervention via script shows it as active. There may need to be a delay for a few seconds depending on your device then it’ll work until they fix this bug

How do you reload the plex? Could you share more details? Thanks!

hongliangl avatar Jun 30 '24 05:06 hongliangl

You have to get the config entry id for plex located in /config/.storage/core.config_entries then in the automation select conditional then entity select your plex media player device then unavailable. The action should be Call a service 'Home Assistant Core Integration: Reload config entry’ with the config id box checked and the config id from earlier. I also had to select my plex media server as the device. I have a 2 second wait after just in case it has to reload the integration.

pranktap avatar Jul 01 '24 22:07 pranktap

@pranktap thanks, guy, it works!

hongliangl avatar Jul 03 '24 16:07 hongliangl