fishbigger / TapoP100

A module for controlling the TP-Link Tapo P100 Plugs
MIT License
572 stars 142 forks source link

[documentation] what units are the various values in the result object? #78

Open lemoustachiste opened 2 years ago

lemoustachiste commented 2 years ago

so I'm getting this object back:

{
    'today_runtime': 1327, 
    'month_runtime': 1604, 
    'today_energy': 8946, 
    'month_energy': 10507,
    'current_power': 3275944
}

I couldn't find what are the units associated with these values. runtime would be in Minute? energy in Watt? What about current_power?

Thanks

lemoustachiste commented 2 years ago

checking with the tplink app, it seems my assumptions are correct for time and energy, and current power looks like it is in mW (milliwatt)

peterdk commented 1 year ago

Energy seems to be in Wh, so Wh/1000.0 -> kWh

stylemessiah commented 1 year ago

heres my test script with the units formatted (at least as i like them)


import json
import datetime
import base64

plugips = ["10.0.0.64", "10.0.0.65"]
username = "xxxxxxxxx@gmail.com"
password = "xxxxxxx"

for x in plugips:
    from PyP100 import PyP110
    p110 = PyP110.P110(x, username, password)
    p110.handshake()
    p110.login()
    returnedData = p110.getDeviceInfo()
    nickname = base64.b64decode(returnedData['result']['nickname'])
    nicknameDecoded = nickname.decode("utf-8")
    print ("Plug Name:", nicknameDecoded)
    print ("Device IP:", returnedData['result']['ip'])
    print ("Device On:", returnedData['result']['device_on'])
    print ("Device Model:", returnedData['result']['model'])
    print ("Firmware Ver:", returnedData['result']['fw_ver'])
    print ("Device ID:", returnedData['result']['device_id'])
    print ("MAC:", returnedData['result']['mac'])
    print ("Device On Time:", (datetime.timedelta(seconds=(returnedData['result']['on_time']))))
    print ("Device Overheated:", returnedData['result']['overheated'])
    print ("Power Protection:", returnedData['result']['power_protection_status'])
    print ("RSSI:", returnedData['result']['rssi'])
    print ("Signal Level:", returnedData['result']['signal_level'])
    print (" ")
    returnedData = p110.getEnergyUsage()
    print("Current Stats:")
    todayRuntime = round((returnedData['result']['today_runtime'] / 60), 1)
    print ("Hours:", todayRuntime)
    todayEnergy = round ((returnedData['result']['today_energy'] / 1000), 2)
    print ("kWh:", todayEnergy)
    currentPower = round((returnedData['result']['current_power'] / 1000))
    print ("Watts:", currentPower)
    print (" ")