mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 12:45:28 +02:00
Update pynetgear to latest version
This commit is contained in:
@@ -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
Submodule homeassistant/external/pynetgear updated: 991fbc9c42...e76b2df517
Reference in New Issue
Block a user