JurajNyiri / PlexMeetsHomeAssistant

Custom card which integrates plex into Home Assistant and makes it possible to launch movies or tv shows on TV with a simple click
Apache License 2.0
107 stars 8 forks source link

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

Open rdmitre opened 2 years ago

rdmitre commented 2 years ago

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)

JurajNyiri commented 2 years ago

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

peledzius commented 2 years ago

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.

blamaz commented 9 months ago

Same error here

blamaz commented 4 months ago

Strangely when I hit play on any video this error "Failed to call service rest_command/pmha_playmedia. Service not found" appear on the screen but the video start playing just fine. If i add the following to my configuration.yaml, the error dissapeared.

rest_command:
  pmha_playmedia:
    url: "{{ url }}"
    headers:
      X-Plex-Target-Client-Identifier: "{{ target_client_identifier }}"
      X-Plex-Client-Identifier: "{{ client_identifier }}"