AlexandrErohin / home-assistant-tplink-router

Home Assistant component for TP-Link router administration with sensors, button reboot, switches and device tracking.
https://community.home-assistant.io/t/custom-component-tp-link-router-integration
MIT License
137 stars 16 forks source link

Archer A7 v5 #40

Closed speedycars closed 7 months ago

speedycars commented 8 months ago

Describe the bug I'm able to add it via https address without SSL verify option. Once it's added it fails to start. If I try with http address, it says: TplinkRouter - C6 - Cannot authorize! Error - ord() expected a character, but string of length 0 found; Response - {'data': ''}

Logs 2024-03-18 19:55:36.867 ERROR (SyncWorker_4) [custom_components.tplink_router] TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/status?form=all&operation=read - Response FC7O+qbVyQtPaPs9/eech6DCe+GfM9WWUORtTe2szMgGUcXEEbj9mSk328QKvhLhmj27x/vIYriYDZLiIMtuwZAr4yRTkMQ2PuCjozhV8zmix4QCcZ4hyVHuMP6beV5Fj4+KdJWFqHcnGjP7SQ55HYpLOWRDebgGz0J9l//V624ZDb+WVM2iO2N4tXgNUaLToTaBsJ4f7QNbB2u3sbUonw== 2024-03-18 19:55:36.869 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry https://192.168.10.1 for tplink_router Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tplink_router/__init__.py", line 60, in async_setup_entry firmware, status = await hass.async_add_executor_job(TPLinkRouterCoordinator.request, client, callback) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tplink_router/coordinator.py", line 56, in request data = callback() ^^^^^^^^^^ File "/config/custom_components/tplink_router/__init__.py", line 56, in callback stat = client.get_status() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tplinkrouterc6u/client.py", line 108, in get_status data = self.request('admin/status?form=all&operation=read') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tplinkrouterc6u/client.py", line 237, in request raise ClientError(error) tplinkrouterc6u.exception.ClientError: TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/status?form=all&operation=read - Response FC7O+qbVyQtPaPs9/eech6DCe+GfM9WWUORtTe2szMgGUcXEEbj9mSk328QKvhLhmj27x/vIYriYDZLiIMtuwZAr4yRTkMQ2PuCjozhV8zmix4QCcZ4hyVHuMP6beV5Fj4+KdJWFqHcnGjP7SQ55HYpLOWRDebgGz0J9l//V624ZDb+WVM2iO2N4tXgNUaLToTaBsJ4f7QNbB2u3sbUonw== 2024-03-18 19:55:43.359 ERROR (SyncWorker_2) [custom_components.tplink_router] TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/status?form=all&operation=read - Response daatyFA37sDF+GmXF3pHtjeOqJ1oXsOW368IAujbI5x3dsNjTg5cJTrsFQYAGexaZ7+urAM8b5sc/fOv0BLo9LIryRACAUHXjoEHWZbDRWozFSejlm2y/ozIkcANIfSFLbjvPMMMaFwsQ6AWAKNLxIvSpHslltCSyHtE8/zs9HrX4ToBVLvfo/NzSaJnfYd0D82oJneotdBh2zDVi9VBDg== 2024-03-18 19:55:43.360 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry https://192.168.10.1 for tplink_router Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tplink_router/__init__.py", line 60, in async_setup_entry firmware, status = await hass.async_add_executor_job(TPLinkRouterCoordinator.request, client, callback) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tplink_router/coordinator.py", line 56, in request data = callback() ^^^^^^^^^^ File "/config/custom_components/tplink_router/__init__.py", line 56, in callback stat = client.get_status() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tplinkrouterc6u/client.py", line 108, in get_status data = self.request('admin/status?form=all&operation=read') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tplinkrouterc6u/client.py", line 237, in request raise ClientError(error) tplinkrouterc6u.exception.ClientError: TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/status?form=all&operation=read - Response daatyFA37sDF+GmXF3pHtjeOqJ1oXsOW368IAujbI5x3dsNjTg5cJTrsFQYAGexaZ7+urAM8b5sc/fOv0BLo9LIryRACAUHXjoEHWZbDRWozFSejlm2y/ozIkcANIfSFLbjvPMMMaFwsQ6AWAKNLxIvSpHslltCSyHtE8/zs9HrX4ToBVLvfo/NzSaJnfYd0D82oJneotdBh2zDVi9VBDg== 2024-03-18 19:55:46.164 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Firefox 123.0 on Windows 10 TypeError: this.contentElement is null renderHeading (src/components/ha-dialog.ts:53:4) apply (src/scoped-custom-element-registry.js:262:44) mainWindow.history.pushState (src/dialogs/make-dialog-manager.ts:129:7) 2024-03-18 19:55:50.035 ERROR (SyncWorker_14) [custom_components.tplink_router.config_flow] TplinkRouter - C6 - Cannot authorize! Error - ord() expected a character, but string of length 0 found; Response - {'data': ''} 2024-03-18 19:55:50.035 ERROR (MainThread) [custom_components.tplink_router.config_flow] TplinkRouter Integration Exception - TplinkRouter - C6 - Cannot authorize! Error - ord() expected a character, but string of length 0 found; Response - {'data': ''}

Additional Information (please complete the following information)

AlexandrErohin commented 8 months ago

Hi Archer A7 V5 was tested and it works with version 1.10.0 https://github.com/AlexandrErohin/home-assistant-tplink-router/issues/25

Do you use local password or from TP-Link Tether?

speedycars commented 8 months ago

Using local password only.

AlexandrErohin commented 8 months ago

@speedycars Try to re-add with http address Response - {'data': ''} - Means that router reply with wrong response. I this response once and it was solved by re-adding

speedycars commented 8 months ago

Hi @AlexandrErohin, tried all options before opening the issue - only the https option is adding the device, but then no devices or entities are shown for it in HA. One thing to note here is that the HA server is connected via OpenVPN connection to the A7's OpenVPN server. The HA server is the OpenVPN client. Buuut over the same OpenVPN connection to the OpenVPN server of A7, I can open the administrative GUI with a browser from a remote client without any issues, hence this shouldn't be the problem. Captured some pcaps - with http option connection is redirected to https, and the device is not added; with the https connection seems good up until HA server is sending a RST packet, unfortunately data there is encrypted so I cannot see what exactly is happening.

speedycars commented 8 months ago

From your code I guess this part is failing due to bad callback data from the router as you already said: def callback():

        firm = client.get_firmware()
        stat = client.get_status()

        return firm, stat

    firmware, status = await hass.async_add_executor_job(TPLinkRouterCoordinator.request, client, callback)

How to capture this bad data to check if it's really bad?

AlexandrErohin commented 8 months ago

Your router responses {'data': ''} Is there any other devices login in router? Like mobile app

speedycars commented 8 months ago

I have the TP-Link Android app Tether on my phone installed, this router there is marked as "Cloud Device". Rarely opening this app to be honest. You think it is interfering?

I got a C7 in my local LAN also added in the Tether app, but it's all working good.

speedycars commented 8 months ago

Tried again and got a different output in the logs: 2024-03-21 11:35:10.757 ERROR (SyncWorker_3) [custom_components.tplink_router] TplinkRouter - TPLinkDecoClient - Unknown error for pwd! Error - 'result'; Response - {"success":true,"data":{"password":["A7646A76B711BD9C86BBA6573A11922CE3BF54615C2AAFD10CBEF6D0DEC8A53F20E7C6A490DD9E69E1DFF3E1436A8B437BABD89CC9F8F117EB8EED725495FA1A2A98AC1F9323E788B73970238181C84CA958712F39D846096017426E86FAF21FDEA72B94977682567E47487C29684F2C35501D9916DD0745EE69DEE2EE0250A3","010001"],"mode":"router","username":""}} 2024-03-21 11:35:12.332 ERROR (SyncWorker_9) [custom_components.tplink_router] TplinkRouter - TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/status?form=all&operation=read - Response joqmmulSleJ6gT4Wc99dezMQTr9wq2ODbc9upaVZMSyzDPK1jQa50ZLZ/qu89e4BENQVPB8jtTe6USMxojmqB8V28gLoBmnVl1BCpRzLFq1mAphGls049nu9fQeVSekPS+18iBAf1P3EyZq2IuMps8/JE3e0x9JC38R5Y9V7BPW1xGGNZdTNZyOaDEYBge71GU48LwEH+IwLeOdING20AQ== 2024-03-21 11:35:12.332 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry https://192.168.10.1 for tplink_router Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tplink_router/init.py", line 47, in async_setup_entry firmware, status = await hass.async_add_executor_job(TPLinkRouterCoordinator.request, client, callback) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tplink_router/coordinator.py", line 56, in request data = callback() ^^^^^^^^^^ File "/config/custom_components/tplink_router/init.py", line 43, in callback stat = client.get_status() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tplinkrouterc6u/client.py", line 307, in get_status data = self.request('admin/status?form=all&operation=read', 'operation=read') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tplinkrouterc6u/client.py", line 109, in request raise ClientError(error) tplinkrouterc6u.exception.ClientError: TplinkRouter - TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/status?form=all&operation=read - Response joqmmulSleJ6gT4Wc99dezMQTr9wq2ODbc9upaVZMSyzDPK1jQa50ZLZ/qu89e4BENQVPB8jtTe6USMxojmqB8V28gLoBmnVl1BCpRzLFq1mAphGls049nu9fQeVSekPS+18iBAf1P3EyZq2IuMps8/JE3e0x9JC38R5Y9V7BPW1xGGNZdTNZyOaDEYBge71GU48LwEH+IwLeOdING20AQ==

AlexandrErohin commented 8 months ago

Try to logout completely from Tether and try again to add your router

speedycars commented 8 months ago

Logged out of Tether app.

First tried with http, then with https:

2024-03-21 12:29:36.944 ERROR (SyncWorker_19) [custom_components.tplink_router.config_flow] TplinkRouter - TPLinkDecoClient - Unknown error for pwd! Error - 'result'; Response - {"success":true,"data":{"password":["A7646A76B711BD9C86BBA6573A11922CE3BF54615C2AAFD10CBEF6D0DEC8A53F20E7C6A490DD9E69E1DFF3E1436A8B437BABD89CC9F8F117EB8EED725495FA1A2A98AC1F9323E788B73970238181C84CA958712F39D846096017426E86FAF21FDEA72B94977682567E47487C29684F2C35501D9916DD0745EE69DEE2EE0250A3","010001"],"mode":"router","username":""}}
2024-03-21 12:29:38.322 ERROR (SyncWorker_18) [custom_components.tplink_router] TplinkRouter - TPLinkDecoClient - Unknown error for pwd! Error - 'result'; Response - {"success":true,"data":{"password":["A7646A76B711BD9C86BBA6573A11922CE3BF54615C2AAFD10CBEF6D0DEC8A53F20E7C6A490DD9E69E1DFF3E1436A8B437BABD89CC9F8F117EB8EED725495FA1A2A98AC1F9323E788B73970238181C84CA958712F39D846096017426E86FAF21FDEA72B94977682567E47487C29684F2C35501D9916DD0745EE69DEE2EE0250A3","010001"],"mode":"router","username":""}}
2024-03-21 12:29:39.897 ERROR (SyncWorker_5) [custom_components.tplink_router] TplinkRouter - TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/status?form=all&operation=read - Response joqmmulSleJ6gT4Wc99dezMQTr9wq2ODbc9upaVZMSyzDPK1jQa50ZLZ/qu89e4BENQVPB8jtTe6USMxojmqB8V28gLoBmnVl1BCpRzLFq1mAphGls049nu9fQeVSekPS+18iBAf1P3EyZq2IuMps8/JE3e0x9JC38R5Y9V7BPW1xGGNZdTNZyOaDEYBge71GU48LwEH+IwLeOdING20AQ==
2024-03-21 12:29:39.897 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry https://192.168.10.1 for tplink_router
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tplink_router/__init__.py", line 47, in async_setup_entry
    firmware, status = await hass.async_add_executor_job(TPLinkRouterCoordinator.request, client, callback)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tplink_router/coordinator.py", line 56, in request
    data = callback()
           ^^^^^^^^^^
  File "/config/custom_components/tplink_router/__init__.py", line 43, in callback
    stat = client.get_status()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tplinkrouterc6u/client.py", line 307, in get_status
    data = self.request('admin/status?form=all&operation=read', 'operation=read')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tplinkrouterc6u/client.py", line 109, in request
    raise ClientError(error)
tplinkrouterc6u.exception.ClientError: TplinkRouter - TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/status?form=all&operation=read - Response joqmmulSleJ6gT4Wc99dezMQTr9wq2ODbc9upaVZMSyzDPK1jQa50ZLZ/qu89e4BENQVPB8jtTe6USMxojmqB8V28gLoBmnVl1BCpRzLFq1mAphGls049nu9fQeVSekPS+18iBAf1P3EyZq2IuMps8/JE3e0x9JC38R5Y9V7BPW1xGGNZdTNZyOaDEYBge71GU48LwEH+IwLeOdING20AQ==
cscherpenisse commented 8 months ago

@speedycars You need to add the MAC address of HomeAssistant in your router under System Features>>Management>>Local Management. After this it worked for me.

speedycars commented 8 months ago

Hi @cscherpenisse and thank you for your post. In my config the switch of "Access for All LAN Connected Devices" is turned on and cannot be turned off (for an unknown reason) in order to have the table you're talking about filling in MAC addresses. Also HA is connected over a OpenVPN through tun0 interface and it doesn't have such MAC address in ifconfig. :(

Are you running Router Firmware Version: 1.2.1 (build 20220714, rel.75573(455)) on your device?

cscherpenisse commented 8 months ago

@speedycars image

Maybe this will give you an idea. I am indeed using the same firmware version.

speedycars commented 8 months ago

Thanks again @cscherpenisse. I knew where this setting is located in the UI, just cannot click on this switch to turn it off: image

It spins for a second then nothing else happens, no change - switch is still on. Tried different browsers.

AlexandrErohin commented 7 months ago

Since this error is due to the settings of the router itself and is not related to this integration, I am closing the issue