mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Update docstring (config file) and attempt to honor PEP0257
This commit is contained in:
parent
1ed8e58679
commit
514b8eddb9
@ -1,6 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.device_tracker.actiontec
|
homeassistant.components.device_tracker.actiontec
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Device tracker platform that supports scanning an Actiontec MI424WR
|
Device tracker platform that supports scanning an Actiontec MI424WR
|
||||||
(Verizon FIOS) router for device presence.
|
(Verizon FIOS) router for device presence.
|
||||||
|
|
||||||
@ -9,10 +9,9 @@ This device tracker needs telnet to be enabled on the router.
|
|||||||
Configuration:
|
Configuration:
|
||||||
|
|
||||||
To use the Actiontec tracker you will need to add something like the
|
To use the Actiontec tracker you will need to add something like the
|
||||||
following to your config/configuration.yaml. If you experience disconnects
|
following to your configuration.yaml file. If you experience disconnects
|
||||||
you can modify the home_interval variable.
|
you can modify the home_interval variable.
|
||||||
|
|
||||||
|
|
||||||
device_tracker:
|
device_tracker:
|
||||||
platform: actiontec
|
platform: actiontec
|
||||||
host: YOUR_ROUTER_IP
|
host: YOUR_ROUTER_IP
|
||||||
@ -69,7 +68,7 @@ _LEASES_REGEX = re.compile(
|
|||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def get_scanner(hass, config):
|
def get_scanner(hass, config):
|
||||||
""" Validates config and returns a DD-WRT scanner. """
|
""" Validates config and returns an Actiontec scanner. """
|
||||||
if not validate_config(config,
|
if not validate_config(config,
|
||||||
{DOMAIN: [CONF_HOST, CONF_USERNAME, CONF_PASSWORD]},
|
{DOMAIN: [CONF_HOST, CONF_USERNAME, CONF_PASSWORD]},
|
||||||
_LOGGER):
|
_LOGGER):
|
||||||
@ -83,8 +82,9 @@ Device = namedtuple("Device", ["mac", "ip", "last_update"])
|
|||||||
|
|
||||||
|
|
||||||
class ActiontecDeviceScanner(object):
|
class ActiontecDeviceScanner(object):
|
||||||
""" This class queries a an actiontec router
|
"""
|
||||||
for connected devices. Adapted from DD-WRT scanner.
|
This class queries a an actiontec router for connected devices.
|
||||||
|
Adapted from DD-WRT scanner.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
@ -106,8 +106,9 @@ class ActiontecDeviceScanner(object):
|
|||||||
_LOGGER.info("home_interval set to: %s", self.home_interval)
|
_LOGGER.info("home_interval set to: %s", self.home_interval)
|
||||||
|
|
||||||
def scan_devices(self):
|
def scan_devices(self):
|
||||||
""" Scans for new devices and return a
|
"""
|
||||||
list containing found device ids. """
|
Scans for new devices and return a list containing found device ids.
|
||||||
|
"""
|
||||||
|
|
||||||
self._update_info()
|
self._update_info()
|
||||||
return [client.mac for client in self.last_results]
|
return [client.mac for client in self.last_results]
|
||||||
@ -123,8 +124,10 @@ class ActiontecDeviceScanner(object):
|
|||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
""" Ensures the information from the Actiontec MI424WR router is up
|
"""
|
||||||
to date. Returns boolean if scanning successful. """
|
Ensures the information from the Actiontec MI424WR router is up
|
||||||
|
to date. Returns boolean if scanning successful.
|
||||||
|
"""
|
||||||
_LOGGER.info("Scanning")
|
_LOGGER.info("Scanning")
|
||||||
if not self.success_init:
|
if not self.success_init:
|
||||||
return False
|
return False
|
||||||
@ -155,7 +158,7 @@ class ActiontecDeviceScanner(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def get_actiontec_data(self):
|
def get_actiontec_data(self):
|
||||||
""" Retrieve data from Actiontec MI424WR and return parsed result. """
|
""" Retrieve data from Actiontec MI424WR and return parsed result. """
|
||||||
try:
|
try:
|
||||||
telnet = telnetlib.Telnet(self.host)
|
telnet = telnetlib.Telnet(self.host)
|
||||||
telnet.read_until(b'Username: ')
|
telnet.read_until(b'Username: ')
|
||||||
|
@ -9,8 +9,8 @@ This device tracker needs telnet to be enabled on the router.
|
|||||||
Configuration:
|
Configuration:
|
||||||
|
|
||||||
To use the Aruba tracker you will need to add something like the following
|
To use the Aruba tracker you will need to add something like the following
|
||||||
to your config/configuration.yaml. You also need to enable Telnet in the
|
to your configuration.yaml file. You also need to enable Telnet in the
|
||||||
configuration pages.
|
configuration page of your router.
|
||||||
|
|
||||||
device_tracker:
|
device_tracker:
|
||||||
platform: aruba
|
platform: aruba
|
||||||
@ -83,8 +83,9 @@ class ArubaDeviceScanner(object):
|
|||||||
self.success_init = data is not None
|
self.success_init = data is not None
|
||||||
|
|
||||||
def scan_devices(self):
|
def scan_devices(self):
|
||||||
""" Scans for new devices and return a list containing found device
|
"""
|
||||||
ids. """
|
Scans for new devices and return a list containing found device IDs.
|
||||||
|
"""
|
||||||
|
|
||||||
self._update_info()
|
self._update_info()
|
||||||
return [client['mac'] for client in self.last_results]
|
return [client['mac'] for client in self.last_results]
|
||||||
@ -100,8 +101,10 @@ class ArubaDeviceScanner(object):
|
|||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
""" Ensures the information from the Aruba Access Point is up to date.
|
"""
|
||||||
Returns boolean if scanning successful. """
|
Ensures the information from the Aruba Access Point is up to date.
|
||||||
|
Returns boolean if scanning successful.
|
||||||
|
"""
|
||||||
if not self.success_init:
|
if not self.success_init:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -114,8 +117,7 @@ class ArubaDeviceScanner(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def get_aruba_data(self):
|
def get_aruba_data(self):
|
||||||
""" Retrieve data from Aruba Access Point and return parsed
|
""" Retrieve data from Aruba Access Point and return parsed result. """
|
||||||
result. """
|
|
||||||
try:
|
try:
|
||||||
telnet = telnetlib.Telnet(self.host)
|
telnet = telnetlib.Telnet(self.host)
|
||||||
telnet.read_until(b'User: ')
|
telnet.read_until(b'User: ')
|
||||||
|
@ -9,7 +9,7 @@ This device tracker needs telnet to be enabled on the router.
|
|||||||
Configuration:
|
Configuration:
|
||||||
|
|
||||||
To use the ASUSWRT tracker you will need to add something like the following
|
To use the ASUSWRT tracker you will need to add something like the following
|
||||||
to your config/configuration.yaml
|
to your configuration.yaml file.
|
||||||
|
|
||||||
device_tracker:
|
device_tracker:
|
||||||
platform: asuswrt
|
platform: asuswrt
|
||||||
@ -63,7 +63,7 @@ _IP_NEIGH_REGEX = re.compile(
|
|||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def get_scanner(hass, config):
|
def get_scanner(hass, config):
|
||||||
""" Validates config and returns a DD-WRT scanner. """
|
""" Validates config and returns an ASUS-WRT scanner. """
|
||||||
if not validate_config(config,
|
if not validate_config(config,
|
||||||
{DOMAIN: [CONF_HOST, CONF_USERNAME, CONF_PASSWORD]},
|
{DOMAIN: [CONF_HOST, CONF_USERNAME, CONF_PASSWORD]},
|
||||||
_LOGGER):
|
_LOGGER):
|
||||||
@ -75,7 +75,8 @@ def get_scanner(hass, config):
|
|||||||
|
|
||||||
|
|
||||||
class AsusWrtDeviceScanner(object):
|
class AsusWrtDeviceScanner(object):
|
||||||
""" This class queries a router running ASUSWRT firmware
|
"""
|
||||||
|
This class queries a router running ASUSWRT firmware
|
||||||
for connected devices. Adapted from DD-WRT scanner.
|
for connected devices. Adapted from DD-WRT scanner.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -93,8 +94,9 @@ class AsusWrtDeviceScanner(object):
|
|||||||
self.success_init = data is not None
|
self.success_init = data is not None
|
||||||
|
|
||||||
def scan_devices(self):
|
def scan_devices(self):
|
||||||
""" Scans for new devices and return a
|
"""
|
||||||
list containing found device ids. """
|
Scans for new devices and return a list containing found device IDs.
|
||||||
|
"""
|
||||||
|
|
||||||
self._update_info()
|
self._update_info()
|
||||||
return [client['mac'] for client in self.last_results]
|
return [client['mac'] for client in self.last_results]
|
||||||
@ -110,8 +112,10 @@ class AsusWrtDeviceScanner(object):
|
|||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
""" Ensures the information from the ASUSWRT router is up to date.
|
"""
|
||||||
Returns boolean if scanning successful. """
|
Ensures the information from the ASUSWRT router is up to date.
|
||||||
|
Returns boolean if scanning successful.
|
||||||
|
"""
|
||||||
if not self.success_init:
|
if not self.success_init:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -129,7 +133,7 @@ class AsusWrtDeviceScanner(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def get_asuswrt_data(self):
|
def get_asuswrt_data(self):
|
||||||
""" Retrieve data from ASUSWRT and return parsed result. """
|
""" Retrieve data from ASUSWRT and return parsed result. """
|
||||||
try:
|
try:
|
||||||
telnet = telnetlib.Telnet(self.host)
|
telnet = telnetlib.Telnet(self.host)
|
||||||
telnet.read_until(b'login: ')
|
telnet.read_until(b'login: ')
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.device_tracker.ddwrt
|
homeassistant.components.device_tracker.ddwrt
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Device tracker platform that supports scanning a DD-WRT router for device
|
Device tracker platform that supports scanning a DD-WRT router for device
|
||||||
presence.
|
presence.
|
||||||
|
|
||||||
Configuration:
|
Configuration:
|
||||||
|
|
||||||
To use the DD-WRT tracker you will need to add something like the following
|
To use the DD-WRT tracker you will need to add something like the following
|
||||||
to your config/configuration.yaml
|
to your configuration.yaml file.
|
||||||
|
|
||||||
device_tracker:
|
device_tracker:
|
||||||
platform: ddwrt
|
platform: ddwrt
|
||||||
@ -64,7 +63,8 @@ def get_scanner(hass, config):
|
|||||||
|
|
||||||
# pylint: disable=too-many-instance-attributes
|
# pylint: disable=too-many-instance-attributes
|
||||||
class DdWrtDeviceScanner(object):
|
class DdWrtDeviceScanner(object):
|
||||||
""" This class queries a wireless router running DD-WRT firmware
|
"""
|
||||||
|
This class queries a wireless router running DD-WRT firmware
|
||||||
for connected devices. Adapted from Tomato scanner.
|
for connected devices. Adapted from Tomato scanner.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -85,8 +85,9 @@ class DdWrtDeviceScanner(object):
|
|||||||
self.success_init = data is not None
|
self.success_init = data is not None
|
||||||
|
|
||||||
def scan_devices(self):
|
def scan_devices(self):
|
||||||
""" Scans for new devices and return a
|
"""
|
||||||
list containing found device ids. """
|
Scans for new devices and return a list containing found device ids.
|
||||||
|
"""
|
||||||
|
|
||||||
self._update_info()
|
self._update_info()
|
||||||
|
|
||||||
@ -124,8 +125,10 @@ class DdWrtDeviceScanner(object):
|
|||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
""" Ensures the information from the DD-WRT router is up to date.
|
"""
|
||||||
Returns boolean if scanning successful. """
|
Ensures the information from the DD-WRT router is up to date.
|
||||||
|
Returns boolean if scanning successful.
|
||||||
|
"""
|
||||||
if not self.success_init:
|
if not self.success_init:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -163,7 +166,7 @@ class DdWrtDeviceScanner(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def get_ddwrt_data(self, url):
|
def get_ddwrt_data(self, url):
|
||||||
""" Retrieve data from DD-WRT and return parsed result. """
|
""" Retrieve data from DD-WRT and return parsed result. """
|
||||||
try:
|
try:
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
url,
|
url,
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.device_tracker.luci
|
homeassistant.components.device_tracker.luci
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Device tracker platform that supports scanning a OpenWRT router for device
|
Device tracker platform that supports scanning a OpenWRT router for device
|
||||||
presence.
|
presence.
|
||||||
|
|
||||||
|
|
||||||
It's required that the luci RPC package is installed on the OpenWRT router:
|
It's required that the luci RPC package is installed on the OpenWRT router:
|
||||||
# opkg install luci-mod-rpc
|
# opkg install luci-mod-rpc
|
||||||
|
|
||||||
Configuration:
|
Configuration:
|
||||||
|
|
||||||
To use the Luci tracker you will need to add something like the following
|
To use the Luci tracker you will need to add something like the following
|
||||||
to your config/configuration.yaml
|
to your configuration.yaml file.
|
||||||
|
|
||||||
device_tracker:
|
device_tracker:
|
||||||
platform: luci
|
platform: luci
|
||||||
@ -66,7 +64,8 @@ def get_scanner(hass, config):
|
|||||||
|
|
||||||
# pylint: disable=too-many-instance-attributes
|
# pylint: disable=too-many-instance-attributes
|
||||||
class LuciDeviceScanner(object):
|
class LuciDeviceScanner(object):
|
||||||
""" This class queries a wireless router running OpenWrt firmware
|
"""
|
||||||
|
This class queries a wireless router running OpenWrt firmware
|
||||||
for connected devices. Adapted from Tomato scanner.
|
for connected devices. Adapted from Tomato scanner.
|
||||||
|
|
||||||
# opkg install luci-mod-rpc
|
# opkg install luci-mod-rpc
|
||||||
@ -95,8 +94,9 @@ class LuciDeviceScanner(object):
|
|||||||
self.success_init = self.token is not None
|
self.success_init = self.token is not None
|
||||||
|
|
||||||
def scan_devices(self):
|
def scan_devices(self):
|
||||||
""" Scans for new devices and return a
|
"""
|
||||||
list containing found device ids. """
|
Scans for new devices and return a list containing found device ids.
|
||||||
|
"""
|
||||||
|
|
||||||
self._update_info()
|
self._update_info()
|
||||||
|
|
||||||
@ -124,8 +124,10 @@ class LuciDeviceScanner(object):
|
|||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
""" Ensures the information from the Luci router is up to date.
|
"""
|
||||||
Returns boolean if scanning successful. """
|
Ensures the information from the Luci router is up to date.
|
||||||
|
Returns boolean if scanning successful.
|
||||||
|
"""
|
||||||
if not self.success_init:
|
if not self.success_init:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -179,6 +181,6 @@ def _req_json_rpc(url, method, *args, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def _get_token(host, username, password):
|
def _get_token(host, username, password):
|
||||||
""" Get authentication token for the given host+username+password """
|
""" Get authentication token for the given host+username+password. """
|
||||||
url = 'http://{}/cgi-bin/luci/rpc/auth'.format(host)
|
url = 'http://{}/cgi-bin/luci/rpc/auth'.format(host)
|
||||||
return _req_json_rpc(url, 'login', username, password)
|
return _req_json_rpc(url, 'login', username, password)
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.device_tracker.netgear
|
homeassistant.components.device_tracker.netgear
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Device tracker platform that supports scanning a Netgear router for device
|
Device tracker platform that supports scanning a Netgear router for device
|
||||||
presence.
|
presence.
|
||||||
|
|
||||||
Configuration:
|
Configuration:
|
||||||
|
|
||||||
To use the Netgear tracker you will need to add something like the following
|
To use the Netgear tracker you will need to add something like the following
|
||||||
to your config/configuration.yaml
|
to your configuration.yaml file.
|
||||||
|
|
||||||
device_tracker:
|
device_tracker:
|
||||||
platform: netgear
|
platform: netgear
|
||||||
@ -90,8 +89,9 @@ class NetgearDeviceScanner(object):
|
|||||||
_LOGGER.error("Failed to Login")
|
_LOGGER.error("Failed to Login")
|
||||||
|
|
||||||
def scan_devices(self):
|
def scan_devices(self):
|
||||||
""" Scans for new devices and return a
|
"""
|
||||||
list containing found device ids. """
|
Scans for new devices and return a list containing found device ids.
|
||||||
|
"""
|
||||||
self._update_info()
|
self._update_info()
|
||||||
|
|
||||||
return (device.mac for device in self.last_results)
|
return (device.mac for device in self.last_results)
|
||||||
@ -106,8 +106,10 @@ class NetgearDeviceScanner(object):
|
|||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
""" Retrieves latest information from the Netgear router.
|
"""
|
||||||
Returns boolean if scanning successful. """
|
Retrieves latest information from the Netgear router.
|
||||||
|
Returns boolean if scanning successful.
|
||||||
|
"""
|
||||||
if not self.success_init:
|
if not self.success_init:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.device_tracker.nmap
|
homeassistant.components.device_tracker.nmap
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Device tracker platform that supports scanning a network with nmap.
|
Device tracker platform that supports scanning a network with nmap.
|
||||||
|
|
||||||
Configuration:
|
Configuration:
|
||||||
|
|
||||||
To use the nmap tracker you will need to add something like the following
|
To use the nmap tracker you will need to add something like the following
|
||||||
to your config/configuration.yaml
|
to your configuration.yaml file.
|
||||||
|
|
||||||
device_tracker:
|
device_tracker:
|
||||||
platform: nmap_tracker
|
platform: nmap_tracker
|
||||||
@ -74,7 +73,7 @@ def _arp(ip_address):
|
|||||||
|
|
||||||
|
|
||||||
class NmapDeviceScanner(object):
|
class NmapDeviceScanner(object):
|
||||||
""" This class scans for devices using nmap """
|
""" This class scans for devices using nmap. """
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.last_results = []
|
self.last_results = []
|
||||||
@ -87,8 +86,9 @@ class NmapDeviceScanner(object):
|
|||||||
_LOGGER.info("nmap scanner initialized")
|
_LOGGER.info("nmap scanner initialized")
|
||||||
|
|
||||||
def scan_devices(self):
|
def scan_devices(self):
|
||||||
""" Scans for new devices and return a
|
"""
|
||||||
list containing found device ids. """
|
Scans for new devices and return a list containing found device ids.
|
||||||
|
"""
|
||||||
|
|
||||||
self._update_info()
|
self._update_info()
|
||||||
|
|
||||||
@ -107,8 +107,10 @@ class NmapDeviceScanner(object):
|
|||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
""" Scans the network for devices.
|
"""
|
||||||
Returns boolean if scanning successful. """
|
Scans the network for devices.
|
||||||
|
Returns boolean if scanning successful.
|
||||||
|
"""
|
||||||
_LOGGER.info("Scanning")
|
_LOGGER.info("Scanning")
|
||||||
|
|
||||||
from nmap import PortScanner, PortScannerError
|
from nmap import PortScanner, PortScannerError
|
||||||
|
@ -9,7 +9,7 @@ This device tracker needs telnet to be enabled on the router.
|
|||||||
Configuration:
|
Configuration:
|
||||||
|
|
||||||
To use the THOMSON tracker you will need to add something like the following
|
To use the THOMSON tracker you will need to add something like the following
|
||||||
to your config/configuration.yaml
|
to your configuration.yaml file.
|
||||||
|
|
||||||
device_tracker:
|
device_tracker:
|
||||||
platform: thomson
|
platform: thomson
|
||||||
@ -71,7 +71,8 @@ def get_scanner(hass, config):
|
|||||||
|
|
||||||
|
|
||||||
class ThomsonDeviceScanner(object):
|
class ThomsonDeviceScanner(object):
|
||||||
""" This class queries a router running THOMSON firmware
|
"""
|
||||||
|
This class queries a router running THOMSON firmware
|
||||||
for connected devices. Adapted from ASUSWRT scanner.
|
for connected devices. Adapted from ASUSWRT scanner.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -107,8 +108,10 @@ class ThomsonDeviceScanner(object):
|
|||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
""" Ensures the information from the THOMSON router is up to date.
|
"""
|
||||||
Returns boolean if scanning successful. """
|
Ensures the information from the THOMSON router is up to date.
|
||||||
|
Returns boolean if scanning successful.
|
||||||
|
"""
|
||||||
if not self.success_init:
|
if not self.success_init:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -125,7 +128,7 @@ class ThomsonDeviceScanner(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def get_thomson_data(self):
|
def get_thomson_data(self):
|
||||||
""" Retrieve data from THOMSON and return parsed result. """
|
""" Retrieve data from THOMSON and return parsed result. """
|
||||||
try:
|
try:
|
||||||
telnet = telnetlib.Telnet(self.host)
|
telnet = telnetlib.Telnet(self.host)
|
||||||
telnet.read_until(b'Username : ')
|
telnet.read_until(b'Username : ')
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.device_tracker.tomato
|
homeassistant.components.device_tracker.tomato
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Device tracker platform that supports scanning a Tomato router for device
|
Device tracker platform that supports scanning a Tomato router for device
|
||||||
presence.
|
presence.
|
||||||
|
|
||||||
Configuration:
|
Configuration:
|
||||||
|
|
||||||
To use the Tomato tracker you will need to add something like the following
|
To use the Tomato tracker you will need to add something like the following
|
||||||
to your config/configuration.yaml
|
to your configuration.yaml file.
|
||||||
|
|
||||||
device_tracker:
|
device_tracker:
|
||||||
platform: tomato
|
platform: tomato
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.device_tracker.tplink
|
homeassistant.components.device_tracker.tplink
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Device tracker platform that supports scanning a TP-Link router for device
|
Device tracker platform that supports scanning a TP-Link router for device
|
||||||
presence.
|
presence.
|
||||||
|
|
||||||
Configuration:
|
Configuration:
|
||||||
|
|
||||||
To use the TP-Link tracker you will need to add something like the following
|
To use the TP-Link tracker you will need to add something like the following
|
||||||
to your config/configuration.yaml
|
to your configuration.yaml file.
|
||||||
|
|
||||||
device_tracker:
|
device_tracker:
|
||||||
platform: tplink
|
platform: tplink
|
||||||
@ -29,7 +28,6 @@ The username of an user with administrative privileges, usually 'admin'.
|
|||||||
password
|
password
|
||||||
*Required
|
*Required
|
||||||
The password for your given admin account.
|
The password for your given admin account.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import base64
|
import base64
|
||||||
import logging
|
import logging
|
||||||
@ -65,7 +63,8 @@ def get_scanner(hass, config):
|
|||||||
|
|
||||||
|
|
||||||
class TplinkDeviceScanner(object):
|
class TplinkDeviceScanner(object):
|
||||||
""" This class queries a wireless router running TP-Link firmware
|
"""
|
||||||
|
This class queries a wireless router running TP-Link firmware
|
||||||
for connected devices.
|
for connected devices.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -85,8 +84,9 @@ class TplinkDeviceScanner(object):
|
|||||||
self.success_init = self._update_info()
|
self.success_init = self._update_info()
|
||||||
|
|
||||||
def scan_devices(self):
|
def scan_devices(self):
|
||||||
""" Scans for new devices and return a
|
"""
|
||||||
list containing found device ids. """
|
Scans for new devices and return a list containing found device ids.
|
||||||
|
"""
|
||||||
|
|
||||||
self._update_info()
|
self._update_info()
|
||||||
|
|
||||||
@ -94,15 +94,18 @@ class TplinkDeviceScanner(object):
|
|||||||
|
|
||||||
# pylint: disable=no-self-use
|
# pylint: disable=no-self-use
|
||||||
def get_device_name(self, device):
|
def get_device_name(self, device):
|
||||||
""" The TP-Link firmware doesn't save the name of the wireless
|
"""
|
||||||
device. """
|
The TP-Link firmware doesn't save the name of the wireless device.
|
||||||
|
"""
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
""" Ensures the information from the TP-Link router is up to date.
|
"""
|
||||||
Returns boolean if scanning successful. """
|
Ensures the information from the TP-Link router is up to date.
|
||||||
|
Returns boolean if scanning successful.
|
||||||
|
"""
|
||||||
|
|
||||||
with self.lock:
|
with self.lock:
|
||||||
_LOGGER.info("Loading wireless clients...")
|
_LOGGER.info("Loading wireless clients...")
|
||||||
@ -122,28 +125,33 @@ class TplinkDeviceScanner(object):
|
|||||||
|
|
||||||
|
|
||||||
class Tplink2DeviceScanner(TplinkDeviceScanner):
|
class Tplink2DeviceScanner(TplinkDeviceScanner):
|
||||||
""" This class queries a wireless router running newer version of TP-Link
|
"""
|
||||||
|
This class queries a wireless router running newer version of TP-Link
|
||||||
firmware for connected devices.
|
firmware for connected devices.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def scan_devices(self):
|
def scan_devices(self):
|
||||||
""" Scans for new devices and return a
|
"""
|
||||||
list containing found device ids. """
|
Scans for new devices and return a list containing found device ids.
|
||||||
|
"""
|
||||||
|
|
||||||
self._update_info()
|
self._update_info()
|
||||||
return self.last_results.keys()
|
return self.last_results.keys()
|
||||||
|
|
||||||
# pylint: disable=no-self-use
|
# pylint: disable=no-self-use
|
||||||
def get_device_name(self, device):
|
def get_device_name(self, device):
|
||||||
""" The TP-Link firmware doesn't save the name of the wireless
|
"""
|
||||||
device. """
|
The TP-Link firmware doesn't save the name of the wireless device.
|
||||||
|
"""
|
||||||
|
|
||||||
return self.last_results.get(device)
|
return self.last_results.get(device)
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
""" Ensures the information from the TP-Link router is up to date.
|
"""
|
||||||
Returns boolean if scanning successful. """
|
Ensures the information from the TP-Link router is up to date.
|
||||||
|
Returns boolean if scanning successful.
|
||||||
|
"""
|
||||||
|
|
||||||
with self.lock:
|
with self.lock:
|
||||||
_LOGGER.info("Loading wireless clients...")
|
_LOGGER.info("Loading wireless clients...")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user