python-kasa and KLAP authentication

python-kasa and KLAP authentication

python-kasa and KLAP authentication
python-kasa and KLAP authentication
Wednesday
Model: EP10  
Hardware Version: V1
Firmware Version: 1.1.1 Build 250908 Rel.112508

I purchased two Smartplug switches a while back, models EP10. They are currently running software version 1.0.5 Build 221021 Rel.183404. I also installed the python-kasa kit on my raspberry-pi. This is running the latest version python-kasa. Happy with how these were working I ordered two more EP10s. While adding the new smartplugs I went for the software upgrade. These new devices are running software version 1.1.1 Build 250908 Rel.112508. From reading the web I see that the kasa hardware started moving to KLAP 1.(KASA Local Authentication Protocol) with these later versions.

 

On the new smartplugs I can't get the klap authentication to work. I see others with the same issues on this forum but no real clear answers. What's more baffling is that the new plugs KasaPlug3&4 toggle between XOR and KLAP. While on XOR the python-kasa tool works fine. However once they toggle over to KLAP the authentication error appears and I can no longer manage them through the python tool.

 

Note that using the app on my phone, both Kasa and Tapo I can operate the new smartplugs just fine however I really want to use the python tool for reasons I don't want to explain. The python tool does have options to pass usernames and passwords using KLAP. Best I can tell the smartplugs running the later software are not logged into the cloud, but if that's the case then how is the app working on my phone?

 

For example I get the same error below when using the correct username and password.

kasa -e klap --username johnedoe@gmail.com --password abc12345 --host 172.18.64.25 sysinfo

Raised error: Device response did not match our challenge on ip 172.18.64.25, check that your e-mail and password (both case-sensitive) are correct.

 

When logged into tpcloud I do not see the smartplugs. Is this normal? Is there a way to get the new devices to stay on XOR? I have done all the usual things like remove the devices and re-add them, toggle off/on 3rd party apps etc however the behavior is the same. Any ideas?

 

kasa discover list
HOST            MODEL     DEVICE FAMILY        ENCRYPT HTTPS LV  ALIAS
172.18.64.99    EP10      IOT.SMARTPLUGSWITCH  XOR     0     -   KasaPlug2
172.18.64.25    EP10      IOT.SMARTPLUGSWITCH  XOR     0     -   KasaPlug4
172.18.64.100   EP10      IOT.SMARTPLUGSWITCH  XOR     0     -   KasaPlug3
172.18.64.98    EP10      IOT.SMARTPLUGSWITCH  XOR     0     -   kasaPlug1

 

kasa discover list
HOST            MODEL     DEVICE FAMILY        ENCRYPT HTTPS LV  ALIAS
172.18.64.100   EP10      IOT.SMARTPLUGSWITCH  KLAP    0     2   - Authentication failed
172.18.64.25    EP10      IOT.SMARTPLUGSWITCH  KLAP    0     2   - Authentication failed
172.18.64.98    EP10      IOT.SMARTPLUGSWITCH  XOR     0     -   kasaPlug1
172.18.64.99    EP10      IOT.SMARTPLUGSWITCH  XOR     0     -   KasaPlug2

  0      
  0      
#1
Options
1 Reply
Re:python-kasa and KLAP authentication
Wednesday

  @TimDor 

 

UPDATE:

 

I got a little further with this today however it's a work-around I'm not sure how long will last. I can manipulate the plug without issue if I use the switch "--type plug" in the command. I ran tcpdump while executing the command below and it uses port 9999/tcp on the smartplug exclusively. When not using that switch it defaults to including the 80/tcp and 20002/udp ports. This is because minus the "--type" switch the tool does a discovery. So any time a discovery is used you get the chance of the authentication failure.

 

So for example...

 

BROKEN

kasa --host 172.18.64.25 toggle
Discovering device 172.18.64.25 for 10 seconds
Raised error: Device response did not match our challenge on ip 172.18.64.25, check that your e-mail and password (both case-sensitive) are correct.
Run with --debug enabled to see stacktrace
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7fadc1b8c0>
ERROR:asyncio:Unclosed connector
 

WORKING

kasa --type plug --host 172.18.64.25 toggle
Turning on KasaPlug4

 

I guess I can live with this for now however it does not solve the original ask of getting KLAP to work. That ultimately needs to be figured out. 

  0  
  0  
#2
Options

Information

Helpful: 0

Views: 76

Replies: 1