Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which command to get the runtime values and statistics? #12

Open
PatrickBB29 opened this issue May 18, 2017 · 5 comments
Open

Which command to get the runtime values and statistics? #12

PatrickBB29 opened this issue May 18, 2017 · 5 comments

Comments

@PatrickBB29
Copy link

Hi,
using Kasa application, it's possible to get information about energy usage and also about runtime.

I don't find the command to get these statistics (Current runtime, Total runtime, day or month stats about runtime).
Is there any missing commands in the file "tplink-smarthome-commands.txt"?

Other question, the command -energy ( {"emeter":{"get_realtime":{}}} ) gives a value for a parameter named 'current'.
Do you know what the 'current' data is, what is its unit?

Many thanks,

Patrick

@cocohub
Copy link

cocohub commented May 18, 2017

Yo man, if you use the info command, you'll get a response where among the stuff returned, you'll find "on_time" which shows how many seconds the device has been running since it was turned on.

If there's a command missing, you can find the commands by using a network monitoring app on your phone to check what commands Kasa is sending, then you can use the python script to send the same commands that you found through the network monitoring app.

@rct
Copy link

rct commented May 18, 2017

@PatrickBB29 - I don't have access to mine at the moment, but IIRC, current is in amperes. It should be a float. (This should let you do P = I x E, but maybe only for a straight resistive load. I did some testing with a space heater.)

IIRC the device is uploading samples to Kasa's cloud service. So if you wanted to do it locally, you'd need to periodically poll and accumulate the values into the desired buckets.

Have you seen the Reverse Engineering blog post? There is a lot of info in there. While the focus is security, there is quite a bit about how the device functions. There might have been a way to change the URL the device posts to, though ssl certificate might be a problem.

@PatrickBB29
Copy link
Author

Hi,
thanks for replies.
I monitored network packets between Kasa app and cloud service (see attached file).
It can be found energy data and also time data.
I'll try to use these captures to complete to complete my work in jeedom (home automation software).
sniff_Kasa.txt

@allotmentearthy
Copy link

allotmentearthy commented Nov 11, 2017

Hi,
In my experience, data from get_realtime current and voltage are not congruent with the wattage.
For starter, voltage is given well above the 220-230V here.
Then One can assign any pair vgain igain, provided vgain/igain ratio is kept constant so that the wattage stay identical to the load.

Finally, with a load multiplied by almost 6, current only increase by almost 3.

P <> U x I /1.414 (accounting for efficient voltage of a sinusoidal power supply 2^0.5=1.414)

Neglecting cosine effects on the power
with 4 power data points 20 to 180 W roughly, the linear relation is
I reel (in Amps) = 1.414 x (312/220 x I -32/220)
where I is the current value from get_realtime
ok it does not work near zero, i noticed

I might be all wrong, so have a look as well

@Dhiyaddein
Copy link

Hi @PatrickBB29 ,

I saw your thread and I had similar question. How do I get the total runtime of the machine that is connected to the smart plug? For example I have a TV connected to it and I want to know how many hours have the TV switched on for a day, a week perhaps a month? Not the switch on time of the smart plug. Any solutions?

Regards,
Din

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants