Repository navigation
Protocol Tuya
stephan-xyz edited this page Sep 13, 2026
·
1 revision
Tuya is one of the largest IoT ecosystems worldwide, powering thousands of white-label brands (such as LSC Smart Connect, Nedis, Calex, Woox, Moes, and generic Smart Life devices).
- Ecosystem: Tuya Smart / Smart Life / LSC Smart Connect
-
HomeNode Module:
modules/tuya(homenode-module-tuya) -
Transport:
-
Local LAN: TCP port
6668(Tuya Local encrypted protocol) -
Cloud API: HTTPS REST (Tuya OpenAPI
openapi.tuyaeu.com)
-
Local LAN: TCP port
-
Encryption: AES-128 (ECB/CBC) with pre-shared 16-byte
local_key
Unlike pure cloud systems, most Tuya Wi-Fi devices run a local TCP server on port 6668 (and historically 6667). Once registered with an IP address, devices accept local connections without accessing the Tuya Cloud.
- Tuya 3.1 & 3.3: Uses AES-128-ECB or AES-128-CBC encryption.
- Tuya 3.4 & 3.5: Enhanced security with session negotiation and HMAC-SHA256 authentication.
Tuya devices structure their state around numeric DP IDs:
- For Micro Solar Converters / Inverters (e.g., LSC Smart Connect):
- Current PV Wattage (
$W$ ) - Daily energy yield (
$kWh$ ) - Total lifetime yield (
$kWh$ ) - AC voltage (
$V$ ) and frequency ($Hz$ )
- Current PV Wattage (
- For Smart Plugs / Relays:
-
DP 1: Switch (true/false) -
DP 18: Current ($mA$ ) -
DP 19: Power ($0.1 W$ ) -
DP 20: Voltage ($0.1 V$ )
-
To establish a local encrypted TCP session to a Tuya device on port 6668, two parameters are required:
-
Virtual ID (
device_id): A 20–22 alphanumeric character string assigned during device commissioning (visible in the manufacturer app under Device Information). -
Local Key (
local_key): A 16-byte secret key assigned to the device by Tuya's provisioning server.
HomeNode supports three acquisition paths:
-
Home Assistant Extraction:
- If the device is connected via Home Assistant's Tuya integration, the
local_keyis stored in.storage/core.config_entriesand can be imported into HomeNode.
- If the device is connected via Home Assistant's Tuya integration, the
-
mHomeNode iOS Companion App:
- The user scans the Tuya authorization QR code or logs into Tuya within the iOS app.
- The iOS app fetches the device list and
local_keys via Tuya OpenAPI and syncs them securely to HomeNode Server.
-
Tuya Cloud Developer Credentials:
- User configures
client_idandsecretinconfig/modules/tuya.toml, allowing HomeNode to poll keys directly.
- User configures
(c) Stephan Zehrer 2025