mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix flood of errors if Plex server goes offline (#2447)
This commit is contained in:
parent
0f4acb59fe
commit
86e3fdee1c
@ -122,7 +122,11 @@ def setup_plexserver(host, token, hass, add_devices_callback):
|
|||||||
try:
|
try:
|
||||||
devices = plexserver.clients()
|
devices = plexserver.clients()
|
||||||
except plexapi.exceptions.BadRequest:
|
except plexapi.exceptions.BadRequest:
|
||||||
_LOGGER.exception("Error listing plex devices")
|
_LOGGER.exception('Error listing plex devices')
|
||||||
|
return
|
||||||
|
except OSError:
|
||||||
|
_LOGGER.error(
|
||||||
|
'Could not connect to plex server at http://%s', host)
|
||||||
return
|
return
|
||||||
|
|
||||||
new_plex_clients = []
|
new_plex_clients = []
|
||||||
@ -148,7 +152,7 @@ def setup_plexserver(host, token, hass, add_devices_callback):
|
|||||||
try:
|
try:
|
||||||
sessions = plexserver.sessions()
|
sessions = plexserver.sessions()
|
||||||
except plexapi.exceptions.BadRequest:
|
except plexapi.exceptions.BadRequest:
|
||||||
_LOGGER.exception("Error listing plex sessions")
|
_LOGGER.exception('Error listing plex sessions')
|
||||||
return
|
return
|
||||||
|
|
||||||
plex_sessions.clear()
|
plex_sessions.clear()
|
||||||
@ -166,7 +170,7 @@ def request_configuration(host, hass, add_devices_callback):
|
|||||||
# We got an error if this method is called while we are configuring
|
# We got an error if this method is called while we are configuring
|
||||||
if host in _CONFIGURING:
|
if host in _CONFIGURING:
|
||||||
configurator.notify_errors(
|
configurator.notify_errors(
|
||||||
_CONFIGURING[host], "Failed to register, please try again.")
|
_CONFIGURING[host], 'Failed to register, please try again.')
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -175,10 +179,10 @@ def request_configuration(host, hass, add_devices_callback):
|
|||||||
setup_plexserver(host, data.get('token'), hass, add_devices_callback)
|
setup_plexserver(host, data.get('token'), hass, add_devices_callback)
|
||||||
|
|
||||||
_CONFIGURING[host] = configurator.request_config(
|
_CONFIGURING[host] = configurator.request_config(
|
||||||
hass, "Plex Media Server", plex_configuration_callback,
|
hass, 'Plex Media Server', plex_configuration_callback,
|
||||||
description=('Enter the X-Plex-Token'),
|
description=('Enter the X-Plex-Token'),
|
||||||
description_image="/static/images/config_plex_mediaserver.png",
|
description_image='/static/images/config_plex_mediaserver.png',
|
||||||
submit_caption="Confirm",
|
submit_caption='Confirm',
|
||||||
fields=[{'id': 'token', 'name': 'X-Plex-Token', 'type': ''}]
|
fields=[{'id': 'token', 'name': 'X-Plex-Token', 'type': ''}]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -201,7 +205,7 @@ class PlexClient(MediaPlayerDevice):
|
|||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the id of this plex client."""
|
"""Return the id of this plex client."""
|
||||||
return "{}.{}".format(
|
return '{}.{}'.format(
|
||||||
self.__class__, self.device.machineIdentifier or self.device.name)
|
self.__class__, self.device.machineIdentifier or self.device.name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user