Fix Plex component to use port number in discovery. (#8197)

* Fix Plex component to use port number in discovery.

* Break line

* Correctly save port to config

* Handle port with fewer code changes

* This is stuck configuring and I'm not sure why

* Changes suggested by @dale3h
This commit is contained in:
Adam Baxter 2017-06-26 09:06:15 +10:00 committed by Dale Higgs
parent 2dd7f0616e
commit f02d169864

View File

@ -88,6 +88,8 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
elif discovery_info is not None:
# Parse discovery data
host = discovery_info.get('host')
port = discovery_info.get('port')
host = '%s:%s' % (host, port)
_LOGGER.info("Discovered PLEX server: %s", host)
if host in _CONFIGURING:
@ -106,6 +108,7 @@ def setup_plexserver(host, token, hass, config, add_devices_callback):
try:
plexserver = plexapi.server.PlexServer('http://%s' % host, token)
_LOGGER.info("Discovery configuration done (no token needed)")
except (plexapi.exceptions.BadRequest, plexapi.exceptions.Unauthorized,
plexapi.exceptions.NotFound) as error:
_LOGGER.info(error)