Skip to content

Added support for TP-Link Archer C50 V3 BR Version#13525

Closed
MelkyFB-zz wants to merge 5 commits intohome-assistant:devfrom
MelkyFB-zz:dev
Closed

Added support for TP-Link Archer C50 V3 BR Version#13525
MelkyFB-zz wants to merge 5 commits intohome-assistant:devfrom
MelkyFB-zz:dev

Conversation

@MelkyFB-zz
Copy link
Copy Markdown

Description:

Pull request in home-assistant.github.io
The tplink.py was not working for this model of router, I tested with my Brazilian Version, maybe it works with Europe Version or even with other other Hardware versions, not only v3.

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox.

referer = 'http://{}/'.format(self.host)
cookie = 'Authorization=Basic {}'.format(self.credentials)

payload = '[LAN_HOST_ENTRY#0,0,0,0,0,0#0,0,0,0,0,0]0,4\r\nleaseTimeRemaining\r\nMACAddress\r\nhostName\r\nIPAddress\r\n'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line too long (128 > 79 characters)


mac_results = []

#CHECK DHCP CLIENT LIST
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

block comment should start with '# '

# Create the authorization cookie.
cookie = 'Authorization=Basic {}'.format(self.credentials)

response = requests.get(url, headers={COOKIE: cookie})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'response' is assigned to but never used

_LOGGER.info("Retrieving auth tokens...")
url = 'http://{}/'.format(self.host)

credentials = '{}:{}'.format(self.username, self.password).encode('utf')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line too long (80 > 79 characters)

self.token = ''
#had to rewrite due c50 responds with colon mac instead of dash
self.parse_macs_c50 = re.compile('[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:' +
'[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

self.credentials = ''
self.token = ''
#had to rewrite due c50 responds with colon mac instead of dash
self.parse_macs_c50 = re.compile('[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:' +
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line too long (81 > 79 characters)

"""Initialize the scanner."""
self.credentials = ''
self.token = ''
#had to rewrite due c50 responds with colon mac instead of dash
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

block comment should start with '# '

self.stok = ''
self.sysauth = ''

class TplinkArcherC50DeviceScanner(TplinkDeviceScanner):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

@homeassistant
Copy link
Copy Markdown
Contributor

Hi @melkyfb,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

cookie = 'Authorization=Basic {}'.format(self.credentials)

payload = '[LAN_HOST_ENTRY#0,0,0,0,0,0#0,0,0,0,0,0]0,4\r\n' +
'leaseTimeRemaining\r\nMACAddress\r\nhostName\r\nIPAddress\r\n'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

indentation is not a multiple of four
unexpected indentation
line too long (81 > 79 characters)

url = 'http://{}/'.format(self.host)

credentials = '{}:{}'.format(self.username, \
self.password).encode('utf')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

_LOGGER.info("Retrieving auth tokens...")
url = 'http://{}/'.format(self.host)

credentials = '{}:{}'.format(self.username, \
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the backslash is redundant between brackets

self.token = ''
# I had to rewrite due c50 responds with colon mac instead of dash
self.parse_macs_c50 =
re.compile('[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:' +
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unexpected indentation

self.credentials = ''
self.token = ''
# I had to rewrite due c50 responds with colon mac instead of dash
self.parse_macs_c50 =
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

trailing whitespace
SyntaxError: invalid syntax


payload = '[LAN_HOST_ENTRY#0,0,0,0,0,0#0,0,0,0,0,0]0,4\r\n' + \
'leaseTimeRemaining\r\nMACAddress\r\nhostName\r\nIPAddress\r\n'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

blank line contains whitespace

self.credentials = base64.b64encode(credentials).decode('utf')

# Create the authorization cookie.
cookie = 'Authorization=Basic {}'.format(self.credentials)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'cookie' is assigned to but never used

def _get_auth_tokens(self):
"""Retrieve auth tokens from the router."""
_LOGGER.info("Retrieving auth tokens...")
url = 'http://{}/'.format(self.host)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'url' is assigned to but never used

@fabaff fabaff changed the title Added suport for TP-Link Archer C50 V3 BR Version to device_tracker Added support for TP-Link Archer C50 V3 BR Version Mar 29, 2018
# CHECK DHCP CLIENT LIST
url = 'http://{}/cgi?5'.format(self.host)
referer = 'http://{}/'.format(self.host)
cookie = 'Authorization=Basic {}'.format(self.credentials)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The credentials are always empty.

def __init__(self, config):
"""Initialize the scanner."""
self.credentials = ''
self.token = ''
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The token is unused.

self.credentials = ''
self.token = ''
# I had to rewrite due c50 responds with colon mac instead of dash
self.parse_macs_c50 = re.compile('[0-9A-F]{2}:[0-9A-F]{2}:' +
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is fine. Please rewrite or remove the comment. You could overwrite self.parse_macs here. A new variable isn't needed to my mind.

@syssi
Copy link
Copy Markdown
Member

syssi commented Apr 6, 2018

@melkyfb Before you invest more time: Please checkout this PR #11827. It looks like you should use pytplinkrouter here and the component needs some love at all!

@balloob
Copy link
Copy Markdown
Member

balloob commented May 2, 2018

Please provide a PR to use pytplinkrouter. We should not add new classes to this file.

@balloob balloob closed this May 2, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Sep 5, 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.

6 participants