PlexDevices - Custom Media Player Component

I just read it, did you find any solution or suspect what the problem is?

Nope, i think that @JesseWebDotCom might be of help, don’t know if he’s on vacation or anything :slight_smile: its nice weather these days…

I haven’t looked into the code but it seems to only register play/pause event. Like a button event, but it doesn’t register the actual status of the movie.The method of registering the status of the movie maybe needs to be redefined to get the actual state from plex rather then button events.

Did it work for you in the past? Maybe there was a server update that made some api changes?

I’m not sure if it worked well before. I added the component recently and I don’t think I watch a complete movie. I tested only to play/pause it.

What I noticed was that after paused then exiting, the state was set to paused…supporting my theory about it only changes status based on play/pause button event. Again, my experience is limited with the component.

Heck I can’t even get this nor the original Plex working. Plex sensor works fine, but neither of these show anything in states.

I’ve tried this on two different installations with no luck. I see the connections being made to http://<server_hostname>:32400/clients?X-Plex-Token=<token> but the entity is never created. Tested while playing on various clients.

I’ve also checked the URL manually and it resolves, but always with an empty response:

`$ curl http://<server_hostname>:32400/clients?X-Plex-Token=

<?xml version="1.0" encoding="UTF-8"?> `

Has the API changed, or am I missing something obvious?

Looks like the clients URL above always returns nothing. However, using http://<plex_server_hostname>:32400/status/sessions provides full information on currently playing streams.

Is the existing component actually working for anyone on current Plex versions? I’m on 1.7.5.4035.

Try to see if this works for you:

https://community.home-assistant.io/t/status-of-a-plex-client-useful-to-trigger-automation/18540?source_topic_id=20341

Since I switched from a local to a remote server I’m having exactly the same problem.

Will this work and tell me the status of a RasPlex Plex client on my LAN that connects to a friend’s Plex Server?

Not sure, But I’m running the latest LibreElec with PlexKodiConnect plugin and then it works also via the normal Kodi Component.

Is this project dead? Links to the OP’s github for this result in a 404 now.

This component has been merged into HA itself for a while now, I’m not sure if he made any additional changes, but in any case, the actual HA Plex Media player is now this updated one.

1 Like

Bummer… I was hoping this project would solve the issue popping up in my error log…

2017-08-24 06:59:55 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform plex
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py", line 83, in create_connection
    raise err
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 284, in connect
    conn = self._new_conn()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x68648ef0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/adapters.py", line 438, in send
    timeout=timeout
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='my.plexapp.com', port=443): Max retries exceeded with url: /users/sign_in.xml (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x68648ef0>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/sensor/plex.py", line 52, in setup_platform
    name, plex_url, plex_user, plex_password, plex_server)], True)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/sensor/plex.py", line 70, in __init__
    user = MyPlexAccount.signin(plex_user, plex_password)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/plexapi/myplex.py", line 76, in signin
    response = requests.post(cls.SIGNIN, headers=plexapi.BASE_HEADERS, auth=auth, timeout=TIMEOUT)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/sessions.py", line 518, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/sessions.py", line 639, in send
    r = adapter.send(request, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/requests/adapters.py", line 502, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='my.plexapp.com', port=443): Max retries exceeded with url: /users/sign_in.xml (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x68648ef0>: Failed to establish a new connection: [Errno 111] Connection refused',))

I created a feature request but this thread seems to have more activity… would it be possible to add the video height and width to the info it pulls of the movie playing… I want to be able to trigger my projector screen masking system based on the videos dimensions of the black bars that go on the top and bottom of the screen.

So i have tried to edit the plex.py file in homeassistant to get the media height. But its not working… the script seems to still be running fine im not getting any errors in the logs, but im not seeing the data in the attributes of home assistant.

image

Can we pull height and width attribute information?.. Ive been asking this question all over the forum but it seems like its fallen on deaf ears… ive been trying to modify this script myself but everything i try doesnt work. There isnt any kind of documentation to understand how its pulling the data into homeassistant.

I am trying to make a view/tab with all of my Plex media players. At times I have up to 10 showing. I have read that dynamic groups are created but I am not able to see them. Any help would be much appreciated. The issue is new ones are added when someone access from a new player example 2 different computers. Where can I find this dynamic group so I can make it a view?

@JesseWebDotCom

Hi,

I’m trying to play movies from PMS to Chromecast. TV switches to Cc, Cc loads the HA player (not Plex) then turns to idle.

I assume Plex needs to be streamed on the Cc however I didn’t find the relevant part where it loads the Plex component.

I have set the following script (there are no errors in the HA log; video name corresponds to the one in Plex).

Thanks

test:
  sequence:
    - service: media_player.play_media
      entity_id: media_player.chromecast2
      data:
        media_content_id: '{ \"library_name\" : \"Movies\", \"video_name\" : \"Videoname1\", \"shuffle\": \"0\"}'
        media_content_type: VIDEO