Skip to main content

Connect DuckyClaw to TuyaClaw

1. Overviewโ€‹

DuckyClaw is an AI voice assistant firmware that runs on IoT devices. It connects to the TuyaClaw Gateway via the ACP protocol (Agent Client Protocol, WebSocket-based) to enable real-time conversation with an AI Agent.

TuyaClaw is Tuya's AI Agent desktop client, available for Windows, macOS, and Linux. It includes the OpenClaw core and exposes a Gateway service (default port 18789) that DuckyClaw connects to.

Connection architecture:

DuckyClaw (IoT device)
โ”‚ WebSocket (ACP protocol)
โ–ผ
TuyaClaw Gateway (PC)
โ”‚ Built-in OpenClaw core
โ–ผ
AI Agent (LLM conversation)

TuyaClaw architecture:

LayerDescription
Electron shellTuyaClaw application; Chromium renderer hosts the UI
OpenClaw coreLocated at resources/openclaw/ in the install directory; identical to open-source OpenClaw
Gateway serviceBuilt-in ACP WebSocket Server, default port 18789
Config directory~/.tuyaclaw/ (Linux / macOS) or C:\Users\<username>\.tuyaclaw\ (Windows)

2. Prerequisitesโ€‹

2.1 Softwareโ€‹

SoftwareDescriptionDownload
TuyaClawAI Agent platform (Windows / macOS / Linux) โ€” must be installed and runningOfficial website
DuckyClaw firmware toolchainRequired to compile and flash DuckyClaw firmwareSee DuckyClaw Quick Start

2.2 Network requirementsโ€‹

  • DuckyClaw device and the PC running TuyaClaw must be on the same LAN or Wi-Fi network
  • For internet connectivity, expose the TuyaClaw Gateway via port forwarding or similar

2.3 DuckyClaw base setupโ€‹

Complete the DuckyClaw base setup (Wi-Fi, firmware flashing) before following this guide.


3. TuyaClaw configuration file locationโ€‹

The core configuration file is openclaw.json. Its default path depends on the operating system:

OSConfig file path
Linux~/.tuyaclaw/openclaw.json
macOS~/.tuyaclaw/openclaw.json
WindowsC:\Users\<username>\.tuyaclaw\openclaw.json
note

~ refers to the current user's home directory, e.g. /home/username (Linux) or /Users/username (macOS). On Windows replace <username> with your login name.

TuyaClaw also has an Electron settings file that stores the Token for the UI:

OSElectron settings path
Linux~/.config/tuyaclaw/settings.json
macOS~/Library/Application Support/tuyaclaw/settings.json
WindowsC:\Users\<username>\AppData\Roaming\tuyaclaw\settings.json

Quick-open the config folder:

Terminal:

xdg-open ~/.tuyaclaw

File manager:

Open your file manager, press Ctrl+L, type ~/.tuyaclaw, and press Enter.

tip

.tuyaclaw is a hidden folder (starts with .). Press Ctrl+H to show hidden files.


4. Modify the TuyaClaw Gateway configurationโ€‹

4.1 Back up the config fileโ€‹

cp ~/.tuyaclaw/openclaw.json ~/.tuyaclaw/openclaw.json.backup

4.2 Edit the config fileโ€‹

Terminal:

nano ~/.tuyaclaw/openclaw.json

File manager:

  1. Open the ~/.tuyaclaw folder (see Section 3)
  2. Right-click openclaw.json โ†’ Open with Text Editor

4.3 Update the Gateway config sectionโ€‹

Find the "gateway" field and replace it with the following (leave all other settings unchanged):

"gateway": {
"port": 18789,
"mode": "local",
"bind": "lan",
"auth": {
"mode": "token",
"token": "your_token_here"
},
"controlUi": {
"dangerouslyAllowHostHeaderOriginFallback": true,
"allowInsecureAuth": true,
"dangerouslyDisableDeviceAuth": true
}
}
warning

Keep the "token" field's existing value. Do not write your_token_here literally โ€” replace it with your actual token (see Section 5.2).

Field descriptions:

FieldDescription
"bind": "lan"Makes the Gateway listen on the LAN network interface instead of only 127.0.0.1 โ€” required for DuckyClaw to connect
dangerouslyAllowHostHeaderOriginFallback: trueAllows non-UI clients (e.g. IoT devices) to open WebSocket connections
allowInsecureAuth: trueAllows authentication without HTTPS (LAN scenario)
dangerouslyDisableDeviceAuth: trueDisables device-level secondary authentication; token-only auth

4.4 Restart the TuyaClaw Gatewayโ€‹

After saving the config, restart the Gateway for changes to take effect.

Built-in CLI:

~/.config/tuyaclaw/resources/cli/openclaw gateway restart

Or: Right-click the TuyaClaw tray icon โ†’ Quit, then relaunch TuyaClaw.


5. Get the IP address and Tokenโ€‹

5.1 Get the LAN IP addressโ€‹

ip addr show | grep -E "inet " | awk '{print $2}' | cut -d'/' -f1 | grep -v "^127"

Or:

hostname -I
tip

Use the IP address on the same LAN segment as your DuckyClaw device (typically 192.168.x.x or 10.x.x.x). A wired Ethernet connection is more stable than Wi-Fi.

5.2 Get the Gateway Tokenโ€‹

grep '"token"' ~/.tuyaclaw/openclaw.json

Or read the exact value:

python3 -c "import json; d=json.load(open('$HOME/.tuyaclaw/openclaw.json')); print(d['gateway']['auth']['token'])"

5.3 Verify Gateway accessibilityโ€‹

Open a browser on a device on the same network as DuckyClaw and visit:

http://<your-LAN-IP>:18789/

Any HTTP response (even an error page) means the Gateway is listening on the LAN address. If the connection times out, check your firewall (see Section 7.3).


6. Configure DuckyClaw firmwareโ€‹

6.1 Create the config fileโ€‹

In the DuckyClaw project root directory, copy and rename the example file:

cp include/tuya_app_config_secrets.h.example include/tuya_app_config_secrets.h
note

tuya_app_config_secrets.h is listed in .gitignore and will not be committed to version control. It is the recommended place to store sensitive configuration.

6.2 Edit the config fileโ€‹

Open include/tuya_app_config_secrets.h and fill in the ACP Gateway macros:

/* openclaw / tuyaclaw gateway configuration */
#define OPENCLAW_GATEWAY_HOST "xxx.xxx.xxx.xxx" /* Replace with TuyaClaw host LAN IP */
#define OPENCLAW_GATEWAY_PORT 18789
#define OPENCLAW_GATEWAY_TOKEN "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" /* Replace with Token from Section 5.2 */
#define DUCKYCLAW_DEVICE_ID "duckyclaw-001" /* Device ID, customizable */

Field descriptions:

MacroDescription
OPENCLAW_GATEWAY_HOSTLAN IP of the machine running TuyaClaw (from Section 5.1)
OPENCLAW_GATEWAY_PORTFixed at 18789, no change needed
OPENCLAW_GATEWAY_TOKENToken from Section 5.2
DUCKYCLAW_DEVICE_IDDevice name; use a unique identifier (e.g. MAC address) to distinguish multiple devices in TuyaClaw

6.3 Recompile and flashโ€‹

After saving the config, recompile the firmware and flash it to the DuckyClaw device.


7. Troubleshootingโ€‹

7.1 DuckyClaw cannot connectโ€‹

Error in device logLikely causeFix
acp tcp connect failedIP unreachable or port blockedCheck IP; verify port 18789 is allowed in the firewall
acp upgrade rejectedWebSocket handshake rejected by GatewayConfirm dangerouslyAllowHostHeaderOriginFallback: true is set and Gateway restarted
acp connect res ok=falseToken mismatchVerify openclaw.json Token matches firmware OPENCLAW_GATEWAY_TOKEN exactly
acp connect timeoutNetwork issue or Gateway not runningConfirm TuyaClaw is running; visit http://<IP>:18789/ in a browser
acp dns resolve failedHostname cannot be resolvedUse an IP address instead of a hostname

7.2 Verify Gateway is bound to the LAN addressโ€‹

netstat -tlnp | grep 18789
# or
ss -tlnp | grep 18789

If Local Address shows 0.0.0.0:18789, the Gateway is successfully bound to all interfaces including the LAN.

If it shows 127.0.0.1:18789, bind: lan has not taken effect โ€” re-check the openclaw.json edit and restart TuyaClaw.

7.3 Open port 18789 in the firewallโ€‹

ufw:

sudo ufw allow 18789/tcp

firewalld:

sudo firewall-cmd --add-port=18789/tcp --permanent
sudo firewall-cmd --reload

7.4 Config changes not taking effectโ€‹

  • Confirm you edited the correct openclaw.json file (see Section 3 for the path)
  • Confirm the JSON is valid โ€” use an online JSON validator if needed
  • Confirm you fully restarted the Gateway (quit the TuyaClaw process and relaunch, do not just refresh the page)

7.5 Differences from connecting to OpenClaw directlyโ€‹

ItemOpenClawTuyaClaw
Supported OSLinux / macOS / WindowsLinux / macOS / Windows
Core config file~/.openclaw/openclaw.json~/.tuyaclaw/openclaw.json
Default Gateway bindinglocal (change to lan)local (change to lan)
Port1878918789 (same)
Get Tokengrep '"token"' ~/.openclaw/openclaw.jsongrep '"token"' ~/.tuyaclaw/openclaw.json
Restart Gatewayopenclaw gateway restartTuyaClaw UI or built-in CLI
DuckyClaw firmware configSame macrosSame macros