Only try to pair notify.webostv when not paired (#5967)

This allows the notify.webostv component to successfully register when
the TV is not currently powered on as long as a pairing record exists.
pull/5198/merge
Josh Anderson 2017-02-13 21:29:18 +00:00 committed by Pascal Vizeli
parent 0feb1c3e28
commit 401263519d
1 changed files with 9 additions and 8 deletions

View File

@ -34,14 +34,15 @@ def get_service(hass, config, discovery_info=None):
path = hass.config.path(config.get(CONF_FILENAME))
client = WebOsClient(config.get(CONF_HOST), key_file_path=path)
try:
client.register()
except PyLGTVPairException:
_LOGGER.error("Pairing with TV failed")
return None
except OSError:
_LOGGER.error("TV unreachable")
return None
if not client.is_registered():
try:
client.register()
except PyLGTVPairException:
_LOGGER.error("Pairing with TV failed")
return None
except OSError:
_LOGGER.error("TV unreachable")
return None
return LgWebOSNotificationService(client)