home-assistant-tplink_router icon indicating copy to clipboard operation
home-assistant-tplink_router copied to clipboard

device request: Archer C1200

Open DiggiD opened this issue 4 years ago • 17 comments

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

DiggiD avatar Apr 27 '20 07:04 DiggiD

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

ericpignet avatar Apr 28 '20 11:04 ericpignet

@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

GuyKh avatar May 06 '20 12:05 GuyKh

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

DiggiD avatar May 11 '20 08:05 DiggiD

@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.

GuyKh avatar May 11 '20 09:05 GuyKh

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'))

DiggiD avatar May 11 '20 13:05 DiggiD

@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>"

GuyKh avatar May 11 '20 13:05 GuyKh

thanks for the pointer.. missed that completely.

script now exits with

FAILED!

DiggiD avatar May 11 '20 13:05 DiggiD

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

GuyKh avatar May 11 '20 14:05 GuyKh

Wait You can also try this:

Response Status: 404

DiggiD avatar May 11 '20 17:05 DiggiD

Wait You can also try this:

Response Status: 404

Sure you set the right settings in line 74?

GuyKh avatar May 11 '20 18:05 GuyKh

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

DiggiD avatar May 11 '20 18:05 DiggiD

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

GuyKh avatar May 12 '20 04:05 GuyKh

thanks for trying:)

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

DiggiD avatar May 12 '20 09:05 DiggiD

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

kwirk avatar Nov 07 '20 19:11 kwirk

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 👍

ChalidNL avatar Nov 23 '20 20:11 ChalidNL

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.

kwirk avatar Nov 23 '20 21:11 kwirk

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

AlexandrErohin avatar Feb 13 '24 08:02 AlexandrErohin