Package: tapo-plug
TapoPlugAPITapo Plug Api is a python warper that can be easily integrated in any project to control the TP-Link Tapo P100 and P105 plugs.All endpoints integrated in this package were discovered after a reverse engineering of the firmware Tapo P105, 1.3.2 Build 20210122 Rel.
However, due to a lack of information about which parameters to use for each request, other endpoints not exploited yet still need to be added in this package. If you are interested, the full endpoints list are listed below after the examples.Also, If you want to have fun with the firmware, the link is also below after the examples.Dependencies:Python 3.3+requests module (install via pip)The dependencies can be satisfied viapip install -r requirements.txtQuick Installpip install tapo-plugEndpoints:Get device informationfromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD"}response=tapoPlugApi.getDeviceInfo(device)print(response)Get device running informationfromtapoimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD"}response=tapoPlugApi.getDeviceRunningInfo(device)print(response)Turn ON the plug.fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD"}response=tapoPlugApi.plugOn(device)print(response)Turn OFF the plug.fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD"}response=tapoPlugApi.plugOff(device)print(response)Get plug time usage.fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD"}response=tapoPlugApi.getPlugUsage(device)print(response)Change plug alias.fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD","nickname":"My Awesome Plug!",}response=tapoPlugApi.setNickname(device)print(response)Turn OFF the LED.fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD"}response=tapoPlugApi.ledOff(device)print(response)Turn ON the LED.fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD"}response=tapoPlugApi.ledOn(device)print(response)Get LED status (ON/OFF).fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD"}response=tapoPlugApi.getLedInfo(device)print(response)Automatically turns OFF the device when the provided delay is expired.fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD","delay":60#seconds}response=tapoPlugApi.plugOffCountdown(device)print(response)Automatically turns ON the device when the provided delay is expired.fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD","delay":60#seconds}response=tapoPlugApi.plugOnCountdown(device)print(response)Get some diagnostic information's.fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD"}response=tapoPlugApi.getDiagnoseStatus(device)print(response)Should get device log, but always empty for me, I leave it here just in case...fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD"}response=tapoPlugApi.getPlugLog(device)print(response)Can't really tell for what this id used for now.fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD"}response=tapoPlugApi.qsComponentNego(device)print(response)Get wireless access points information around the plug..fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD"}response=tapoPlugApi.getWirelessScanInfo(device)print(response)Update plug WiFi settings.fromtapo_plugimporttapoPlugApidevice={"tapoIp":"DEVICE IP","tapoEmail":"ENTER YOUR TP-LINK EMAIL","tapoPassword":"ENTER YOUR TP-LINK PWD","ssid":"AP SSID","password":"AP PASSWORD","key_type":"AP ENC",#wpa2_psk..."region":"Asia/Tokyo",#Meaningless, but seems required}response=tapoPlugApi.setWirelessInfo(device)print(response)*Don't forget to change your tapo IP in the dict once this request completed :)Full endpoints list:Here are all enpoints used by Tapo P105 found in the firmware.Endpoints ListEndpoints Listget_device_inforemove_antitheft_rulesget_device_running_infoset_antitheft_all_enableset_device_infounbindDevicedevice_resetsetAliasdevice_rebootpassthroughget_latest_fwmultipleRequestfw_downloadgetWifiBasicget_fw_download_stategetFwCurrentVercomponent_negogetFwDownloadProgressqs_component_negomodule.negotiateset_qs_infomodule.queryset_qs_extra_infomodule.executeget_device_timemodule.configset_device_timeget_factory_infoget_wireless_scan_infoget_diagnose_statusset_wireless_infoaccount_syncget_schedule_rulessync_envadd_schedule_ruleset_device_logedit_schedule_ruleget_device_logremove_schedule_rulesset_flash_logset_schedule_all_enableget_flash_logget_next_eventget_led_infoget_schedule_day_runtimeset_led_infoget_schedule_month_runtimeconnect_cloudremove_all_schedule_runtimeget_connect_cloud_stateget_countdown_rulesget_ffs_infoadd_countdown_ruleclose_device_bleedit_countdown_ruleheart_beatremove_countdown_rulesget_device_usageget_antitheft_rulesclose_device_bleadd_antitheft_ruleset_inherit_infoedit_antitheft_ruleget_inherit_infoexec_atcmdI think the function exec_atcmd is one of the most interesting because the function name mean it is possible to send AT commands directly to the device, in theory. I've tried everything but nothing worked... In any case all the compatible AT commands are also listed in the firmware, if someone can find how to use it... PLEASE ping me!Tapo firmware:Tapo P105 1.3.2 firmware:http://download.tplinkcloud.com/firmware/P105_1.3.2_20210122_r57063_up_signed_1615802824400.binBuilding modules:To build a package to install viapiporeasy_install, execute:python setup.py sdistThe resulting build will be in$PWD/dist/tapo_plug-<version>.tar.gz