AlexandrErohin / TP-Link-Archer-C6U

Python package for API access and management for TP-Link Routers. See supported routers list
GNU General Public License v3.0
59 stars 22 forks source link

fixed down / up speed values #36

Closed ryirv closed 2 months ago

ryirv commented 3 months ago

Changed grabbing values from "client?form=client_list" to "smart_network?form=game_accelerator". Compatible with AX1800 model.

AlexandrErohin commented 3 months ago

These changes brake compatibility and tests.

Post here the json responses from client?form=client_list and smart_network?form=game_accelerator for your router?

ryirv commented 3 months ago

I feel like I should add as much info as I can here. Here is the code that I'm running:

clients = router.get_status().devices
    for client in clients:
        print(f"{client.macaddr} {client.ipaddr:16s} {client.hostname:36} {client.down_speed:12} {client.up_speed:12}")

JSON response from game_accelerator (snipped):

smart_network: [{'enableLimit': 'off', 'index': 11, 'trafficUsage': 119799472368, 'ip': '192.168.2.71', 'remainTime': -1725038476, 'deviceName': 'RYAN_PC', 'key': '-snip-', 'uploadSpeed': 11439, 'onlineTime': 11244.96, 'mac': '-snip-', 'downloadSpeed': 12547, 'isGuest': False, 'deviceType': 'pc', 'downloadLimit': '16384', 'uploadLimit': '-1', 'enablePriority': True, 'timePeriod': '-1', 'speedLimitOnline': True, 'deviceTag': 'wired'}]

The original method which grabs the down / up speeds is never called (class TPLinkDecoClient):

    def get_status(self) -> Status: # never called
        data = self.request('admin/network?form=wan_ipv4', json.dumps({'operation': 'read'}))

        status = Status()

When I try to get client?form=client_list using :

                data = self.request('admin/client?form=client_list', json.dumps(
            {"operation": "read", "params": {"device_mac": "default"}})).get('client_list', [])

                for item in data:
                    print(item)

I get the following error:

Error: TplinkRouter - TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0); Request admin/client?form=client_list - Response TSb7SPLQ3HY1zlv/G5xpStVnT8KS20rxJrA2XktlmoHWMNNtZ2lv6DJX8RrfY5BFUoCQe/oVGm6BMLlKKmK2bq83bbQRMDrcoCtB58FWDFymmoIFdu6B1l0yosDrN85S2txJlvNfiqIFyxAzYNG/9ZbNUSaWsa0yNy+Tlw/Pfk4kTJ2cFWoFYPf2LDVP4EMGx615Qun+uO97FArHnp77Q+gqSPYvLAmaifE1lr7nmfIEQIVqCcX1mU1tlFZ7NBOTg/AI7d1ykvlDRcG1E5Vquw==

Let me know if you'd like anything else, cheers.