[Custom Component] Tapo P100 Plug Control

You have done some awesome work here! Will this become an official add on at some point? I really like these plugs as they are nice and compact.

I cant get to work tapo with the credentials problem Its very dissaponting

It does seem that the component sometimes doesn’t like plugs / accounts that are already set up, giving a ‘Possibly bad credentials’ error in the HA Log. It’s not clear why.

Many people seem to have had success by resetting the plugs, and then creating a totally new Tapo account. Have you tried this?

After a few tries, I managed to get it working. First of all thank you fishbigger for your work.
Just for context, I run HASSIO with HA 0.118 inside a Docker container on a RPi3B+.

As many of you, I had the “Possibly invalid credentials” error. This is what I did:

  • reset the P100;
  • deleted it from my account;
  • changed my app password and set it to 8 characters, only lowercase, 1 number, no special characters;
  • added the P100 to my account (I simply called it “tapo”)

After rebooting HA it worked.

1 Like

Thanks @dogez
Now my two Tapo are working!!!
I also gave different name like “Christmas tree”, no problems!!
Thanks a lot!

If you missed the sh!tstorm with some of the Tp-Link Kasa plugs:

Ouch. Well yeah I feel this could unfortunately happen at any time with the tapo plugs because ultimately this connection we have now is even more hacky and “unapproved” than the Kasa local integration was.

Have a look at the end of the topic, the py-kasa integration is about to be updated, there seems to be a similar protocol for those plugs as well. App/handshake1 and handshake2 endpoints for the handshake. It is called KLAP protocol.

After a Black Friday spree on cheap P100s, I decided to beef up my rubbish password on the account. The integration failed with ‘Possibly Invalid Credentials’ again. Eek. So I repeated the new account, reset everything, re-add everything method. Aaaaaaand can’t get them back.

@fishbigger - you’ve done some sterling work on getting this integration moving quickly. But there is clearly something a little rum about how TP-Link are validating credentials here. Combined with the rather shifty stuff going on with the Kasa range (ie cutting off local access), I wondered if you’re still actively looking at how this is achieved, and potentially looking at an official API route… (as @GSzabados mentions above)?

*Nothing to do with the now 15 plugs sat here blinking at me, you understand…

An update: after all sorts of juggling, I went back to the account that worked, changed the password back to the terrible one, and… it all works again as if nothing changed. If I change the password again, it breaks. Obviously something very specific going on about whether it likes the credentials or not.

1 Like

Just wanted to add that reducing my password length from 10 to 8 characters fixed the credentials issue for me. It included numbers too.

1 Like

Interesting. I’ve just managed to get (yet another) new account working. And I also took the password down to 8 characters from 10…

This might be a newbie HA question but why are my Tapo devices showing up as entities rather than devices? Is there any way I can achieve that?

In case it’s useful in diagnosing the ‘invalid credentials’ problem, I moved from a Docker HA Core environment to a Virtual Machine HA Supervised environment (with a different IP) and the Tapo devices worked first time.

So I have one P100 v1.0 and P100 v1.2 … I am right now looking for the external API from Tapo and they are completed different requests. It’s super strange that with a new product they are already creating a completely new way of doing the requests

This is how you make requests with 1.2:

{
   "method":"passthrough",
   "params":{
      "deviceId":"8022827EE8EEE2D2ABE0580FC80C105CAAAAAAAA",
      "requestData":{
         "method":"multipleRequest",
         "params":{
            "requests":[
               {
                  "method":"get_device_running_info",
                  "terminalUUID":"98-3B-16-96-48-AA",
                  "requestTimeMils":1606006249234
               }
            ]
         },
         "requestTimeMils":0
      }
   }
}

And the response is:

{
    "error_code": 0,
    "result": {
        "responseData": {
            "result": {
                "responses": [
                    {
                        "result": {
                            "rssi": -44,
                            "time_usage_today": 7,
                            "latitude": 311112,
                            "ip": "192.168.1.9",
                            "device_on": true,
                            "avatar": "house",
                            "time_usage_past30": 12608,
                            "has_set_location_info": true,
                            "time_usage_past7": 8646,
                            "signal_level": 3,
                            "on_time": 453,
                            "overheated": false,
                            "nickname": "UGx1ZyAy",
                            "location": "bedroom",
                            "fw_ver": "1.2.1 Build 20200616 Rel. 31218",
                            "longitude": -91116
                        },
                        "method": "get_device_running_info",
                        "error_code": 0
                    }
                ]
            },
            "error_code": 0
        }
    }
}

Oh. Facepalm emoji. How annoying. But that’s great that you’re looking!

The multipleRequest method is used by the Tapo cameras as well, but they do use another simple way as well. Try this new method on the old plug and the old method on the new plug. You will might see that they both work.

The integration works great for a few days. After it I start to get, without being able to control the switches m

  • Updating tapo_p100_control switch took longer than the scheduled update interval 0:00:30

A fix is to reinstall HA. Any ideas?

Successfully installed and running on my Home Assistant server that runs on my Synology control for two plugs.
Initial attempt failed with the PyP100 error, simply copying tapo_p100_control folder into the custom_components folder and restarting the server before adding the lines to configuration.yaml solved it.
Now how do I create an automation? The Tapo plugs do not show up as devices when trying to create an action.

I’m doomed. I bought a P105 assuming that it will work since I saw a TP-Link documentation a long time ago. Now P100 is still a work in progress. I tried it and failed. It says that the credentials are wrong.

How do you sniff the data sent by the plugs?

Still getting the

Error Code: -1501, Invalid Request or Credentials

But I was able to login via the cloud api using postman and see all my devices registered via the cloud.
The thing that hinders me and got me stumped is in the login() function.
I reviewed the code and saw that this part depends on the encryption that was used by the app. I am not sure if the current PyP100 is aligned with the current Tapo App or I’m doing something wrong.

But I think it’s safe to assume that the encryption step of the app does not need to know the type of the device nor the model. I want to reverse engineer the app but I’m still hoping someone here still has the answer.

My Tapo app is currently 2.2.36