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
312 stars 30 forks source link

Local access to TAPO P110 for energy data #215

Open goofy2k opened 1 month ago

goofy2k commented 1 month ago

Is acquisition of energy data of the P110 still possible with local access?

I did that succesfully in NodeRed using the staus node of this flow. Lately I get invalid results. Could this be due to blocking of the functionality in recent firmware updates?

mihai-dinculescu commented 1 month ago

As far as I know, getting the energy data has always required the device to be connected to the internet. I suspect this is because the data is stored in the cloud rather than on the device.

goofy2k commented 1 month ago

Thanks for your reply!

I have been able to access the devices locally with a Nodered flow. Currently I can only get the data by using the Export function in the Android Tapo app. This generates a csv file that is sent to my email.

Currently I have no way to get my data available via Homey Pro.

Fred

mihai-dinculescu commented 1 month ago

Yes, you can access the device, get device info, turn it on/off, etc, without the device having an internet connection. But to get energy data, it does need an internet connection.

goofy2k commented 1 month ago

I will send you a link to the relevant source code(s) later.

Unfortunately I am not able to test it anymore e.g. by switching off my internet connection.

I The API info was allegedly supplied by TP-link. I now suspect that they removed that mode of access in later firmware updates.

Now I have to press a key in the Android app. Then I get an email with the data in some longer period.

I could live with it if I could let a Homey app do that key press all was it in a weekly frequency....

goofy2k commented 1 month ago

I discovered that more people hit on this issue. Local access was possible, but the method does not work after a firmware upgrade of the plugs.

You can find the discussion by following the link to the nodered software in my first message. Then follow the link to the relevant github repository and see Issues.

There is a solution available for Home Assistant. It is based on this.

I will test that solution in Python to see if it works for me....

mihai-dinculescu commented 1 month ago

Is this the issue that you're referring to? https://github.com/sanlike0911/node-red-contrib-tplink-tapo-connect-api/issues/38

goofy2k commented 1 month ago

Yep

mihai-dinculescu commented 1 month ago

That thread is about last year's firmware version that started using the KLAP encryption protocol. This library does support it.

goofy2k commented 1 month ago

OK that's great! I will see if I can get data from my P110's ! I'll have to study how to use the lib.

OK. Got your TAPO_p110.py script working OK! Switches my garden lights on and of and ..... gets energy data. :-)

I use(d) that for monitoring energy usage of my heat pump.

I am not very knowledgable on networking. Is this local access? The plugs do not request for data from the TP-link cloud?

mihai-dinculescu commented 3 weeks ago

It is primarily local access. Most operations do not require the device to be connected to the Internet. However, some, like getting energy usage historical data, do require a cloud connection. Also, the devices need to connect to the cloud from time to time so that the locally cached password hash is synced.