| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
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:
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? |
|
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:
|
|
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 |
|
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? |
|
And @rct, I previously made quick notes on setup. Posting as pastebin to save space here: https://pastebin.com/2dFEEBrN |
|
@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. |
|
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)")
|
|
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}")
|
|
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. |
|
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")
|
|
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>
|
|
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... |
| Back | FazBrowse Home | New Git URL |
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: