From 975befd136fb0d4b3c6b785733f90ce587bda29a Mon Sep 17 00:00:00 2001 From: Tim Bailey Date: Mon, 20 Aug 2018 22:34:52 +1000 Subject: [PATCH] TpLink Device Tracker Error (#15918) * Fix 'Error setting up platform tplink' error when a scanner fails even if another scanner would succeed * Try to fix tox errors * Adjust code based on PR comments --- .../components/device_tracker/tplink.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/device_tracker/tplink.py b/homeassistant/components/device_tracker/tplink.py index 346f381db34..9bf85e39faf 100644 --- a/homeassistant/components/device_tracker/tplink.py +++ b/homeassistant/components/device_tracker/tplink.py @@ -69,11 +69,16 @@ class TplinkDeviceScanner(DeviceScanner): password = config[CONF_PASSWORD] username = config[CONF_USERNAME] - self.tplink_client = TpLinkClient( - password, host=host, username=username) + self.success_init = False + try: + self.tplink_client = TpLinkClient( + password, host=host, username=username) - self.last_results = {} - self.success_init = self._update_info() + self.last_results = {} + + self.success_init = self._update_info() + except requests.exceptions.ConnectionError: + _LOGGER.debug("ConnectionError in TplinkDeviceScanner") def scan_devices(self): """Scan for new devices and return a list with found device IDs.""" @@ -115,7 +120,11 @@ class Tplink1DeviceScanner(DeviceScanner): self.password = password self.last_results = {} - self.success_init = self._update_info() + self.success_init = False + try: + self.success_init = self._update_info() + except requests.exceptions.ConnectionError: + _LOGGER.debug("ConnectionError in Tplink1DeviceScanner") def scan_devices(self): """Scan for new devices and return a list with found device IDs."""