Code Monkey home page Code Monkey logo

Comments (5)

cocohub avatar cocohub commented on July 17, 2024

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.

from tplink-smartplug.

rct avatar rct commented on July 17, 2024

@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.

from tplink-smartplug.

PatrickBB29 avatar PatrickBB29 commented on July 17, 2024

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

from tplink-smartplug.

allotmentearthy avatar allotmentearthy commented on July 17, 2024

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

from tplink-smartplug.

Dhiyaddein avatar Dhiyaddein commented on July 17, 2024

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

from tplink-smartplug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.