menahishayan / TP-Link-Archer-C50-API

HTTP based python script for API access and router management of the TP-Link Archer C50
GNU General Public License v3.0
36 stars 2 forks source link

AD7200 #3

Closed ReenigneArcher closed 2 years ago

ReenigneArcher commented 3 years ago

Anyway this will work for an AD7200 router? I am only looking for a method to restart the router using an automation.

My python script is as follows.

import tplinkrouter
router = tplinkrouter.C50('192.168.1.1','myemail@gmail.com','myPassword')

which returns the following: Metadata Update Error.

menahishayan commented 3 years ago

__init__.py: Line 41 to Line 47

        try:
            about = self._get('about')['[0,0,0,0,0,0]0']
            self.__name__ = about['modelName']
            self.description = about['description']
            self.__version__ = self._get('version')['[0,0,0,0,0,0]0']['softwareVersion'].split()[4]
        except:
            self.log("Metadata Update Error.")

remove the try and except blocks and add print/log statements to attempt to debug the issue

Your code would be something like:

            about = self._get('about')['[0,0,0,0,0,0]0']
            print(about)
            self.__name__ = about['modelName']
            self.description = about['description']
            self.__version__ = self._get('version')['[0,0,0,0,0,0]0']['softwareVersion'].split()[4]

Note: If you've installed this via pip then your changes will not reflect due to python's cache. Download the script from this repo and import the local file manually


Edit

It's highly unlikely that this script will work AS-IS for the AD7200. Instead of a failed attempt at modifying the code as mentioned above, I'd suggest following the instructions mentioned in CONTRIBUTING.md to add support for your model

ReenigneArcher commented 2 years ago

I ended up writing my own script to reboot the router: https://github.com/ReenigneArcher/JBOHAS/blob/main/scripts/python/tp_link_reboot.py

It runs inside of home assistant using selenium web driver.

itsboo07 commented 1 year ago

hey how did you Manage to run the script inside home assistant ?

I ended up writing my own script to reboot the router: https://github.com/ReenigneArcher/JBOHAS/blob/main/scripts/python/tp_link_reboot.py

It runs inside of home assistant using selenium web driver.

ReenigneArcher commented 1 year ago

hey how did you Manage to run the script inside home assistant ?

Been quite a while since I added this, so not 100% sure. I think I used this as reference: https://community.home-assistant.io/t/using-selenium-with-chromedriver/259864/5

I think I used a command line sensor, but not 100% sure.