Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I will note up front here I've scoured issues and discussions here, Home Assistant docs, reddit, and general search. I'm hoping to get some clarity on the status of Kasa EP25 smart plugs.

I just unboxed newly arrived Kasa EP25 (https://www.amazon.com/dp/B0B14C719T). I chose these plugs as I intend to use them specifically with Home Assistant and they are shown as supported on the HA Integrations page for TP-Link Kasa Smart. Also, I've been using EP10 plugs for about a year and really impressed with their reliability and non-cloud functionality.

But about these EP25s... the setup was awkward and I'll share details of that if requested. As a troubleshooting step I used python-kasa and the results are as such (identifying details fuzzed):

# kasa --debug --host 192.168.1.108
No --type defined, discovering..
DEBUG:kasa.discover:[DISCOVERY] ('192.168.1.108', 9999) >> {'system': {'get_sysinfo': None}}
DEBUG:kasa.discover:Waiting a total of 5 seconds for responses...
DEBUG:kasa.discover:[DISCOVERY] Unsupported device found at 192.168.1.108 << {'result': {'device_id': '189foobarfoobar2323b66ce', 'owner': 'F37BWEIROFOOBAR238423B40E1C8', 'device_type': 'SMART.KASAPLUG', 'device_model': 'EP25(US)', 'ip': '192.168.1.108', 'mac': '3C-52-A1-D0-00-00', 'is_support_iot_cloud': True, 'obd_src': 'apple', 'factory_default': False, 'mgt_encrypt_schm': {'is_support_https': False, 'encrypt_type': 'AES', 'http_port': 80, 'lv': 2}}, 'error_code': 0}
Got error: UnsupportedDeviceException("Unsupported device 192.168.1.108: {'result': {'device_id': '189foobarfoobar2323b66ce', 'owner': 'F37BWEIROFOOBAR238423B40E1C8', 'device_type': 'SMART.KASAPLUG', 'device_model': 'EP25(US)', 'ip': '192.168.1.108', 'mac': '3C-52-A1-D0-00-00', 'is_support_iot_cloud': True, 'obd_src': 'apple', 'factory_default': False, 'mgt_encrypt_schm': {'is_support_https': False, 'encrypt_type': 'AES', 'http_port': 80, 'lv': 2}}, 'error_code': 0}")

So some observations (what I understand) and notes:

  • In the Kasa app I see Firmware Version: 1.0.1 Build 230614 Rel. 150219
  • The HA Integrations page for TP-Link Kasa Smart shows these as supported yet the kasa-python README does not. The HA Integrations page suggests the underlying mechanism for support is python-kasa. Can anyone clarify?
  • Ultimately I was able to get the plugs in HA as Discovered: TPLINK Smart Plug 123B (Outlet) HomeKit Controller and I'm able to power on/off the devices. Yet I'm currently troubleshooting how to get the energy monitoring details. My starting point has been this discussion.

So while I continue to dig I'm hoping for a comment from someone more knowledgeable than me about the extent of support on these devices. That is, can I get the full feature of energy monitoring with these plugs or just power on/off?

And lastly, but maybe not most importantly, I've found comments through my searching, including here, that EP25s "work for me." Could this be an issue of firmware version?

You must be logged in to vote

Version 0.6.0 (currently available as dev release, pip install --pre python-kasa) adds support for the new protocol required to control devices with newer hw/fw versions.

Edited on Jan 18, earlier comment was:

Looking at the discovery response, this device is using a different protocol (using AES for encryption) which is not currently supported by this lib.

The homeassistant integration uses this library and the note about support for that model was added to homeassistant docs here: home-assistant/home-assistant.io#28164 so maybe there are different versions of that very same model :-(

Replies: 11 comments · 16 replies

Comment options

Version 0.6.0 (currently available as dev release, pip install --pre python-kasa) adds support for the new protocol required to control devices with newer hw/fw versions.

Edited on Jan 18, earlier comment was:

Looking at the discovery response, this device is using a different protocol (using AES for encryption) which is not currently supported by this lib.

The homeassistant integration uses this library and the note about support for that model was added to homeassistant docs here: home-assistant/home-assistant.io#28164 so maybe there are different versions of that very same model :-(

You must be logged in to vote
0 replies
Answer selected by rytilahti
Comment options

I've bought that EP25P4 (4 pack of EP25s) twice from Amazon (2023-07 and 2022-11). They have basically worked out of the box with home assistant like the earlier KP/HS plugs with energy monitoring. (I stumbled on this issue because I was thinking of buying more during the black Friday deals.)

Do you have a hardware version from either the device or the box?

How did you get to get them connected to the network?

For the first few I used Apple Home on iOS and I think others I tried using either python-kasa or attempted the kasa ios app directly without home kit. I don't remember the specifics at this point.

I found that the setup through the apple process wound up trying to connect the devices to my 5ghz wifi, probably the one my iPhone was using at the time. IIRC there was some other annoyance too with the apple setup like the location didn't get set correctly.

What do you have as a hardware revision?

Mine according to the box are EP25P4 (US) Ver 1.6 (made in Vietnam). The device itself through kasa or python-kasa identifies as hw_ver: 1.0

You must be logged in to vote
0 replies
Comment options

Oh thanks for the prompt comments here! I'd been meaning to get back and mention the hw version. It's showing as Hardware Version: 2.6 in the Kasa app.

Something also worth mentioning is during my ongoing search for answers I found people claiming success when their firmware versions were more recent than mine. This made me optimistic.

Out of curiosity, @rytilahti, is the key indicator of "different protocol" as you say, this key/val: 'encrypt_type': 'AES'? And what was it previously that allowed the device to be supported?

You must be logged in to vote
0 replies
Comment options

And @rct, I previously made quick notes on setup. Posting as pastebin to save space here: https://pastebin.com/2dFEEBrN

You must be logged in to vote
2 replies
@rct
Comment options

@ezekieldas - Looking at your instructions, you are connecting the plug to home assistant using the Apple HomeKit integration rather than the TPLink Kasa Smart integration.

My hardware version 1.0 plugs are discovered by Home Assisant both as an TPLink Kasa device and a HomeKit device. I ignore the HomeKit entry and only use the TPLink Kasa device.

@ezekieldas
Comment options

Initially I tried using TPLink Kasa Smart integration but it repeatedly returned with 'No devices found on the network'

I'm not familiar with HomeKit so it isn't clear to me how it's at least offering power on/off on the devices. However it does make sense that the TPLink Kasa Smart integration would fail due to the encryption issue raised here.

Comment options

@ezekieldas yes, that's a response from a newer discovery protocol that was added in the last release to allow adding support for klap protocol used by some devices (#509). Previously, port 9999 with different payloads was used for discovery.

Would you mind trying to downgrade to the earlier python-kasa version (pip install python-kasa==0.5.3) and try the discover again? Just to make sure that the device does not support both discovery protocols as the current logic sends discovery packets using both protocols, but accepts only the first response. You could also try to communicate with the device without discovery by passing --type to the command line, i.e., kasa --host <addr> --type plug would work for plugs.

You must be logged in to vote
0 replies
Comment options

So using kasa, version 0.5.3 there is no connect at all:

# kasa --debug --host 192.168.1.108
No --type defined, discovering..
Got error: SmartDeviceException("Unable to connect to the device: 192.168.1.108:9999:  Connect call failed ('192.168.1.108', 9999)")

# kasa --host 192.168.1.108 --type plug
Got error: SmartDeviceException("Unable to connect to the device: 192.168.1.108:9999:  Connect call failed ('192.168.1.108', 9999)")

# kasa --debug --host 192.168.1.108 --type plug
DEBUG:kasa.smartdevice:Initializing 192.168.1.108 of type <class 'kasa.smartplug.SmartPlug'>
DEBUG:kasa.smartdevice:Adding module <Module Schedule (schedule) for 192.168.1.108>
DEBUG:kasa.smartdevice:Adding module <Module Usage (schedule) for 192.168.1.108>
DEBUG:kasa.smartdevice:Adding module <Module Antitheft (anti_theft) for 192.168.1.108>
DEBUG:kasa.smartdevice:Adding module <Module Time (time) for 192.168.1.108>
DEBUG:kasa.smartdevice:Adding module <Module Cloud (cnCloud) for 192.168.1.108>
DEBUG:kasa.smartdevice:Performing the initial update to obtain sysinfo
Got error: SmartDeviceException("Unable to connect to the device: 192.168.1.108:9999:  Connect call failed ('192.168.1.108', 9999)")
You must be logged in to vote
2 replies
@rytilahti
Comment options

As I thought it would, thanks for confirmation. Alas, adding support for those is not that simple as it will require figuring out and implementing (at least) the encryption layer to use with these devices. That KLAP PR I linked above adds a new layer of abstraction for different transport protocols, so assuming the devices still use the same commands but encrypted differently, adding a new encryption layer that implements this 'AES' schema would be enough. Friendly ping to @sdb9696 as he might have some ideas on that.

@sdb9696
Comment options

I think this is probably the same encrpytion that TAPO uses as my TAPO device also returns 'mgt_encrypt_schm': {'is_support_https': False, 'encrypt_type': 'AES', 'http_port': 80, 'lv': 2}}.

However I've drafted a quick PR #550 that tries to implement the KLAP lv2 protocol just in case this isn't the same one as TAPO. @ezekieldas you could checkout that PR and then run kasa to see if it discovers your EP25.

Comment options

Hello @sdb9696 and thanks for the PR. Let me know if these steps are correct and whether you need more detail. I'd be happy to provide a packet capture as well.

# git clone https://github.com/sdb9696/python-kasa.git
# cd python-kasa/
# poetry install
# poetry shell

(python-kasa-py3.10) root@proxy03:~/python-kasa# kasa --debug --host 192.168.1.108
No --type defined, discovering..
DEBUG:kasa.discover:[DISCOVERY] ('192.168.1.108', 9999) >> {'system': {'get_sysinfo': None}}
DEBUG:kasa.discover:Waiting a total of 5 seconds for responses...
DEBUG:kasa.discover:[DISCOVERY] Unsupported device found at 192.168.1.108 << {'result': {'device_id': '189b83f8473aaa7c0eef97969beb66ce', 'owner': 'F37BA3A74B8733CC13E954F84B40E1C8', 'device_type': 'SMART.KASAPLUG', 'device_model': 'EP25(US)', 'ip': '192.168.1.108', 'mac': '3C-52-A1-D0-58-DB', 'is_support_iot_cloud': True, 'obd_src': 'apple', 'factory_default': False, 'mgt_encrypt_schm': {'is_support_https': False, 'encrypt_type': 'AES', 'http_port': 80, 'lv': 2}}, 'error_code': 0}
Got error: UnsupportedDeviceException("Unsupported device 192.168.1.108: {'result': {'device_id': '189b83f8473aaa7c0eef97969beb66ce', 'owner': 'F37BA3A74B8733CC13E954F84B40E1C8', 'device_type': 'SMART.KASAPLUG', 'device_model': 'EP25(US)', 'ip': '192.168.1.108', 'mac': '3C-52-A1-D0-58-DB', 'is_support_iot_cloud': True, 'obd_src': 'apple', 'factory_default': False, 'mgt_encrypt_schm': {'is_support_https': False, 'encrypt_type': 'AES', 'http_port': 80, 'lv': 2}}, 'error_code': 0}")
You must be logged in to vote
0 replies
Comment options

I think it would be better to clone python-kasa/python-kasa and checkout the PR there:

git clone https://github.com/python-kasa/python-kasa.git
cd python-kasa
git fetch origin pull/550/head:pull550
git checkout pull550
poetry install
poetry shell

Also please bear in mind that this probably won't work because the 'encrypt_type': 'AES' is not what I expect to work, but it could help inform us of what is needed. Specifically if the device responds with an html string instead of bytes.

N.B. you'll need to pass --username and --password if it is going to work at all.

You must be logged in to vote
0 replies
Comment options

Following those better steps you just posted, here are the results. This shows obfuscated credentials, whereas my actual test involved actual creds.

(python-kasa-py3.10) root@proxy03:~/python-kasa# kasa --debug --host 192.168.1.108 --username "kasa@example.com" --password "allmydata4u"
No --type defined, discovering..
DEBUG:kasa.discover:[DISCOVERY] ('192.168.1.108', 9999) >> {'system': {'get_sysinfo': None}}
DEBUG:kasa.discover:Waiting a total of 5 seconds for responses...
DEBUG:kasa.discover:[DISCOVERY] 192.168.1.108 << {'result': {'device_id': '189b83f8473aaa7c0eef97969beb66ce', 'owner': 'F37BA3A74B8733CC13E954F84B40E1C8', 'device_type': 'SMART.KASAPLUG', 'device_model': 'EP25(US)', 'ip': '192.168.1.108', 'mac': '3C-52-A1-D0-58-DB', 'is_support_iot_cloud': True, 'obd_src': 'apple', 'factory_default': False, 'mgt_encrypt_schm': {'is_support_https': False, 'encrypt_type': 'AES', 'http_port': 80, 'lv': 2}}, 'error_code': 0}
DEBUG:kasa.smartdevice:Initializing 192.168.1.108 of type <class 'kasa.smartplug.SmartPlug'>
DEBUG:kasa.smartdevice:Adding module <Module Schedule (schedule) for 192.168.1.108>
DEBUG:kasa.smartdevice:Adding module <Module Usage (schedule) for 192.168.1.108>
DEBUG:kasa.smartdevice:Adding module <Module Antitheft (anti_theft) for 192.168.1.108>
DEBUG:kasa.smartdevice:Adding module <Module Time (time) for 192.168.1.108>
DEBUG:kasa.smartdevice:Adding module <Module Cloud (cnCloud) for 192.168.1.108>
DEBUG:kasa.klapprotocol:Created KLAP object for 192.168.1.108
DEBUG:kasa.smartdevice:Performing the initial update to obtain sysinfo
DEBUG:kasa.klapprotocol:Starting handshake with 192.168.1.108
DEBUG:httpcore.connection:connect_tcp.started host='192.168.1.108' port=80 local_address=None timeout=5 socket_options=None
DEBUG:httpcore.connection:connect_tcp.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x7f09c2919930>
DEBUG:httpcore.http11:send_request_headers.started request=<Request [b'POST']>
DEBUG:httpcore.http11:send_request_headers.complete
DEBUG:httpcore.http11:send_request_body.started request=<Request [b'POST']>
DEBUG:httpcore.http11:send_request_body.complete
DEBUG:httpcore.http11:receive_response_headers.started request=<Request [b'POST']>
DEBUG:httpcore.http11:receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Server', b'SHIP 2.0'), (b'Content-Length', b'49'), (b'Content-Type', b'text/html')])
DEBUG:httpcore.http11:receive_response_body.started request=<Request [b'POST']>
DEBUG:httpcore.http11:receive_response_body.complete
DEBUG:httpcore.http11:response_closed.started
DEBUG:httpcore.http11:response_closed.complete
DEBUG:kasa.klapprotocol:Handshake1 posted at 2023-11-21 11:17:29.703217. Host is 192.168.1.108, Responsestatus is 200, Request was dc820a48658c7dace651f9dd30d7a62c
DEBUG:kasa.klapprotocol:Handshake1 success at 2023-11-21 11:17:29.703292. Host is 192.168.1.108, Server remote_seed is: 3c68746d6c3e3c626f64793e3c63656e, server hash is: 7465723e323030204f4b3c2f63656e7465723e3c2f626f64793e3c2f68746d6c3e
DEBUG:kasa.klapprotocol:Server response doesn't match our challenge on ip 192.168.1.108
DEBUG:kasa.klapprotocol:Unable to complete handshake for device 192.168.1.108, authentication failed
DEBUG:kasa.klapprotocol:Unable to authenticate with 192.168.1.108, not retrying
Got error: AuthenticationException("Server response doesn't match our challenge on ip 192.168.1.108")
You must be logged in to vote
1 reply
@sdb9696
Comment options

So your device has responded with:
<html><body><center>200 OK</center></body></html> which is what the tplink TAPO plugs do.

This is very odd, especially as some TAPO devices seem to be randomly upgrading to KLAP lv:2 and your device is randomly updated to what looks like the TAPO encryption protocol.

I could try a quick PR with the TAPO handshake but I’m worried it could be very difficult for us to debug with me not having a device with this problem to test with.

Are you able to code and debug in vscode? You could do a simple test with the TAPO library to see if it completes a handshake with your device.

Comment options

I'd be happy to help with this effort however I can. vscode has been on my list for at least a couple of years. I've had a few sessions with it recently and would ultimately prefer to be using it regularly. So I can try, but I may have some beginner questions.

I gave a spin of that tapo lib you noted, and ran the code example. Here are the results (ssid obfuscated):

# python3 tapo.py

Success({'device_id': '803AC804956D1A64C3C2F9858770793521C9B2A3', 'fw_ver': '1.0.1 Build 230614 Rel.150219', 'hw_ver': '2.6', 'type': 'SMART.KASAPLUG', 'model': 'EP25', 'mac': '3C-52-A1-D0-58-DB', 'hw_id': '651A215C54B3520474193575A358E0CC', 'fw_id': '00000000000000000000000000000000', 'oem_id': '1646D188F56641C3AE3B08FFB032AEF9', 'ip': '192.168.1.108', 'time_diff': -480, 'ssid': 'foobar=', 'rssi': -57, 'signal_level': 2, 'auto_off_status': 'off', 'auto_off_remain_time': 0, 'latitude': 0, 'longitude': 0, 'lang': 'en_US', 'avatar': 'plug', 'region': 'America/Los_Angeles', 'specs': '', 'nickname': 'emVlaw==', 'has_set_location_info': False, 'device_on': True, 'on_time': 284093, 'default_states': {'type': 'last_states', 'state': {}}, 'overheated': False, 'power_protection_status': 'normal'})
Success(EnergyInfo(today_runtime=719, month_runtime=5372, today_energy=4127, month_energy=19989, current_power=698260))
Success(PowerInfo(current_power=698))
Failure(Returned error_code: TapoError.INVALID_REQUEST: Invalid request)
Failure(Returned error_code: TapoError.INVALID_REQUEST: Invalid request)
Failure(Returned error_code: TapoError.INVALID_REQUEST: Invalid request)
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f0ff8732920>
You must be logged in to vote
10 replies
@ezekieldas
Comment options

I'm not the expert here but I'd say this looks really promising! I've attached the output here. Let me know if there are other args you'd like to see. I'll be in/out today given the us holiday but keeping an eye on this.
pull552_out.txt

@kohenkatz
Comment options

@sdb9696 @rytilahti I just tested the current master (so including #552 and #557) with a brand new EP25 (Hardware 2.6; Software 1.0.1 Build 230614 Rel.150219), and it works great so far in my testing. Just wanted to give some positive feedback and thanks to all who are working on this!

@ralphpig
Comment options

I can also confirm latest master is working with my EP25 with authentication. I'm also getting emeter data correctly.
I'll look forward to seeing to seeing this in HA

== EP25 ==
  Host: xx.xx.xx.xx
  Port: 20002
  Device state: True
  == Generic information ==
  Hardware:     2.6
  Software:     1.0.1 Build 230614 Rel.150219

  == Device specific information ==
  overheated: False
  signal_level: 3
  auto_off_status: off
  auto_off_remain_time: 0

  == Current State ==
  <EmeterStatus power=197.219 voltage=None current=None total=2.988>

  == Modules ==
  + <Module Emeter (emeter) for xx.xx.xx.xx>

@rodolfosb
Comment options

Same here on multiple EP25 units, only voltage and current seem to be missing.

== Fridge - EP25 ==
Host: REDACTED
Port: 20002
Device state: True
== Generic information ==
Time: REDACTED
Hardware: 2.6
Software: 1.0.1 Build 230614 Rel.150219
MAC (rssi): REDACTED
Location: {'latitude': REDACTED, 'longitude': REDACTED}
== Device specific information ==
overheated: False
signal_level: 2
SSID: REDACTED
On since: 2023-11-22 11:36:36
auto_off_status: off
auto_off_remain_time: 0
== Current State ==

== Modules ==
+ <Module Emeter (emeter) for REDACTED>

@JasonLukose
Comment options

Adding my notes with latest package and EP25 plugs incase anyone needs data or runs into this later:

Installed pre-release package 0.6.0.dev2 and it is able to now show as supported devices that fail to authenticate (without username/password given, see below for full details)

pip show python-kasa
Name: python-kasa
Version: 0.6.0.dev2
Summary: Python API for TP-Link Kasa Smarthome devices
Home-page: https://github.com/python-kasa/python-kasa
Author: python-kasa developers
Author-email:
License: GPL-3.0-or-later

=================================================================
DISCOVER WITH NO USERNAME/PASSWORD

PS C:\Users\jason> kasa discover
Discovering devices on 255.255.255.255 for 3 seconds
== Authentication failed for device ==
        == Discovery Result ==
        Device Type:          SMART.KASAPLUG
        Device Model:         EP25(US)
        IP:                   REDACTED
        MAC:                  REDACTED
        Device Id (hash):     REDACTED
        Owner (hash):         REDACTED
        HW Ver:               None
        Is Support IOT Cloud: True)
        OBD Src:              tplink
        Factory Default:      False
                == Encryption Scheme ==
                Encrypt Type:     AES
                Is Support HTTPS: False
                HTTP Port:        80
                LV (Login Level): 2


== Authentication failed for device ==
        == Discovery Result ==
        Device Type:          SMART.KASAPLUG
        Device Model:         EP25(US)
        IP:                   REDACTED
        MAC:                  REDACTED
        Device Id (hash):     REDACTED
        Owner (hash):         REDACTED
        HW Ver:               None
        Is Support IOT Cloud: True)
        OBD Src:              tplink
        Factory Default:      False
                == Encryption Scheme ==
                Encrypt Type:     AES
                Is Support HTTPS: False
                HTTP Port:        80
                LV (Login Level): 2


Found 0 devices
Found 2 devices that failed to authenticate

=================================================================
WITH USERNAME / PASSWORD FROM KASA, It authenticates properly and is able to receive commands:

PS C:\Users\jason> kasa --username <USERNAME FROM KASA> --password <PASSWORD FROM KASA> discover
Discovering devices on 255.255.255.255 for 3 seconds
== Left Lamp - EP25 ==
        Host: IP_REDACTED
        Port: 80
        Device state: True
        == Generic information ==
        Time:         2024-01-17 19:36:28-08:00 (tz: {'timezone': 'America/Los_Angeles'}
        Hardware:     2.6
        Software:     1.0.2 Build 231108 Rel.163012
        MAC (rssi):   REDACTED(-41)
        Location:     {'latitude': REDACTED, 'longitude': REDACTED}

        == Device specific information ==
        overheated: False
        signal_level: 3
        SSID: REDACTED
        On since: 2024-01-17 19:31:29
        auto_off_status: off
        auto_off_remain_time: 0

        == Current State ==
        <EmeterStatus power=17.855 voltage=None current=None total=0.02>

        == Modules ==
        + <Module Emeter (emeter) for REDACTED>

== Right Lamp - EP25 ==
        Host: IP_REDACTED
        Port: 80
        Device state: True
        == Generic information ==
        Time:         2024-01-17 19:36:28-08:00 (tz: {'timezone': 'America/Los_Angeles'}
        Hardware:     2.6
        Software:     1.0.2 Build 231108 Rel.163012
        MAC (rssi):   REDACTED (-46)
        Location:     {'latitude': REDACTED, 'longitude': REDACTED}

        == Device specific information ==
        overheated: False
        signal_level: 3
        SSID: REDACTED
        On since: 2024-01-17 19:31:30
        auto_off_status: off
        auto_off_remain_time: 0

        == Current State ==
        <EmeterStatus power=93.224 voltage=None current=None total=0.089>

        == Modules ==
        + <Module Emeter (emeter) for REDACTED>
Comment options

Quick question -- once authenticated, can I permanently rely on local control of the newer EP25? Or will Home Assistant eventually require another cloud authentication? Hate having to hook into their cloud...

You must be logged in to vote
1 reply
@rytilahti
Comment options

All communications done by this library are local, so as long as nothing changes it should keep working just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
9 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.