From 91b1ebaeb71a45fac13f05ce864c61c161093ef1 Mon Sep 17 00:00:00 2001 From: OpenDave15 Date: Sat, 9 Apr 2016 21:29:06 -0600 Subject: [PATCH] Allow use of pynetgear 3.3 port parameter. (#1777) * Allow use of pynetgear 3.3 port parameter. * Fix lint problem --- homeassistant/components/device_tracker/netgear.py | 14 +++++++++----- homeassistant/const.py | 1 + requirements_all.txt | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/device_tracker/netgear.py b/homeassistant/components/device_tracker/netgear.py index 6b0cbc5f465..b20e5aae60e 100644 --- a/homeassistant/components/device_tracker/netgear.py +++ b/homeassistant/components/device_tracker/netgear.py @@ -9,14 +9,15 @@ import threading from datetime import timedelta from homeassistant.components.device_tracker import DOMAIN -from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, \ + CONF_PORT from homeassistant.util import Throttle # Return cached results if last scan was less then this time ago. MIN_TIME_BETWEEN_SCANS = timedelta(seconds=5) _LOGGER = logging.getLogger(__name__) -REQUIREMENTS = ['pynetgear==0.3.2'] +REQUIREMENTS = ['pynetgear==0.3.3'] def get_scanner(hass, config): @@ -25,12 +26,13 @@ def get_scanner(hass, config): host = info.get(CONF_HOST) username = info.get(CONF_USERNAME) password = info.get(CONF_PASSWORD) + port = info.get(CONF_PORT) if password is not None and host is None: _LOGGER.warning('Found username or password but no host') return None - scanner = NetgearDeviceScanner(host, username, password) + scanner = NetgearDeviceScanner(host, username, password, port) return scanner if scanner.success_init else None @@ -38,7 +40,7 @@ def get_scanner(hass, config): class NetgearDeviceScanner(object): """Queries a Netgear wireless router using the SOAP-API.""" - def __init__(self, host, username, password): + def __init__(self, host, username, password, port): """Initialize the scanner.""" import pynetgear @@ -49,8 +51,10 @@ class NetgearDeviceScanner(object): self._api = pynetgear.Netgear() elif username is None: self._api = pynetgear.Netgear(password, host) - else: + elif port is None: self._api = pynetgear.Netgear(password, host, username) + else: + self._api = pynetgear.Netgear(password, host, username, port) _LOGGER.info("Logging in") diff --git a/homeassistant/const.py b/homeassistant/const.py index 6837bf582e8..700c4d964a3 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -23,6 +23,7 @@ CONF_CUSTOMIZE = "customize" CONF_PLATFORM = "platform" CONF_HOST = "host" +CONF_PORT = "port" CONF_HOSTS = "hosts" CONF_USERNAME = "username" CONF_PASSWORD = "password" diff --git a/requirements_all.txt b/requirements_all.txt index b471912560a..c1c678f4f44 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -189,7 +189,7 @@ pyicloud==0.7.2 pyloopenergy==0.0.7 # homeassistant.components.device_tracker.netgear -pynetgear==0.3.2 +pynetgear==0.3.3 # homeassistant.components.alarm_control_panel.nx584 # homeassistant.components.binary_sensor.nx584