ericpignet / home-assistant-tplink_router

TPLink router device tracker for Home Assistant
41 stars 28 forks source link

device request: Archer C1200 #3

Open DiggiD opened 4 years ago

DiggiD commented 4 years ago

archer c1200 v2.0

no username field for router home page, only password field

AP didn't respond with JSON. Check if credentials are correct Couldn't fetch auth tokens! Response was: {"errorcode":"login failed","success":false,"data":{"failureCount":1,"errorcode":"-5002","attemptsAllowed":9}} Router didn't respond with JSON. Check if credentials are correct. Error 404 from router

ericpignet commented 4 years ago

Hi, I've only repackaged the old TP-Link router integration in HACS, so that people can keep using it even though it was officially removed from Home Assistant. I've only implemented support for the N600, which is my own router. I don't have a C1200 so I can't troubleshoot and fix by myself.

If you are able to find out how authentication works for your router, I'm happy to integrate in the code.

Eric

GuyKh commented 4 years ago

@DiggiD Try this:

Save this file (https://gist.github.com/GuyKh/39cd5a2ed74c5303f3217a503cde4048) with .py extension Modify the Username/Password settings in the file Then run it with python3 file.py If it succeed - #4 should solve the issue

DiggiD commented 4 years ago

thanks all

@GuyKh

changed 'conf_password' to my router password since page does not have username field. got many errors, can't make sense of it but most notably the logs keep mentioning host=192.168.1.1 even after i tried changing 'conf_host' to 192.168.0.1 the address of my router.

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection raise err File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection sock.connect(sa) TimeoutError: [Errno 110] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen chunked=chunked, File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 392, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/local/lib/python3.7/http/client.py", line 1252, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/lib/python3.7/http/client.py", line 1298, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.7/http/client.py", line 1247, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.7/http/client.py", line 1026, in _send_output self.send(msg) File "/usr/local/lib/python3.7/http/client.py", line 966, in send self.connect() File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 187, in connect conn = self._new_conn() File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 172, in _new_conn self, "Failed to establish a new connection: %s" % e urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x76382f70>: Failed to establish a new connection: [Errno 110] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send timeout=timeout File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 725, in urlopen method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 439, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.1.1', port=80): Max retries exceeded with url: /cgi/getParm (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x76382f70>: Failed to establish a new connection: [Errno 110] Operation timed out'))

also tried changing 'conf_username' to admin to check

GuyKh commented 4 years ago

@DiggiD So yeah - if you're using only a password then the username must be admin.

Make sure you use the right host (192.168.1.1 in the example) for your case - perhaps it's 192.168.0.1 Try these settings and paste the entire run log (right from the python command).

Also - please specify what is your IP you're calling from. In the log you pasted - indeed it shows that 192.168.1.1 is not where the router is located

Again - I don't promise it'll work - it just uses the new VR600 admin interface.

DiggiD commented 4 years ago

conf_host = '192.168.0.1' conf_password = 'mypassword' conf_username = 'admin'

I'm calling this from docker hassio install running on my pi on the same subnet

error:

bash-5.0# python3 tp-link.py Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection raise err File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection sock.connect(sa) TimeoutError: [Errno 110] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen chunked=chunked, File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 392, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/local/lib/python3.7/http/client.py", line 1252, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/lib/python3.7/http/client.py", line 1298, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.7/http/client.py", line 1247, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.7/http/client.py", line 1026, in _send_output self.send(msg) File "/usr/local/lib/python3.7/http/client.py", line 966, in send self.connect() File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 187, in connect conn = self._new_conn() File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 172, in _new_conn self, "Failed to establish a new connection: %s" % e urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7632cf10>: Failed to establish a new connection: [Errno 110] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send timeout=timeout File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 725, in urlopen method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 439, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.1.1', port=80): Max retries exceeded with url: /cgi/getParm (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7632cf10>: Failed to establish a new connection: [Errno 110] Operation timed out'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "tp-link.py", line 307, in main() File "tp-link.py", line 298, in main scanner = Tplink6DeviceScanner(config) File "tp-link.py", line 102, in init super(Tplink6DeviceScanner, self).init(config) File "tp-link.py", line 53, in init self.success_init = self._update_info() File "tp-link.py", line 264, in _update_info gotToken = self._get_auth_tokens() File "tp-link.py", line 199, in _get_auth_tokens pubkey = self._get_pub_key() File "tp-link.py", line 118, in _get_pub_key response = requests.post(url, headers={'REFERER': referer}) File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 119, in post return request('post', url, data=data, json=json, kwargs) File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 61, in request return session.request(method=method, url=url, kwargs) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 530, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 643, in send r = adapter.send(request, kwargs) File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.1', port=80): Max retries exceeded with url: /cgi/getParm (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7632cf10>: Failed to establish a new connection: [Errno 110] Operation timed out'))

GuyKh commented 4 years ago

@DiggiD It still feels that it tries to reach 192.168.1.1

Again - make sure that in the .py file - on line #295 you get these lines:

    CONF_HOST: "192.168.0.1",
    CONF_USERNAME: "admin",
    CONF_PASSWORD: "<your pass>"
DiggiD commented 4 years ago

thanks for the pointer.. missed that completely.

script now exits with

FAILED!

GuyKh commented 4 years ago

So - sorry to disappoint - my solution will not work (out-of-the-box) for you.

I need to further investigate this - and this is VERY HARD when I don't have the router. Sorry :(


Wait You can also try this: https://gist.github.com/GuyKh/545ebfe1e95f48a8c623cf959cebb82b

Modify lines 74-76. This is a more detailed script

DiggiD commented 4 years ago

Wait You can also try this:

Response Status: 404

GuyKh commented 4 years ago

Wait You can also try this:

Response Status: 404

Sure you set the right settings in line 74?

DiggiD commented 4 years ago

yes, i set it to my router url '192.168.0.1'

GuyKh commented 4 years ago

@DiggiD so it seems that indeed this method is not suitable for your router. Sorry to be the bearer of bad news

DiggiD commented 4 years ago

thanks for trying:)

if only i knew how to get you the info that you need

kwirk commented 3 years ago

I have the same router and was able to get this to work, but had to get the encrypted password, per instructions in README.

ChalidNL commented 3 years ago

I have the same router and was able to get this to work, but had to get the encrypted password, per instructions in README.

As you managed to make it work I would like to ask you if can share some details. As for me it is not working

Did you use admin as username or did you left it blanc like ''?

Could you share you config ?

How is your ip setting? My router is 192.168.1.3 and also 192.168.2.1 my home assistant is like 192.168.2.101

Some specific steps to do? I.e. modem and router reset ? Or anything else please share so we can also benefit 👍

kwirk commented 3 years ago

I have the same router and was able to get this to work, but had to get the encrypted password, per instructions in README.

As you managed to make it work I would like to ask you if can share some details. As for me it is not working

Did you use admin as username or did you left it blanc like ''?

Could you share you config ?

How is your ip setting? My router is 192.168.1.3 and also 192.168.2.1 my home assistant is like 192.168.2.101

Some specific steps to do? I.e. modem and router reset ? Or anything else please share so we can also benefit +1

My config:

device_tracker:
  - platform: tplink_router
    host: 192.168.0.1
    username: admin
    password: !secret tplink_router

My home assistant is on 192.168.0.0/24 subnet. I didn't do anything specifically to get it working, once I realised I needed the encrypted password.

One thing to watch out for is you can't be logged on to the router multiple times, so keep sure to log off from other devices.

AlexandrErohin commented 8 months ago

If you are still looking for a Home Assistant Integration for Archer C1200 v2.0 - I have one https://github.com/AlexandrErohin/home-assistant-tplink-router