Enter the host & credentials used to log in to your router management page. Username is admin by default. But you may pass username as third parameter
fromtplinkroutergdprimportTplinkRouterGDPR, WififromloggingimportLoggerrouter=TplinkRouterGDPR('http://192.168.0.1', 'password')
# You may also pass username if it is different and a logger to log errors as# TplinkRouter('http://192.168.0.1','password','admin2', Logger('test'))# Get firmware info - returns Firmwarefirmware=router.get_firmware()
# Get status info - returns Statusstatus=router.get_status()
# Turn ON guest wifi 2.5Grouter.set_wifi(Wifi.WIFI_GUEST_2G, True)
# Get Address reservations, sort by ipaddrreservations=router.get_ipv4_reservations()
reservations.sort(key=lambdaa:a.ipaddr)
forresinreservations:
print(f"{res.macaddr}{res.ipaddr:16s}{res.hostname:36}{'Permanent':12}")
# Get DHCP leases, sort by ipaddrleases=router.get_ipv4_dhcp_leases()
leases.sort(key=lambdaa:a.ipaddr)
forleaseinleases:
print(f"{lease.macaddr}{lease.ipaddr:16s}{lease.hostname:36}{lease.lease_time:12}")
The TP-Link Web Interface only supports upto 1 user logged in at a time (for security reasons, apparently).
So before action client authorize and after logout
To reduce authorization requests client allows to make several actions with one authorization
fromtplinkroutergdprimportTplinkRouterGDPR, Wifirouter=TplinkRouterGDPR('http://192.168.0.1')
router.connect('password',logout_others=True)
router.single_request_mode=False# make client use single authorizationtry:
ifrouter.connect('password',logout_others=True): # authorizingstatus=router.get_status()
ifnotstatus.guest_2g_enable: # check if guest 2.4G wifi is disablerouter.set_wifi(Wifi.WIFI_GUEST_2G, True) # turn on guest 2.4G wififinally:
router.logout() # always logout as TP-Link Web Interface only supports upto 1 user logged
Please let me know if you have tested integration with one of this or other model. Open an issue with info about router's model, hardware and firmware versions.