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
132 stars 16 forks source link

BE800 - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/firmware?form=upgrade - Response #114

Open zhunhung opened 1 week ago

zhunhung commented 1 week ago

Describe the bug A clear and concise description of what the bug is.

After logging in via HomeAssistant UI, I get this error immediately.

Logs Add also all relevant logs from Settings->System->Logs.

Screenshot 2024-11-07 at 6 06 46 PM Screenshot 2024-11-07 at 6 06 59 PM

Additional Information (please complete the following information)

AlexandrErohin commented 1 week ago

Could you post the full error here?

zhunhung commented 1 week ago
2024-11-07 18:06:27.661 ERROR (SyncWorker_3) [custom_components.tplink_router] TplinkRouter - TPLinkDecoClient - Unknown error for pwd! Error - 'result'; Response - {"success":true,"data":{"password":["<full password>","010001"],"mode":"router","username":""}}
2024-11-07 18:06:28.443 ERROR (SyncWorker_5) [custom_components.tplink_router] TplinkRouter - TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/firmware?form=upgrade - Response 
2024-11-07 18:06:28.447 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry http://192.168.0.1 for tplink_router
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, 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 42, in callback
    firm = client.get_firmware()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tplinkrouterc6u/client.py", line 316, in get_firmware
    data = self.request(self._url_firmware, 'operation=read')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tplinkrouterc6u/client.py", line 112, in request
    raise ClientError(error)
tplinkrouterc6u.exception.ClientError: TplinkRouter - TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/firmware?form=upgrade - Response 
2024-11-07 18:06:39.193 ERROR (MainThread) 

Here you go!

AlexandrErohin commented 1 week ago

Your router dosnt provide firmware info. It is strange as Archer BE800 v1.0 was tested OK here https://github.com/AlexandrErohin/TP-Link-Archer-C6U/issues/34

zhunhung commented 1 week ago

Yup, thats why I'm not too sure what's wrong. It does provide the firmware info though, when I logged into the web UI of the router, the api call is successful.

Screenshot 2024-11-07 at 7 14 34 PM

When I try to use this package tplinkrouterc6u and run a separate python script, it returns {"data": ""} which is the same issue I raised.

AlexandrErohin commented 1 week ago

Do you have the latest Router Firmware Version ? When you use tplinkrouterc6u could you call get_status() ? does it work?

zhunhung commented 1 week ago

Yup, it is the latest version. I cant call get_status() as well:

try:
    router.authorize()  # authorizing
    # Get status info - returns Status
    status = router.get_status()

Output:

http://tplinkwifi.net/cgi-bin/luci/;stok=<hash>/admin/status?form=all&operation=read 
...
tplinkrouterc6u.exception.ClientError: TplinkRouter - TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/status?form=all&operation=read - Response 

Same issue if I were to use http://192.168.0.1 instead of http://tplinkwifi.net

AlexandrErohin commented 1 week ago

Do you use router local password or password from TP-LINK ID?

zhunhung commented 1 week ago

I used local password, I verified by using the password for this: Screenshot 2024-11-07 at 7 40 10 PM

router = TplinkRouterProvider.get_client('http://192.168.0.1', <local password>')

If I input the wrong password, I will get this error:

Exception: Not authorised
AlexandrErohin commented 1 week ago

It is better to ask help @nicandris as he has this router and has tested this client for BE800

nicandris commented 1 week ago

I'm not using hassio, can you run this? https://gist.github.com/nicandris/c822b68f56c4efffff3eb53f37ab584d#file-be800-tplinkrouterc6u-py-L92

i just tried it and it can fetch the firmware just fine. (you dont really need to run the entire script, you can run router = TplinkRouterProvider.get_client(args.url, args.credentials) and then firmware = router.get_firmware()

be800

zhunhung commented 1 week ago

Thanks @nicandris!

router = TplinkRouterProvider.get_client(args.url, args.credentials) and then firmware = router.get_firmware()

Running get_firmware() gives the same error:

tplinkrouterc6u.exception.ClientError: TplinkRouter - TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/firmware?form=upgrade - Response 
thegeekybeng commented 3 days ago

On that note, the same thing is happening for my Archer BE 805, it is a relief to know that likely is not an isolated issue.

AlexandrErohin commented 2 days ago

Do you have something that uses your password to login to the router constantly ? Like mobile APP

zhunhung commented 2 days ago

Do you have something that uses your password to login to the router constantly ? Like mobile APP

I just tried to log out of the router in the Tether app and reload the integration. The same error persists :/