Allow use of pynetgear 3.3 port parameter. (#1777)

* Allow use of pynetgear 3.3 port parameter.

* Fix lint problem
pull/1780/head
OpenDave15 2016-04-09 21:29:06 -06:00 committed by Paulus Schoutsen
parent 1e86044590
commit 91b1ebaeb7
3 changed files with 11 additions and 6 deletions

View File

@ -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")

View File

@ -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"

View File

@ -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