PlexDevices - Custom Media Player Component

Kyle - I think your idea for the state card is more appropriate for a new component (don’t know what, but I like the idea). I can fool around with that after I finish with this.

OK, one thing I found out is that when I was testing this on the Shield player, I was connected to my old PC server.

Connected to the PMS on the Shield and using the Player on the Shield, I’m not seeing anything on the Plexdevices client. In fact, if I view something on the PC server then move over to the Shield, the Plexdevices client still shows the last media played on the PC server.

Even if I use a web client to connect to the Shield’s PMS, it doesn’t show any media except the last thing I played on the PC’s PMS while testing. However if I press the off button in the player while playing something from the Shield, it does stop. Pause also works, but then subsequent presses do nothing; to get it to start again, I have to go to the webclient. While it is running, volume also seems to work. All of this while it is still showing the previously viewed media on the PC’s PMS. It never updates.

Here’s some of the errors I have been getting. Note that the IP in the errors is the PC’s PMS not the Shield’s PMS…:

17-02-14 22:47:32 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 298, in _error_catcher
    yield
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 380, in read
    data = self._fp.read(amt)
  File "/usr/lib/python3.4/http/client.py", line 500, in read
    return super(HTTPResponse, self).read(amt)
  File "/usr/lib/python3.4/http/client.py", line 539, in readinto
    n = self.fp.readinto(b)
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 719, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 432, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 397, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "/usr/lib/python3.4/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 303, in _error_catcher
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='192.168.1.195', port=32400): Read timed out.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1018, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/media_player/__init__.py", line 364, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/hass/custom_components/media_player/plexdevices.py", line 504, in set_volume_level
    self._active_media_plexapi_type)
  File "/home/hass/deps/plexapi/client.py", line 138, in setVolume
    def setVolume(self, volume, mtype): self.setParameters(volume=volume, mtype=mtype)      # 0-100
  File "/home/hass/deps/plexapi/client.py", line 162, in setParameters
    self.sendCommand('playback/setParameters', **params)
  File "/home/hass/deps/plexapi/client.py", line 85, in sendCommand
    return self.query(path, headers=headers)
  File "/home/hass/deps/plexapi/client.py", line 66, in query
    response = method(url, headers=headers, timeout=TIMEOUT, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 641, in send
    r.content
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 797, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 726, in generate
    raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.195', port=32400): Read timed out.
17-02-14 22:47:38 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 298, in _error_catcher
    yield
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 380, in read
    data = self._fp.read(amt)
  File "/usr/lib/python3.4/http/client.py", line 500, in read
    return super(HTTPResponse, self).read(amt)
  File "/usr/lib/python3.4/http/client.py", line 539, in readinto
    n = self.fp.readinto(b)
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 719, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 432, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 397, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "/usr/lib/python3.4/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 303, in _error_catcher
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='192.168.1.195', port=32400): Read timed out.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1018, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/media_player/__init__.py", line 364, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/hass/custom_components/media_player/plexdevices.py", line 504, in set_volume_level
    self._active_media_plexapi_type)
  File "/home/hass/deps/plexapi/client.py", line 138, in setVolume
    def setVolume(self, volume, mtype): self.setParameters(volume=volume, mtype=mtype)      # 0-100
  File "/home/hass/deps/plexapi/client.py", line 162, in setParameters
    self.sendCommand('playback/setParameters', **params)
  File "/home/hass/deps/plexapi/client.py", line 85, in sendCommand
    return self.query(path, headers=headers)
  File "/home/hass/deps/plexapi/client.py", line 66, in query
    response = method(url, headers=headers, timeout=TIMEOUT, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 641, in send
    r.content
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 797, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 726, in generate
    raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.195', port=32400): Read timed out.
17-02-14 22:47:41 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 298, in _error_catcher
    yield
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 380, in read
    data = self._fp.read(amt)
  File "/usr/lib/python3.4/http/client.py", line 500, in read
    return super(HTTPResponse, self).read(amt)
  File "/usr/lib/python3.4/http/client.py", line 539, in readinto
    n = self.fp.readinto(b)
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 719, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 432, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 397, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "/usr/lib/python3.4/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 303, in _error_catcher
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='192.168.1.195', port=32400): Read timed out.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1018, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/media_player/__init__.py", line 364, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/hass/custom_components/media_player/plexdevices.py", line 541, in media_pause
    self.device.pause(self._active_media_plexapi_type)
  File "/home/hass/deps/plexapi/client.py", line 126, in pause
    def pause(self, mtype): self.sendCommand('playback/pause', type=mtype)
  File "/home/hass/deps/plexapi/client.py", line 85, in sendCommand
    return self.query(path, headers=headers)
  File "/home/hass/deps/plexapi/client.py", line 66, in query
    response = method(url, headers=headers, timeout=TIMEOUT, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 641, in send
    r.content
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 797, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 726, in generate
    raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.195', port=32400): Read timed out.
17-02-14 22:47:57 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 298, in _error_catcher
    yield
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 380, in read
    data = self._fp.read(amt)
  File "/usr/lib/python3.4/http/client.py", line 500, in read
    return super(HTTPResponse, self).read(amt)
  File "/usr/lib/python3.4/http/client.py", line 539, in readinto
    n = self.fp.readinto(b)
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 719, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 432, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 397, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "/usr/lib/python3.4/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 303, in _error_catcher
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='192.168.1.195', port=32400): Read timed out.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1018, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/media_player/__init__.py", line 364, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/hass/custom_components/media_player/plexdevices.py", line 541, in media_pause
    self.device.pause(self._active_media_plexapi_type)
  File "/home/hass/deps/plexapi/client.py", line 126, in pause
    def pause(self, mtype): self.sendCommand('playback/pause', type=mtype)
  File "/home/hass/deps/plexapi/client.py", line 85, in sendCommand
    return self.query(path, headers=headers)
  File "/home/hass/deps/plexapi/client.py", line 66, in query
    response = method(url, headers=headers, timeout=TIMEOUT, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 641, in send
    r.content
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 797, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 726, in generate
    raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.195', port=32400): Read timed out.
17-02-14 22:48:00 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 298, in _error_catcher
    yield
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 380, in read
    data = self._fp.read(amt)
  File "/usr/lib/python3.4/http/client.py", line 500, in read
    return super(HTTPResponse, self).read(amt)
  File "/usr/lib/python3.4/http/client.py", line 539, in readinto
    n = self.fp.readinto(b)
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 719, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 432, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 397, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "/usr/lib/python3.4/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 303, in _error_catcher
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='192.168.1.195', port=32400): Read timed out.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1018, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/media_player/__init__.py", line 364, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/hass/custom_components/media_player/plexdevices.py", line 541, in media_pause
    self.device.pause(self._active_media_plexapi_type)
  File "/home/hass/deps/plexapi/client.py", line 126, in pause
    def pause(self, mtype): self.sendCommand('playback/pause', type=mtype)
  File "/home/hass/deps/plexapi/client.py", line 85, in sendCommand
    return self.query(path, headers=headers)
  File "/home/hass/deps/plexapi/client.py", line 66, in query
    response = method(url, headers=headers, timeout=TIMEOUT, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 641, in send
    r.content
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 797, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/models.py", line 726, in generate
    raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.195', port=32400): Read timed out.

Thanks. I wonder if your shield PMS is running on a different port than 32400. Can you confirm as that would explain the timeout? If not, I can check out the issue on my Shield later in the week.

Also, I’m posting an update that fixes some of those issues in your log. Looks like the shield only supports volumes 2-100. So my fake muting would never work and owed just error because I set the volume to 0 when pressing mute. I tested with mute volume being 2 but that doesn’t work. So now I just detect if the device is a shield and have the mute button do nothing.

UPDATE POSTED - Shield mute fix, custom entity IDs, mark old sessions as idle

  • Ignoring mute commands from Nvidia Shield devices - Muting requires volume=0 but the Shield errors when volume is set lower than 2.
  • Custom entity ID’s - Added a custom config option to have entity ID’s named media_player.plex_{id}, where {id} is the unique player ID
    • This avoids ambuguity issues like media_player.plex_web_safari, media_player.plex_web_safari2
    • Scenario:
      • Imagine you had an automation based on an entity name (ex. media_player.plex_web_safari)
      • The first system that ever connects over safari gets this entity name
      • Now you have a timing issue to ensure the right system gets the right name
      • You could then have a different issue if the wrong system gets the name and kicks off your automation
  • Mark old sessions as idle - Now loop through, find any device without an active session, and mark as idle

I’m not sure how that would be done but I can dig a bit.

My reasoning is I share with friends and family - it would be nice to know which entities are not within my house. If the username was also added as an attribute it could potentially be used to customize the view(s) further so that my media view is only MY players and then I have a Plex view that is all others…

1 Like

Nope. Standard 32400. And I have both PMS setup to prefer secure connections and allow my Pi’s IP without auth.

I’ll test the new update and see if it helps. Kind of frustrating because the initial versions seemed to work well and I’m not sure if I am doing something wrong. I’ve made no changes to either of my PMS besides updating the version on the PC, but that’s the one that works.

Also should note that I removed my plex.conf and disabled discovery and default view, but never got a configurator pop up.

RE: Custom cards - maybe using the new feature, here? Gonna have a peek later today.

https://home-assistant.io/developers/frontend_creating_custom_ui/

Or, it looks like some additional docs here:

have you tried entity namespace?

media_player:
  - platform: plex
    entity_namespace: 'plex'

media_player:
  - platform: cast
    entity_namespace: 'cast'

this way it would become…

   - media_player.plex_shield
   - media_player.cast_shield
2 Likes

When I figure out how to display it, I can also include the location attribute which displays “LAN” or “wan”.

I’ve never used it before but this would definitely be the case. Thanks.

Been holding my breath here for the last hour because after a reboot, my primary PC wouldn’t load Windows and I know for a fact that my Acronis backup didn’t run for a while. I just set it up to run last night but it hadn’t finished (probably part of the problem). I checked my online backup (Crash Plan) and it was up to date as of yesterday - which was a miracle of timing because I had JUST reinstalled that last week and it finally caught up.

Restarted one last time and went to vacuum to occupy myself and it’s back up… Yikes!

I’ll try this a little later - thanks for reminding me about this.

Got it working for plex servers on nvidia shield - update coming soon

1 Like

UPDATE POSTED - Support for Plex Server running on Nvidia Shield and more

  • Fixed issue preventing component from working with Nvidia Shield Plex server instances
  • Fixed issue when using custom entity id’s
  • Sped up client refreshing (changed the component to poll session data first, then client data - this seemed to noticeably speed up initial players displaying in HAS when HA starts. Other refreshes looked faster too but this is purely subjective).

Giving it a shot now!

newest update giving:

Traceback (most recent call last):
  File "uvloop/future.pyx", line 372, in uvloop.loop.BaseTask._fast_step (uvloop/loop.c:112669)
  File "/usr/src/app/homeassistant/helpers/entity_component.py", line 336, in _async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/usr/src/app/homeassistant/helpers/entity_component.py", line 205, in async_add_entity
    yield from entity.async_update_ha_state()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 240, in async_update_ha_state
    attr)
  File "/usr/src/app/homeassistant/helpers/entity.py", line 306, in _attr_setter
    value = getattr(self, name)
  File "/config/custom_components/media_player/plexdevices.py", line 573, in supported_features
    if "127.0.0.1" in self._convert_na_to_none(self.device.baseurl):
AttributeError: 'NoneType' object has no attribute 'baseurl'

That appears to be the new nVidia fix… but I don’t run an Shield…

Made some progress - at least now I am getting the media and it is showing the eps thumbnails, but the controls are missing or inoperative. I am seeing the position indicator and it updates appropriately.

However when playing, I only get a stop button and it doesn’t actually do anything. When I press it, I see the toast notification that the command was sent but nothing actually happens. If I pause with my remote, the button disappears altogether.

Playing

Paused

Also getting a torrent of errors in the logs…

17-02-16 13:19:07 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 83, in create_connection
    raise err
  File "/srv/hass/hass_venv/lib/python3.4/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/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 356, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.4/http/client.py", line 1090, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.4/http/client.py", line 1128, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.4/http/client.py", line 1086, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.4/http/client.py", line 924, in _send_output
    self.send(msg)
  File "/usr/lib/python3.4/http/client.py", line 859, in send
    self.connect()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 166, in connect
    conn = self._new_conn()
  File "/srv/hass/hass_venv/lib/python3.4/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.HTTPConnection object at 0x6c077d90>: 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/hass/hass_venv/lib/python3.4/site-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=32500): Max retries exceeded with url: /player/playback/pause?commandID=1&type=video (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x6c077d90>: 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 "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1018, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/media_player/__init__.py", line 364, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/hass/custom_components/media_player/plexdevices.py", line 619, in media_pause
    self.device.pause(self._active_media_plexapi_type)
  File "/home/hass/deps/plexapi/client.py", line 126, in pause
    def pause(self, mtype): self.sendCommand('playback/pause', type=mtype)
  File "/home/hass/deps/plexapi/client.py", line 85, in sendCommand
    return self.query(path, headers=headers)
  File "/home/hass/deps/plexapi/client.py", line 66, in query
    response = method(url, headers=headers, timeout=TIMEOUT, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/adapters.py", line 487, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=32500): Max retries exceeded with url: /player/playback/pause?commandID=1&type=video (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x6c077d90>: Failed to establish a new connection: [Errno 111] Connection refused',))
17-02-16 13:19:09 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 83, in create_connection
    raise err
  File "/srv/hass/hass_venv/lib/python3.4/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/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 356, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.4/http/client.py", line 1090, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.4/http/client.py", line 1128, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.4/http/client.py", line 1086, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.4/http/client.py", line 924, in _send_output
    self.send(msg)
  File "/usr/lib/python3.4/http/client.py", line 859, in send
    self.connect()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 166, in connect
    conn = self._new_conn()
  File "/srv/hass/hass_venv/lib/python3.4/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.HTTPConnection object at 0x68c252f0>: 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/hass/hass_venv/lib/python3.4/site-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=32500): Max retries exceeded with url: /player/playback/pause?commandID=2&type=video (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x68c252f0>: 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 "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1018, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/media_player/__init__.py", line 364, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/hass/custom_components/media_player/plexdevices.py", line 619, in media_pause
    self.device.pause(self._active_media_plexapi_type)
  File "/home/hass/deps/plexapi/client.py", line 126, in pause
    def pause(self, mtype): self.sendCommand('playback/pause', type=mtype)
  File "/home/hass/deps/plexapi/client.py", line 85, in sendCommand
    return self.query(path, headers=headers)
  File "/home/hass/deps/plexapi/client.py", line 66, in query
    response = method(url, headers=headers, timeout=TIMEOUT, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/adapters.py", line 487, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=32500): Max retries exceeded with url: /player/playback/pause?commandID=2&type=video (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x68c252f0>: Failed to establish a new connection: [Errno 111] Connection refused',))

This was only a portion - post limits prevented me from posting the whole thing. Seems to happen only when trying to press the button.

1 Like

If you are using the same Nvidia shield as a server and a client, then this is a known issue I coded for (disabling the controls) and documented. In this scenario, the local client doesn’t get a real IP address (gets a loopback address) so all API calls fail. Maybe I can get around that by using the address of the server and calling the commands via url. Let me know if this is your circumstance.

Another update coming soon regarding the shield: In my testing:

  • remote client (ex. iPhone) streaming from shield PMS: controls display and work fine
  • local client (ex. playing directly on the shield or casting to the shield) streaming from shield PMS: controls disabled (by me) since they don’t work (because the client does not have a registered IP address and can’t be controlled via the web api)
  • local client (ex. playing directly on the shield) streaming from another PMS: controls display and work mostly fine: Errors display whenever volume is lowered below 2. I also disable mute because of this.

Yes, that is my use case exactly. PMS runs in the background and the client is a separate app.

I guess that’s why it works when I point it to my old PC server. But I am planning on decommissioning that as that was the whole reason I bought the Shield. I’m hoping to turn the old PMS into a Linux box to run HA.

To be honest, if you can’t find a way around control from the HA UI it wouldn’t be the end of this for me as long as I could still access the controls from within an automation somehow. I really don’t use the UI for control that often.

(But I’d be happier if you can make it work, of course! :wink:)

Whatever I can do to help, testing, documenting things like this - I stand at the ready!

1 Like