trying to fix more warnings...

This commit is contained in:
Nolan Gilley 2015-08-18 16:50:40 -04:00
parent d2f01174e7
commit c471e39fa0

View File

@ -1,15 +1,15 @@
""" """
homeassistant.components.device_tracker.actiontec homeassistant.components.device_tracker.actiontec
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Device tracker platform that supports scanning a Actiontec MI424WR (Verizon FIOS) router for device Device tracker platform that supports scanning an Actiontec MI424WR
presence. (Verizon FIOS) router for device presence.
This device tracker needs telnet to be enabled on the router. 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 following To use the Actiontec tracker you will need to add something like the
to your config/configuration.yaml following to your config/configuration.yaml
device_tracker: device_tracker:
platform: actiontec platform: actiontec
@ -49,8 +49,6 @@ _LOGGER = logging.getLogger(__name__)
_LEASES_REGEX = re.compile(r'(?P<mac>([0-9a-f]{2}[:-]){5}([0-9a-f]{2}))') _LEASES_REGEX = re.compile(r'(?P<mac>([0-9a-f]{2}[:-]){5}([0-9a-f]{2}))')
# 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 a DD-WRT scanner. """
@ -63,7 +61,6 @@ def get_scanner(hass, config):
return scanner if scanner.success_init else None return scanner if scanner.success_init else None
class ActiontecDeviceScanner(object): class ActiontecDeviceScanner(object):
""" This class queries a an actiontec router """ This class queries a an actiontec router
for connected devices. Adapted from DD-WRT scanner. for connected devices. Adapted from DD-WRT scanner.
@ -122,11 +119,11 @@ class ActiontecDeviceScanner(object):
telnet.write((self.username + '\n').encode('ascii')) telnet.write((self.username + '\n').encode('ascii'))
telnet.read_until(b'Password: ') telnet.read_until(b'Password: ')
telnet.write((self.password + '\n').encode('ascii')) telnet.write((self.password + '\n').encode('ascii'))
prompt_string = telnet.read_until(b'Wireless Broadband Router> ').split(b'\n')[-1] prompt = telnet.read_until(b'Wireless Broadband Router> ').split(b'\n')[-1]
telnet.write('firewall mac_cache_dump\n'.encode('ascii')) telnet.write('firewall mac_cache_dump\n'.encode('ascii'))
telnet.write('\n'.encode('ascii')) telnet.write('\n'.encode('ascii'))
skip_line = telnet.read_until(prompt_string).split(b'\n')[1:-1] _=telnet.read_until(prompt).split(b'\n')[1:-1]
leases_result = telnet.read_until(prompt_string).split(b'\n')[1:-1] leases_result = telnet.read_until(prompt).split(b'\n')[1:-1]
telnet.write('exit\n'.encode('ascii')) telnet.write('exit\n'.encode('ascii'))
except EOFError: except EOFError:
_LOGGER.exception("Unexpected response from router") _LOGGER.exception("Unexpected response from router")
@ -143,4 +140,3 @@ class ActiontecDeviceScanner(object):
devices.append(match.group('mac')) devices.append(match.group('mac'))
return devices return devices