Archive for "Aug 24 2021"

How to Reset Energy Usage and Runtime on TP-Link Kasa Smart Plugs (KP115/HS110)

I recently acquired a few TP-Link Kasa KP115 smart plugs with energy metering. It was a bit disappointing to find that they barely show any data. There are no graphs, no voltage or current, just instantaneous power and summary energy stats and runtime:

I wanted to find the daily energy consumption of various appliances, so I needed a way to reset the energy counter to zero. Believe it or not, TP-Link doesn’t provide a way to reset the energy. TP-Link support says that you have to delete the plug from Kasa, factory reset, and then add it back to Kasa.

The most ridiculous part is, the smart plugs actually have a command to reset the energy without resetting the whole device! They’re just too lazy to add it to their app!

I found a github repo with a list of the commands available in the TP-Link protocol. It turns out that there’s a command to reset the energy monitor!

Erase All EMeter Statistics
{"emeter":{"erase_emeter_stat":null}}

The repo contains a Python3 script that can query the energy stats, but it doesn’t have an option to send the emeter reset command. Fortunately, it has a command line option to send an arbitrary JSON command to the plug. I tried sending the above to my KP115, and the energy meter was instantly reset to 0! Although I don’t have one, the same command should also work on the older HS110 smart plug.

So here’s how to do it:

  1. Download and install Python 3.x: Python Downloads
  2. Download tplink_smartplug.py
  3. Next you need to know the IP address of the smart plug you want to reset. If you don’t know how to find it from your WiFi router, you can scan for it with an IP scanner, such as Fing. Look for a device named KP115 (or HS110).
  4. open up a command shell and type:
python3 ./tplink_smartplug.py -t <ipaddr> -j {"emeter":{"erase_emeter_stat":null}}

substituting the IP address of your smart plug for “<ipaddr>.”

Example:

# python3 ./tplink_smartplug.py -t 192.168.1.36 -j {"emeter":{"erase_emeter_stat":null}}
Sent:      {emeter:{erase_emeter_stat:null}}
Received:  {}

The Python script returns “Received: {}” if it’s successful. Next, open up your Kasa app, and check to see if the energy meter was reset successfully.