mihai-dinculescu / tapo

Unofficial Tapo API Client. Works with TP-Link Tapo smart devices. Tested with light bulbs (L510, L520, L530, L610, L630), light strips (L900, L920, L930), plugs (P100, P105, P110, P115, P300), hubs (H100), switches (S200B) and sensors (KE100, T100, T110, T300, T310, T315).
MIT License
339 stars 35 forks source link

P110 getting current energy usage via different api method #109

Closed Michal-Szczepaniak closed 1 year ago

Michal-Szczepaniak commented 1 year ago

I'm seeking help in adding support in p110 api to get current power draw, let me explain.

All my "smart" devices are on network without internet access for privacy and security concerns and i've noticed that if the device turns on and connects to that network or even looses connection and then reconnects, none of the get_device_usage,get_energy_usage,get_energy_usage work which in the tplink app i can see as no energy usage graphs whatsoever. To fix that you need to kickstart them with internet connection and then they work fine just fine. But while they are not working, i noticed in the app i could still see current power draw and fankly thats all i care about (on/off works fine), so i was hoping you could help me/we could work together on finding out that api method, but if you got P110/115 then you don't need my help :P

I'm happy to provide any information and help in any way i can to get it as it's stopping me from achieving perfection

Michal-Szczepaniak commented 1 year ago

I've done a bit of reverse engineering on the app (i'm newb) and i've located CurrentPowerResult which returns ONLY currentPower which I strongly believe is the result i'm interested in, and the request is called get_current_power

Michal-Szczepaniak commented 1 year ago

So far i tested the get_current_power and indeed, get_device_usage/get_energy_usage/get_energy_data all fail with different unknown tapo errors and get_current_power does indeed return current power draw!

Michal-Szczepaniak commented 1 year ago

Imma close this now since it's merged and I was able to do it myself :P

mihai-dinculescu commented 1 year ago

It's been released in v0.7.2. Thank you!

Michal-Szczepaniak commented 1 year ago

@mihai-dinculescu what do you think about adding rest of functions

mihai-dinculescu commented 1 year ago

I'm all for adding whatever it's helpful to people.

What do you have in mind?

Michal-Szczepaniak commented 1 year ago

While looking at the apps code i just noticed some other functions, might not be exactly useful but full api coverage would be good no?

+ i'm gonna add small thingy to generate mappings for c++ which i used for my project

mihai-dinculescu commented 1 year ago

I don't think that full API coverage should be a target in itself because:

However, if someone needs a particular function, I'll gladly support its addition.

If you're looking into adding FFI-related stuff, you might want to look at and/or branch off https://github.com/mihai-dinculescu/tapo/pull/100.

Michal-Szczepaniak commented 1 year ago

Oki gotcha that makes sense

Hmm but thats for python gotta add bindings for c++ along with cbindgen :P But well this is not issue for that

Thanks