mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
Allow use of pynetgear 3.3 port parameter. (#1777)
* Allow use of pynetgear 3.3 port parameter. * Fix lint problem
This commit is contained in:
parent
1e86044590
commit
91b1ebaeb7
@ -9,14 +9,15 @@ import threading
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.components.device_tracker import DOMAIN
|
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
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
# Return cached results if last scan was less then this time ago.
|
# Return cached results if last scan was less then this time ago.
|
||||||
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=5)
|
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=5)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
REQUIREMENTS = ['pynetgear==0.3.2']
|
REQUIREMENTS = ['pynetgear==0.3.3']
|
||||||
|
|
||||||
|
|
||||||
def get_scanner(hass, config):
|
def get_scanner(hass, config):
|
||||||
@ -25,12 +26,13 @@ def get_scanner(hass, config):
|
|||||||
host = info.get(CONF_HOST)
|
host = info.get(CONF_HOST)
|
||||||
username = info.get(CONF_USERNAME)
|
username = info.get(CONF_USERNAME)
|
||||||
password = info.get(CONF_PASSWORD)
|
password = info.get(CONF_PASSWORD)
|
||||||
|
port = info.get(CONF_PORT)
|
||||||
|
|
||||||
if password is not None and host is None:
|
if password is not None and host is None:
|
||||||
_LOGGER.warning('Found username or password but no host')
|
_LOGGER.warning('Found username or password but no host')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
scanner = NetgearDeviceScanner(host, username, password)
|
scanner = NetgearDeviceScanner(host, username, password, port)
|
||||||
|
|
||||||
return scanner if scanner.success_init else None
|
return scanner if scanner.success_init else None
|
||||||
|
|
||||||
@ -38,7 +40,7 @@ def get_scanner(hass, config):
|
|||||||
class NetgearDeviceScanner(object):
|
class NetgearDeviceScanner(object):
|
||||||
"""Queries a Netgear wireless router using the SOAP-API."""
|
"""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."""
|
"""Initialize the scanner."""
|
||||||
import pynetgear
|
import pynetgear
|
||||||
|
|
||||||
@ -49,8 +51,10 @@ class NetgearDeviceScanner(object):
|
|||||||
self._api = pynetgear.Netgear()
|
self._api = pynetgear.Netgear()
|
||||||
elif username is None:
|
elif username is None:
|
||||||
self._api = pynetgear.Netgear(password, host)
|
self._api = pynetgear.Netgear(password, host)
|
||||||
else:
|
elif port is None:
|
||||||
self._api = pynetgear.Netgear(password, host, username)
|
self._api = pynetgear.Netgear(password, host, username)
|
||||||
|
else:
|
||||||
|
self._api = pynetgear.Netgear(password, host, username, port)
|
||||||
|
|
||||||
_LOGGER.info("Logging in")
|
_LOGGER.info("Logging in")
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ CONF_CUSTOMIZE = "customize"
|
|||||||
|
|
||||||
CONF_PLATFORM = "platform"
|
CONF_PLATFORM = "platform"
|
||||||
CONF_HOST = "host"
|
CONF_HOST = "host"
|
||||||
|
CONF_PORT = "port"
|
||||||
CONF_HOSTS = "hosts"
|
CONF_HOSTS = "hosts"
|
||||||
CONF_USERNAME = "username"
|
CONF_USERNAME = "username"
|
||||||
CONF_PASSWORD = "password"
|
CONF_PASSWORD = "password"
|
||||||
|
@ -189,7 +189,7 @@ pyicloud==0.7.2
|
|||||||
pyloopenergy==0.0.7
|
pyloopenergy==0.0.7
|
||||||
|
|
||||||
# homeassistant.components.device_tracker.netgear
|
# homeassistant.components.device_tracker.netgear
|
||||||
pynetgear==0.3.2
|
pynetgear==0.3.3
|
||||||
|
|
||||||
# homeassistant.components.alarm_control_panel.nx584
|
# homeassistant.components.alarm_control_panel.nx584
|
||||||
# homeassistant.components.binary_sensor.nx584
|
# homeassistant.components.binary_sensor.nx584
|
||||||
|
Loading…
x
Reference in New Issue
Block a user