Update pynetgear to latest version
This commit is contained in:
parent
8562b8f09d
commit
45e295c1d3
2 changed files with 16 additions and 21 deletions
|
@ -22,7 +22,10 @@ def get_scanner(hass, config):
|
|||
_LOGGER):
|
||||
return None
|
||||
|
||||
scanner = NetgearDeviceScanner(config[DOMAIN])
|
||||
info = config[DOMAIN]
|
||||
|
||||
scanner = NetgearDeviceScanner(
|
||||
info[CONF_HOST], info[CONF_USERNAME], info[CONF_PASSWORD])
|
||||
|
||||
return scanner if scanner.success_init else None
|
||||
|
||||
|
@ -30,10 +33,7 @@ def get_scanner(hass, config):
|
|||
class NetgearDeviceScanner(object):
|
||||
""" This class queries a Netgear wireless router using the SOAP-api. """
|
||||
|
||||
def __init__(self, config):
|
||||
host = config[CONF_HOST]
|
||||
username, password = config[CONF_USERNAME], config[CONF_PASSWORD]
|
||||
|
||||
def __init__(self, host, username, password):
|
||||
self.last_results = []
|
||||
|
||||
try:
|
||||
|
@ -54,32 +54,27 @@ class NetgearDeviceScanner(object):
|
|||
self.lock = threading.Lock()
|
||||
|
||||
_LOGGER.info("Logging in")
|
||||
if self._api.login():
|
||||
self.success_init = True
|
||||
self._update_info()
|
||||
|
||||
self.success_init = self._api.login()
|
||||
|
||||
if self.success_init:
|
||||
self._update_info()
|
||||
else:
|
||||
_LOGGER.error("Failed to Login")
|
||||
|
||||
self.success_init = False
|
||||
|
||||
def scan_devices(self):
|
||||
""" Scans for new devices and return a
|
||||
list containing found device ids. """
|
||||
|
||||
self._update_info()
|
||||
|
||||
return [device.mac for device in self.last_results]
|
||||
return (device.mac for device in self.last_results)
|
||||
|
||||
def get_device_name(self, mac):
|
||||
""" Returns the name of the given device or None if we don't know. """
|
||||
|
||||
filter_named = [device.name for device in self.last_results
|
||||
if device.mac == mac]
|
||||
|
||||
if filter_named:
|
||||
return filter_named[0]
|
||||
else:
|
||||
try:
|
||||
return next(device.name for device in self.last_results
|
||||
if device.mac == mac)
|
||||
except StopIteration:
|
||||
return None
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||
|
@ -92,4 +87,4 @@ class NetgearDeviceScanner(object):
|
|||
with self.lock:
|
||||
_LOGGER.info("Scanning")
|
||||
|
||||
self.last_results = self._api.get_attached_devices()
|
||||
self.last_results = self._api.get_attached_devices() or []
|
||||
|
|
2
homeassistant/external/pynetgear
vendored
2
homeassistant/external/pynetgear
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 991fbc9c42abe3e8bcce50fbf549d9fceefe1e29
|
||||
Subproject commit e76b2df5170d65c56d406d79d9944b724de6382e
|
Loading…
Add table
Add a link
Reference in a new issue