Anyone have any info on the TP-Link Kasa HS110 Energy Monitoring Plug API

Hi
I was wondering if anyone had any information on the API that Sense uses to gather data from the TP-Link Kasa HS110 energy monitoring smart plug. I’m interested in writing a driver for my smart home processor to gather data directly from a few of the ones I’ve put into my house to help Sense.

I contacted TP-Link and they’ve told me the API isn’t public. At the same time there are a number of people who have written drivers and put them on GitHub. I’d prefer not to be trying to reverse engineer someone else’s code vs. just writing something fresh to decent documentation.

Thanks in advance for the help.

What system are you using? I think I have a post on the Hubitat forums bookmarked regarding integrating these plugs.

Somebody else has done the reverse engineering:
https://www.softscheck.com/en/reverse-engineering-tp-link-hs110/

You might also want to check in with @duanetiemann. He has written code to pull data from HS110s and Wemo Insights directly. I have used a few times.

https://community.sense.com/t/real-time-utilities/3720

Thanks so much for all the quick replies.

I’ll take look into all the recommended sources of information and also contact @duanetiemann.

My plan is to write a driver for a Crestron control system so the mail part of the driver would be written in C# with the remainder written in Crestron’s proprietary tools.

Thanks again for the help

@jay.m.basen
The link Kevin posted works well for smart plugs on the local network. I’ve been working up accessing smart plugs from off-site. These links helped me.
https://itnerd.space/2017/01/22/how-to-control-your-tp-link-hs100-smartplug-from-internet/
http://itnerd.space/2017/01/29/get-the-state-of-your-hs100-smart-plug/
http://itnerd.space/2017/06/19/how-to-authenticate-to-tp-link-cloud-api/
http://itnerd.space/2017/05/21/how-to-get-the-tp-link-hs100-cloud-end-point-url/
They get to the plugs through a Kasa server.
My code is in java. It seems to work, but doesn’t have many miles on it.
I have seen a few hs110 glitches, reporting huge current for a while. Have to watch out for those.
I can provide example local and remote java code if it will help.
My thought is to provide a cloud server that monitors such things for folks. Not there yet.
I haven’t explored controlling them. I’m just interested in the energy reporting for now.

1 Like

Thanks so much @duanetiemann!!

I’m just interested in pulling energy usage data locally from an HS110. If you can point me to the best example of doing that it would be incredibly helpful.

Thanks again.

This is my updated code to do that. There are some utility routines around it, but I don’t think you need them to get the idea.

There are more TP-Link energy monitoring models now. This code also contains support for the HS300 which has multiple outlets, but I haven’t really incorporated it in my collection yet. Don’t know what problems may exist around it.

CollectKasa.java

The ‘encryption’ is described in Kevin’s link. But my code to do it is in

Utilities.java

methods encryptKasaBytes and decryptKasaBytes.

Duane

1 Like

Thanks @duanetiemann!!