PlexDevices - Custom Media Player Component

In the same directory as your configuration.yaml, create a new folder called ‘custom_components’ - inside that, create another folder called ‘media_player’ then drop the plexdevices.py inside the media_player folder.

Testing this now; note that the readme.md has platform: plex instead of platform: plexdevices.

thank you… wasn’t sure which way it should be. :slight_smile:

I’m trying to test this in place with the existing Plex client and figuring out which is which isn’t easy.

I use a nvidia Shield as my new Plex server and finally figured out what my missing ‘third’ media player was.

I get one for the Standard Plex client, one for the Shield as a Chromecast device and one for the Plexdevices Plex client.

Entity-wise, this shows up as:

media_player.shield
media_player.shield_2
media_player.shield_3

Unfortunately naming them isn’t as easy as it appears that they get entity names according to the order they get initialized and that doesn’t appear to be in a set (and consistent) order.

I think for testing purposes, I’m going to need to disable the standard Plex client.

Can we get the username added to the card?

Also, for the groups, is it possible to have a single card with a line description/status for each device?

AppleTV    Playing    Quantico    S02E04    mrpicklehead
Pixel      Paused     Arrow       S02E10    jimbob
Roku       Playing    The Flash   S01E08    XXcooldudeXX
Samsung    Idle
iPhone     Idle
iPhone     Idle

OK, I got some things sorted out and tests on the ShieldTV look good. I can control the media and while the display of the state seems to be a little laggy, the actual response on the client side is immediate.

I think my volume controls would work to but I have to change some settings on the Shield so it’s not controlled by the AV Receiver.

I can also report that this client works really well in the Universal Media Player and all controls in the plexdevice client still work in Universal Media Player.

Even with the standard Plex client commented out, I am still getting a third instance, but I am thinking that it may be due to discovery. We’ve been discussing this here:

@JesseWebDotCom - is there anything specific I can test for you in my setup?

Quick reply - sounds like it’s working well. If you guys can:

  • please test with media_player.plex off (that means don’t reference it in your config and turn off discovery)
  • compare your results between this component and media-player.plex
  • compare between this component and your plex now playing screen

Everything should be working (within the noted limitations). I did notice and plan to code for a scenario where the plex server says media is playing but you can see the duration is 0 or the position hasn’t moved. Let me know of any other scenarios you spot and send me details/screenshots. I plan to wrap this up and submit to ha this weekend as an update to the current plex component

Thanks again

documentation updated

I was contemplating changing the entity id’s as I too hate the ambiguous names. I’d change them to client ids - they would be ugly, but unique. I think the ID would only change if the plex client was reinstalled on a given device - so there’s risk but less than what’s currently (i.e. anyone can rename their device at any time). Let me know your thoughts and I’ll see if that’s doable over the next few days.

Kyle - I don’t think I can do anything about state cards as it should use the default media_player card. If you have an example on how to change it or separately how to add additional attributes to a device (i.e. so I can add username), let me know.

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