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
121 stars 15 forks source link

Can't turn on/off Guest Wifi on Deco #73

Open bchevreau opened 2 months ago

bchevreau commented 2 months ago

Describe the bug Unable to turn on or off the Guest Wifi on Deco x50 router. I have a feeling it is because in the newer version of the Deco App, both 2.4G and 5G are turning on simultaneously (only one toggle for both bands) but I am unsure how to verify as the error message isn't very explicit.

Note: the reporting works fine: if I turn it off via the app, I can see it turn off in the configuration toggles in Home Assistant. But I cannot initiate the action: toggling on/off throws errors.

Logs Failed to perform the action switch/turn_off. TplinkRouter - TPLinkDecoClient - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/wireless?form=wlan - Response Vr94vjuSaW9DP1/oebKjrgh2+8B31/Fmthzzajam5phEe/USIfMe9k4ILFprCVqLxPgKzhrGpDuwn9qdWTMUuoFEVFUUp430zApRdj/QN6ThsAuoUxWf8cRxasx+vyBy1NRMnld5buqY/0nOHmWzPRaIzd22TOgizmeiKxzY7oB5LCsUIP0fi+Z/KYZpvCuLoJjdIMHBwcYRyE/BkubB6Wc9Fnp9FRVFNpd65kkkfMCRUBD8srtblD+un4UBvtPE8VPbxVFQ5t2qUHVBA3lSZX2W5X88+M1YkVHFUudZrFW6Fjo8ghLrDqtwdl7EwkR1rnSGJglbn9rvTaUii7lXLDJuPfQziURsA5amd2+qzJE=

Additional Information (please complete the following information)

image

sebabordon commented 1 month ago

I have an XE75 Pro (v1 and v2) and it seems that it doesn't work as well. I can see status but not disable nor enable the guest wifi

bchevreau commented 3 weeks ago

@AlexandrErohin Anything I can help with for that issue? I'm happy to provide logs or go thru some debugging with you to find a way to fix those if ever. The main problem I would assume seems to be that the command sends separate commands for 2.4G and 5G whereas the DECO x50 / X60 and similar have a single switch for both of those.

AlexandrErohin commented 3 weeks ago

@bchevreau Hi. As I dont have Deco router - could you use this client https://github.com/AlexandrErohin/TP-Link-Archer-C6U) and play with wifi switch? You may test like this

from tplinkrouterc6u import TPLinkDecoClient
from logging import Logger
from json import dumps

client = TPLinkDecoClient('192.168.0.1', 'yourPassword', logger=Logger('test'))
client.authorize()
print(self.request('admin/wireless?form=wlan', dumps({'operation': 'write', 'params': {'band2_4': {'host': {'enable': True}}}})))
sebabordon commented 3 weeks ago

I tried the script, with the following output (I had to install it in debian using pipx with ---install-deps) I also tried another code in the site and the problem it seems that is not authorizing.

Traceback (most recent call last): File "/home/seba/.local/pipx/venvs/./tplink2.py", line 9, in print(self.request('admin/wireless?form=wlan', dumps({'operation': 'write', 'params': {'band2_4': {'host': {'enable': True}}}}))) ^^^^ NameError: name 'self' is not defined

AlexandrErohin commented 3 weeks ago

@bchevreau Try this

from tplinkrouterc6u import TPLinkDecoClient
from logging import Logger
from json import dumps

client = TPLinkDecoClient('192.168.0.1', 'yourPassword', logger=Logger('test'))
client.authorize()
print(client.request('admin/wireless?form=wlan', dumps({'operation': 'write', 'params': {'band2_4': {'host': {'enable': True}}}})))
sebabordon commented 3 weeks ago

@AlexandrErohin tried it... after some seconds, I receive the following

TplinkRouter - TPLinkDecoClient - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/wireless?form=wlan - Response sF+6iVSeFc/MAG8eSxcQTQH3e0at3b4qlvP5iRy8a25KxabbUqFhUV/Zw+T7BEnwbpm2kfH15Yq+sm5J++Dsk+BXIUvR0ANyMjUXSdIiwSESgkrPBvYRe9CeTMfeOWGEaTyjHKwxaFtKjJjo6tgEBCwMYza9owMzGL2+pP3zrXptM6lx0EMo0ozRNPWT/n6U22zwzTFxVsTwao8K7xYHdYYe66dn+0qX2ULYpeVulGThdzWiqEArtDzasumrGZCVFzlenchM395+W/jyo3lYtbNcX6/la2WvwhSD6AkhmpRHTmMmDca1CBQxvd8gKGnFRE8knoNVp+/xKTTmEqEDXz7eU1F8VB+g2vQDLXwQFLk= Traceback (most recent call last): File "/home/seba/.local/pipx/venvs/tplink3.py", line 7, in <module> print(client.request('admin/wireless?form=wlan', dumps({'operation': 'write', 'params': {'band2_4': {'host': {'enable': True}}}}))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/seba/.local/pipx/venvs/tplinkrouterc6u/lib/python3.11/site-packages/tplinkrouterc6u/client.py", line 111, in request raise ClientError(error) tplinkrouterc6u.exception.ClientError: TplinkRouter - TPLinkDecoClient - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/wireless?form=wlan - Response sF+6iVSeFc/MAG8eSxcQTQH3e0at3b4qlvP5iRy8a25KxabbUqFhUV/Zw+T7BEnwbpm2kfH15Yq+sm5J++Dsk+BXIUvR0ANyMjUXSdIiwSESgkrPBvYRe9CeTMfeOWGEaTyjHKwxaFtKjJjo6tgEBCwMYza9owMzGL2+pP3zrXptM6lx0EMo0ozRNPWT/n6U22zwzTFxVsTwao8K7xYHdYYe66dn+0qX2ULYpeVulGThdzWiqEArtDzasumrGZCVFzlenchM395+W/jyo3lYtbNcX6/la2WvwhSD6AkhmpRHTmMmDca1CBQxvd8gKGnFRE8knoNVp+/xKTTmEqEDXz7eU1F8VB+g2vQDLXwQFLk=

After a new run I'm getting some connection timeout, I assume It is because the script does not logoff?. I'll try later