Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

device_tracker.asuswrt: Ignore unreachable ip neigh entries #12201

Merged
merged 1 commit into from
Feb 12, 2018

Conversation

trisk
Copy link
Contributor

@trisk trisk commented Feb 5, 2018

Description:

device_tracker.asuswrt should consider entries in ip neigh output with STALE or FAILED status to be unreachable, so it can detect when devices with link-local IPv6 addresses are removed.

Related issue (if applicable): fixes #12198

Checklist:

  • The code change is tested and works locally.

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass

@@ -212,6 +212,10 @@ def _get_neigh(self, cur_devices):
result = _parse_lines(lines, _IP_NEIGH_REGEX)
devices = {}
for device in result:
status = device['status']
if status is not None:
if state.upper() == 'STALE' or status.upper() == 'FAILED':

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined name 'state'

@trisk trisk force-pushed the asuswrt_ignore_unreachable_neigh branch from ead3b35 to ca60c0a Compare February 5, 2018 18:29
@trisk trisk force-pushed the asuswrt_ignore_unreachable_neigh branch from ca60c0a to 2a2e08b Compare February 5, 2018 19:24
@trisk trisk force-pushed the asuswrt_ignore_unreachable_neigh branch from 2a2e08b to d353432 Compare February 5, 2018 21:10
@trisk trisk force-pushed the asuswrt_ignore_unreachable_neigh branch from d353432 to b812086 Compare February 5, 2018 22:31
@@ -118,11 +119,10 @@ def __init__(self, config):
if self.protocol == 'ssh':
self.connection = SshConnection(
self.host, self.port, self.username, self.password,
self.ssh_key, self.mode == 'ap')
self.ssh_key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ap is still used, look at get_asuswrt_data() please revert this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kennedyshead That method uses only the mode attribute of AsusWrtDeviceScanner. The ap parameter of SshConnection (and TelnetConnection) is only used to set the attribute SshConnection._ap. This is not needed and doesn't make sense as a property of the connection anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried running i AP mode with this pull-request?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I'd say that this change should be done in a separate PR anyway

else:
self.connection = TelnetConnection(
self.host, self.port, self.username, self.password,
self.mode == 'ap')
self.host, self.port, self.username, self.password)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -253,7 +256,7 @@ def disconnect(self):
class SshConnection(_Connection):
"""Maintains an SSH connection to an ASUS-WRT router."""

def __init__(self, host, port, username, password, ssh_key, ap):
def __init__(self, host, port, username, password, ssh_key):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ap should not be removed

@@ -323,7 +325,7 @@ def disconnect(self): \
class TelnetConnection(_Connection):
"""Maintains a Telnet connection to an ASUS-WRT router."""

def __init__(self, host, port, username, password, ap):
def __init__(self, host, port, username, password):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ap should not be removed

@@ -332,7 +334,6 @@ def __init__(self, host, port, username, password, ap):
self._port = port
self._username = username
self._password = password
self._ap = ap
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ap should not be removed

@kennedyshead
Copy link
Contributor

This will also solve #12123

@trisk
Copy link
Contributor Author

trisk commented Feb 9, 2018

@kennedyshead I've moved the other change to a separate PR.

@kennedyshead
Copy link
Contributor

Ready to merge 🐬

@balloob balloob merged commit ebe4418 into home-assistant:dev Feb 12, 2018
@balloob balloob mentioned this pull request Feb 22, 2018
@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

asuswrt should ignore unreachable ip neigh entries
5 participants