PlexMeetsHomeAssistant icon indicating copy to clipboard operation
PlexMeetsHomeAssistant copied to clipboard

Bug: Failed to call service rest_command/pmha_playmedia. Service not found

Open rdmitre opened this issue 2 years ago • 4 comments

Whenever I play anything a toast notification pops up: Failed to call service rest_command/pmha_playmedia. Service not found

Steps to reproduce the behavior: I just installed the repo through HACS and set up the card through Yaml file. The error occurs every time I play anything. The media plays without any issue, just an annoying error message to see every time.

Please check below if true:

[x ] I am running Home Assistant on HTTP protocol [ ] I am running BOTH Home Assistant AND Plex on HTTPS protocol [ x] My Plex server is accessible through protocol, port and ip/hostname I have specified for the card. [ ] My Plex server is running on HTTPS and has a valid certificate.

        - type: 'custom:plex-meets-homeassistant'
          token: !secret plex_token
          ip: !secret plex_host
          port: 32400
          libraryName: Películas
          protocol: http
          sort: title:desc
          entity:
            plexPlayer:
              - identifier: Roku de Sofia
              - identifier: Roku de Dario

Card Version 3.6.3

Plex Version 1.25.2.5319 (QNAP NAS Version)

rdmitre avatar Apr 16 '22 06:04 rdmitre

Please follow steps here and provide needed information: https://github.com/JurajNyiri/PlexMeetsHomeAssistant/issues/49

JurajNyiri avatar Apr 19 '22 14:04 JurajNyiri

I'm experiencing this too on Android tablet. It happens when I start Plex app on TV and then I try to cast movie from the card. If I refresh my Lovelace view, it doesn't throw error anymore.

Error from DevTools:

<?xml version='1.0' encoding='utf-8'?>
<Response code="2000" status="KeyError: X-Plex-Target-Client-Identifier">
  <Traceback>Traceback (most recent call last):
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-8cf78dab3/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/runtime.py", line 843, in handle_request
    result = f(**d)
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-8cf78dab3/System.bundle/Contents/Code/playerservice.py", line 19, in process_remote_command
    identifier = Request.Headers['X-Plex-Target-Client-Identifier']
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-8cf78dab3/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 108, in &lt;lambda&gt;
    _getitem_           = lambda x, y: x.__getitem__(y),
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-8cf78dab3/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/tornado/httputil.py", line 113, in __getitem__
    return dict.__getitem__(self, HTTPHeaders._normalize_name(name))
KeyError: 'X-Plex-Target-Client-Identifier'
</Traceback>
</Response>

I investigated that X-Plex-Target-Client-Identifier header is sent empty:

image

I assume that the card doesn't know if Plex client became available unless you refresh page. And that's also why play button never shows up when hovered above poster until you refresh page.

peledzius avatar May 12 '22 23:05 peledzius