Skip to content

Add Tapo cloud device support alongside Kasa#112

Merged
piekstra merged 2 commits intomainfrom
piekstra/tapo-cloud-support
Feb 8, 2026
Merged

Add Tapo cloud device support alongside Kasa#112
piekstra merged 2 commits intomainfrom
piekstra/tapo-cloud-support

Conversation

@piekstra
Copy link
Owner

@piekstra piekstra commented Feb 8, 2026

Summary

Expand the library to support TP-Link Tapo devices by authenticating against both the Kasa and Tapo cloud APIs. Both clouds use the same V2 HMAC-SHA1 signing protocol but with different hosts, signing keys, app identifiers, and passthrough URL formats.

  • Unified device listing: get_devices() now returns both Kasa and Tapo devices with cloud_type attribute for identification
  • Dual-cloud auth: TPLinkDeviceManager logs into both Kasa (n-wap.tplinkcloud.com) and Tapo (n-wap.i.tplinkcloud.com) clouds with the same credentials
  • Tapo V2 passthrough: Tapo devices use /api/v2/common/passthrough with a flat {deviceId, requestData} body (vs Kasa's {"method":"passthrough","params":{...}} wrapper)
  • Deduplication: Devices appearing in both clouds are only listed once (Kasa version takes priority)
  • Backward compatible: New include_tapo parameter defaults to True; existing code works unchanged

Technical details (from Tapo APK reverse engineering)

Aspect Kasa Tapo
Cloud host n-wap.tplinkcloud.com n-wap.i.tplinkcloud.com
App type Kasa_Android_Mix TP-Link_Tapo_Android
Passthrough URL POST / with method wrapper POST /api/v2/common/passthrough flat
Signing algorithm HMAC-SHA1 (same) HMAC-SHA1 (same)
Auth flow V2 (same) V2 (same)

Files changed

  • signing.py — Configurable signing keys (Kasa + Tapo constants)
  • client.py — Dual-cloud support with separate host/keys/appType per cloud
  • device_client.py — V2 passthrough format for Tapo devices
  • device_info.pycloud_type tracking
  • device_manager.py — Dual login, merged device listing, deduplication
  • test_tapo_devices.py — 12 new tests across 4 test classes
  • 8 new wiremock stubs for Tapo API mocking

Test plan

  • All 93 tests pass (81 existing + 12 new Tapo tests)
  • Tapo devices listed alongside Kasa with correct cloud_type
  • Tapo auth tokens set on login
  • include_tapo=False excludes Tapo devices
  • Device deduplication works across clouds
  • Tapo V2 passthrough returns sys_info correctly
  • Manual test with real Tapo devices (no hardware available — best effort)

Support TP-Link Tapo devices by authenticating against both the Kasa
and Tapo cloud APIs in parallel. Both use the same V2 HMAC-SHA1
signing protocol but with different host, signing keys, and app
identifiers (discovered via Tapo APK reverse engineering).

Key changes:
- signing.py: Add Tapo signing keys, make functions accept configurable keys
- client.py: Support dual cloud types with separate host/keys/appType
- device_client.py: Handle Tapo V2 passthrough format (/api/v2/common/passthrough)
- device_info.py: Track which cloud a device belongs to (cloud_type)
- device_manager.py: Login to both clouds, merge device lists with deduplication
- New include_tapo parameter (default True) on TPLinkDeviceManager

Tapo cloud differences from Kasa:
- Host: n-wap.i.tplinkcloud.com (vs n-wap.tplinkcloud.com)
- Passthrough: POST /api/v2/common/passthrough with flat body
- App type: TP-Link_Tapo_Android
Add documentation for the new dual-cloud architecture, Tapo device
compatibility list, cloud_type attribute, and include_tapo parameter.
@piekstra piekstra merged commit de39034 into main Feb 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant