Fix Unifi direct errors caused by AP reboot. (#11835)

* Fix Unifi direct errors caused by AP reboot.

* Inverted logic in update
pull/11551/merge
William Scanlon 2018-01-21 12:13:28 -05:00 committed by Pascal Vizeli
parent 1a789a05db
commit 6a6ea263cf
1 changed files with 6 additions and 2 deletions

View File

@ -98,11 +98,15 @@ class UnifiDeviceScanner(DeviceScanner):
self.connected = False
def _get_update(self):
from pexpect import pxssh
from pexpect import pxssh, exceptions
try:
if not self.connected:
self._connect()
# If we still aren't connected at this point
# don't try to send anything to the AP.
if not self.connected:
return None
self.ssh.sendline(UNIFI_COMMAND)
self.ssh.prompt()
return self.ssh.before
@ -110,7 +114,7 @@ class UnifiDeviceScanner(DeviceScanner):
_LOGGER.error("Unexpected SSH error: %s", str(err))
self._disconnect()
return None
except AssertionError as err:
except (AssertionError, exceptions.EOF) as err:
_LOGGER.error("Connection to AP unavailable: %s", str(err))
self._disconnect()
return None