Skip to content

Tapo H200 Hub does not work with python-kasa #1149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DaveGut opened this issue Oct 3, 2024 · 18 comments
Closed

Tapo H200 Hub does not work with python-kasa #1149

DaveGut opened this issue Oct 3, 2024 · 18 comments
Labels
bug Something isn't working
Milestone

Comments

@DaveGut
Copy link

DaveGut commented Oct 3, 2024

Just a note, not an issue. If someone wonders why the H200 Hub will not work with python-Kasa, I have discovered that the H200 Hub uses the same security protocol as the Tapo Cameras (and is not compatible with python-Kasa). Below is the port 20002 discovery data for the H200 (from one of my Hubitat users). This is the same as on the Tapo Kamera.

POLLRESP:[device_id:69D49ADCBDB15067CAC9F26BD6ZZZZZZ, device_model:H200, device_name:Living Room Tap Hub, device_type:SMART.TAPOHUB, encrypt_info:[data:JnQE4HPv/vlyx7qw4/IGT6sg6wgSgZ1kgK61zbcCQgxnUVpBK0aRMagGBupe3D0sokbtH+LEf+f4lLsWtYawAmmQ2hm6rTZrCrMUJzCZ3scV0LQL2TlhcyyubQbsn4uQnNyLFAwi4uRCvSE4yqP51tngQCPllJTl86RfTyOCq6gILLG3s6FL+bx4XeIKzGtBxoIXy6DsUmnRQqGb7v0/ZhwWZ6aY0M, key:dv+eQ62B3+/cO427K2T1SYWqs5KJo91C49V2tJHSpHav7KKU0e+GZm7UYUXv4oKLxUhxaR3bBU7UCBjBqrY0MwcmJpB01kTOIteIMa5SPt2u0z33m1O9PxuDDm8QoXeAo2XpWfIc5xZQCRTlKS9MGAnV2Yg4T19YInRmlHdrASmm1kZpPUjzT+HXQRNpBcp+TCJOI4UfefELZmEzZiBrDPAJI4BV4o7GBx1+b6ajV7UKrpWs3DZKy7I7vxaBrhxTYJfjSAsrBIZxbTEypItEp6YrJiYq8M+y4Ph2t8SCAdpjTe23pgMzfG/yiwGCv6w8tx7Ud0TD5C5FKANtVzoYrQ==, sym_schm:AES], factory_default:false, firmware_version:1.3.3 Build 20240604 rel.61598, hardware_version:1.0, ip:192.168.1.203, isResetWiFi:false, is_support_iot_cloud:true, mac:A8-42-A1-ZZ-XX-ZZ, mgt_encrypt_schm:[is_support_https:true]]]

Note: encrypt_info.data may be truncated since the Hubitat platform UDP protocol does not support messages longer thant 1024.

@sdb9696
Copy link
Collaborator

sdb9696 commented Oct 11, 2024

Hi @DaveGut, do you know what the discovery query looks like to get this response?

@DaveGut
Copy link
Author

DaveGut commented Oct 11, 2024

It should be the same protocol within the this library, module discovery.py. (I use my own based on the groovy language.) See line 193, 194 then follow the code from there. It is parsed differently since the json details are different *(and VERY similar to the Tapo Camera discovery using same discovery).

I think that without the limits of the Hubitat UDP limitations (1024), you may be able to decrypt the json data element using the sent key and the returned key. the Hubitat UDP implementation only takes one return packet; therefore, truncating the message at 1024 bytes.

The handshake / encryption code is DIFFERENT from in this library (verified by a user not being able to control using the code). I believe that this is a version of the handshake/encryption for the TAPO camera. Some evidence for this - but I do not yet have an H200 to fully validate. That code is in the library "https://github.com/JurajNyiri/pytapo". That code supports devices with both legacy encryption as well as the new encryption scheme (called "secure" in the code block.

H200 will then connect to the new "sub-g" cameras and existing "sub-g" sensors that Tapo is selling (no direct wifi for the camera). It provides a camera local hub and a low-power interface to the camera itself.

@sdb9696
Copy link
Collaborator

sdb9696 commented Oct 11, 2024

That’s really helpful thanks. So I’ve been working on getting the “camera” protocol working, do you have an H200 you can test with when it’s ready?

@SirWaddles
Copy link

I just set up a Home Assistant instance and noticed that the H200 isn't supported, so if there's any way I can help I'd like to. I have a bunch of devices connected to it that I'd like to get data from.

@rytilahti
Copy link
Member

rytilahti commented Oct 14, 2024

@SirWaddles feel free to check out #1165, it implements the protocol spoken by (at least some) cameras and it is apparently the same as what that hub uses as told by DaveGut. You can try to force that transport by passing --device-family SMART.IPCAMERA to your command, so I'd try something like kasa --device-family SMART.IPCAMERA --host <addr> --username <email> --password <pw> and play with command command to see if you can figure out what command set is being used.

@sdb9696
Copy link
Collaborator

sdb9696 commented Oct 14, 2024

Yes, as per @rytilahti, we’re trying to work on this. It would be great to hook up on discord and see if we can test this PR with your H200.

@SirWaddles
Copy link

I may very well be doing something wrong, but I had no such luck. I checked out the PR and ran:

uv run kasa --host 192.168.50.198 --username 00 --password 00 --debug
DEBUG    [DISCOVERY] 192.168.50.198 >> {'system': {'get_sysinfo': {}}}                                   discover.py:228
DEBUG    Waiting a total of 5 seconds for responses...                                                   discover.py:474
Raised error: Timed out getting discovery response for 192.168.50.198
....
File "E:\GitHub\kasa\python-kasa\kasa\discover.py", line 490, in discover_single
    raise TimeoutError(f"Timed out getting discovery response for {host}")
TimeoutError: Timed out getting discovery response for 192.168.50.198

@sdb9696
Copy link
Collaborator

sdb9696 commented Oct 14, 2024

So I have found with the camera that it times out first time on discovery so I just run it again. I’m not completely sure about the options that’ll work out the box for a hub but you may need to add —encrypt-type AES —ssl -df SMART.IPCAMERA but I suspect we need to make some tweaks to make it work with the cli.

@rytilahti
Copy link
Member

rytilahti commented Oct 14, 2024

Does kasa discover (w/o defining --host) work? It would be great to see the response payload, if it's working. Note, that you can also use --debug to see more low-level details on what's being sent and received.

@SirWaddles
Copy link

SirWaddles commented Oct 14, 2024

discover just returns a lot of information on the other devices on the network even though I'm providing a host - none of it even mentions the IP address of the hub.

With the parameters @sdb9696 gave, I get a different result though.

kasa --host 192.168.50.198 --username 00 --password 00 --debug --device-family SMART.IPCAMERA --encrypt-type AES --ssl
DEBUG    Created AES transport for 192.168.50.198                                                 sslaestransport.py:142
DEBUG    Initializing 192.168.50.198 of type <class 'kasa.experimental.smartcamera.SmartCamera'>           device.py:198
DEBUG    192.168.50.198 multi-request-batch-1-of-1 >>                                               smartprotocol.py:185
         '{"method":"multipleRequest","request_time_milis":1728941709858,"terminal_uuid":"9aQzup6WF
         +Kq4VqMrAdNkQ==","params":{"requests":[{"method":"getDeviceInfo","params":{"device_info":{
         "name":["basic_info"]}}}]}}'
DEBUG    Will perform handshaking...                                                              sslaestransport.py:325
DEBUG    Posting to https://192.168.50.198                                                              httpclient.py:87
DEBUG    Device responded with: {'error_code': -40401, 'result': {'data': {'code': -60502}}}      sslaestransport.py:345
WARNING  Device 192.168.50.198 received unknown error code: -40401                                sslaestransport.py:166
DEBUG    Unable to query the device: 192.168.50.198, not retrying: Unable to complete handshake:    smartprotocol.py:145
         192.168.50.198: INTERNAL_UNKNOWN_ERROR(-100000) (error_code=INTERNAL_UNKNOWN_ERROR)
Raised error: Unable to complete handshake: 192.168.50.198: INTERNAL_UNKNOWN_ERROR(-100000)
(error_code=INTERNAL_UNKNOWN_ERROR)

Happy to talk more on Discord.

@sdb9696
Copy link
Collaborator

sdb9696 commented Oct 14, 2024

40401 is something to do with the handshake not completing and the device forcing you to wait for a period of time before it will start handshake again. I think you can reboot it to clear this. My discord username is sdb9696 although I am going to bed now and will check it in the am.

@willis1203
Copy link

When will it be supported the H200 Hub by python-kasa?

@sdb9696
Copy link
Collaborator

sdb9696 commented Nov 22, 2024

It’s supported in the master branch. 0.8 should be released in the coming days. The only problem is we don’t have any examples of the H200 with connected battery cameras. I don’t suppose you have any?

@bomba5
Copy link

bomba5 commented Nov 27, 2024

I have an H200 with a D230S1 Video Doorbell and I am available to test. I can't wait to integrate this to home assistant.

@sdb9696
Copy link
Collaborator

sdb9696 commented Nov 27, 2024

So far we haven't been able to test the H200 with a connected camera device so this would actually be very helpful. Currently it won't show your camera in HA. Are you able to hmu on discord with the same username sdb9696?

@sdb9696
Copy link
Collaborator

sdb9696 commented Nov 29, 2024

@bomba5 ?

@rytilahti
Copy link
Member

@DaveGut the newest release (0.8.0) added support for H200. Could you confirm if it is now working for you, and close this issue, if so?

@rytilahti rytilahti added the bug Something isn't working label Dec 1, 2024
@rytilahti rytilahti added this to the 0.9.0 milestone Dec 12, 2024
@sdb9696
Copy link
Collaborator

sdb9696 commented Dec 17, 2024

H200 hub now supported

@sdb9696 sdb9696 closed this as completed Dec 17, 2024
@sdb9696 sdb9696 mentioned this issue Dec 21, 2024
sdb9696 added a commit that referenced this issue Dec 21, 2024
## [0.9.0](https://github.com/python-kasa/python-kasa/tree/0.9.0) (2024-12-21)

[Full Changelog](0.8.1...0.9.0)

**Release highlights:**

- Improvements to Tapo camera support:
  - C100, C225, C325WB, C520WS and TC70 now supported.
  - Support for motion, person, tamper, and baby cry detection.
- Initial support for Tapo robovacs.
- API extended with `FeatureAttributes` for consumers to test for [supported features](https://python-kasa.readthedocs.io/en/stable/topics.html#modules-and-features).
- Experimental support for Kasa cameras[^1]

[^1]: Currently limited to devices not yet provisioned via the Tapo app - Many thanks to @Puxtril!

**Breaking changes:**

- Use DeviceInfo consistently across devices [\#1338](#1338) (@sdb9696)

**Implemented enhancements:**

- Add rssi and signal\_level to smartcam [\#1392](#1392) (@sdb9696)
- Add smartcam detection modules [\#1389](#1389) (@sdb9696)
- Add bare-bones matter modules to smart and smartcam devices [\#1371](#1371) (@sdb9696)
- Add bare bones homekit modules smart and smartcam devices [\#1370](#1370) (@sdb9696)
- Return raw discovery result in cli discover raw [\#1342](#1342) (@sdb9696)
- cli: print model, https, and lv for discover list [\#1339](#1339) (@rytilahti)
- Improve overheat reporting [\#1335](#1335) (@rytilahti)
- Provide alternative camera urls [\#1316](#1316) (@sdb9696)
- Add LinkieTransportV2 and basic IOT.IPCAMERA support [\#1270](#1270) (@Puxtril)
- Add ssltransport for robovacs [\#943](#943) (@rytilahti)

**Fixed bugs:**

- Tapo H200 Hub does not work with python-kasa [\#1149](#1149)
- Treat smartcam 500 errors after handshake as retryable [\#1395](#1395) (@sdb9696)
- Fix lens mask required component and state [\#1386](#1386) (@sdb9696)
- Add LensMask module to smartcam [\#1385](#1385) (@sdb9696)
- Do not error when accessing smart device\_type before update [\#1319](#1319) (@sdb9696)
- Fallback to other module data on get\_energy\_usage errors [\#1245](#1245) (@rytilahti)

**Added support for devices:**

- Add P210M\(US\) 1.0 1.0.3 fixture [\#1399](#1399) (@sdb9696)
- Add C225\(US\) 2.0 1.0.11 fixture [\#1398](#1398) (@sdb9696)
- Add P306\(US\) 1.0 1.1.2 fixture [\#1396](#1396) (@nakanaela)
- Add TC70 3.0 1.3.11 fixture [\#1390](#1390) (@sdb9696)
- Add C325WB\(EU\) 1.0 1.1.17 Fixture [\#1379](#1379) (@sdb9696)
- Add C100 4.0 1.3.14 Fixture [\#1378](#1378) (@sdb9696)
- Add KS200 \(US\) IOT Fixture and P115 \(US\) Smart Fixture [\#1355](#1355) (@ZeliardM)
- Add C520WS camera fixture [\#1352](#1352) (@Happy-Cadaver)

**Documentation updates:**

- Update docs for Tapo Lab Third-Party compatibility [\#1380](#1380) (@sdb9696)
- Add homebridge-kasa-python link to README [\#1367](#1367) (@rytilahti)
- Update docs for new FeatureAttribute behaviour [\#1365](#1365) (@sdb9696)
- Add link to related homeassistant-tapo-control [\#1333](#1333) (@rytilahti)

**Project maintenance:**

- Add P135 1.0 1.2.0 fixture [\#1397](#1397) (@sdb9696)
- Handle smartcam device blocked response [\#1393](#1393) (@sdb9696)
- Handle KeyboardInterrupts in the cli better [\#1391](#1391) (@sdb9696)
- Update C520WS fixture with new methods [\#1384](#1384) (@sdb9696)
- Miscellaneous minor fixes to dump\_devinfo [\#1382](#1382) (@sdb9696)
- Add timeout parameter to dump\_devinfo [\#1381](#1381) (@sdb9696)
- Simplify get\_protocol to prevent clashes with smartcam and robovac [\#1377](#1377) (@sdb9696)
- Add smartcam modules to package inits [\#1376](#1376) (@sdb9696)
- Enable saving of fixture files without git clone [\#1375](#1375) (@sdb9696)
- Force single for some smartcam requests [\#1374](#1374) (@sdb9696)
- Add new methods to dump\_devinfo [\#1373](#1373) (@sdb9696)
- Update cli, light modules, and docs to use FeatureAttributes [\#1364](#1364) (@sdb9696)
- Pass raw components to SmartChildDevice init [\#1363](#1363) (@sdb9696)
- Fix line endings in device\_fixtures.py [\#1361](#1361) (@sdb9696)
- Update dump\_devinfo for raw discovery json and common redactors [\#1358](#1358) (@sdb9696)
- Tweak RELEASING.md instructions for patch releases [\#1347](#1347) (@sdb9696)
- Scrub more vacuum keys [\#1328](#1328) (@rytilahti)
- Remove unnecessary check for python \<3.10 [\#1326](#1326) (@rytilahti)
- Add vacuum component queries to dump\_devinfo [\#1320](#1320) (@rytilahti)
- Handle missing mgt\_encryption\_schm in discovery [\#1318](#1318) (@sdb9696)
- Follow main package structure for tests [\#1317](#1317) (@rytilahti)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants