Back to the store
Plugin

Tuya Control

by Maciej Kaczmarek

allows control tuya devices via cloud and lan

Code

Tuya Control - Macro Deck 3 Plugin

A Macro Deck 3 out-of-process plugin for controlling Tuya smart home devices over your local network (LAN) with optional cloud fallback. Built on the Macro Deck 3 plugin SDK.

What This Plugin Does

Tuya Control lets you create Macro Deck buttons that control Tuya-based smart home devices (lights, switches, plugs, dimmers, and more) directly from your Macro Deck setup. It communicates with devices on your local network using the Tuya LAN protocol (versions 3.3, 3.4, and 3.5), with an optional Tuya cloud connection for devices that are not on your local network.

Features

Local LAN control - Direct communication with Tuya devices on your network (protocol 3.3, 3.4, 3.5) with low latency Cloud fallback - Optional Tuya cloud account for controlling devices remotely or devices that do not support local control Device discovery - UDP beacon listener to find device IP addresses and protocol versions on your network Multiple action types - Toggle, set state, or send custom commands Secure credential storage - Cloud credentials are stored in Macro Deck's encrypted secret store Configuration flow - Guided setup through Macro Deck's config flow UI

Requirements

Macro Deck 3 desktop app (version 3.0.0 or later) Tuya smart home devices on your local network (Optional) Tuya IoT Platform account for cloud features

Configuration

The plugin uses Macro Deck's config flow. You will need to configure:

1. Tuya Cloud Account (Optional)

Only needed if you want cloud fallback or cloud-only devices.

If you used a plugin build that included bundled Tuya credentials, revoke and rotate that Client Secret in the Tuya IoT Platform before continuing. Removing the source file or rewriting Git history does not revoke an exposed credential.

Go to iot.tuya.com and create a Cloud project Navigate to Cloud → Development → Your Project → Overview Copy your Access ID (Client ID) and Access Secret (Client Secret) In Macro Deck, open the Tuya Control config flow and select Tuya cloud account (login) Fill in your region, country code, username, password, app type, and credentials

2. Add Devices

For each device you want to control:

Open the Tuya Control config flow and select A device Choose a source: Pick from the Tuya cloud - Select from your cloud device list (requires cloud account setup first) Enter manually - Type the device ID, name, and local key yourself Enter the network details: IP address - The device's IP on your local network Protocol version - 3.3, 3.4, 3.5, or "Cloud (no LAN)"

Finding Your Device Information

Device ID - Found in the Tuya Smart / Smart Life app under device settings Local key - Found in the Tuya IoT Platform under your cloud project's device list, or from the Tuya Smart app IP address - Your router's DHCP client list, or use the Detect device (UDP) action to find it Protocol version - Use the Detect device (UDP) action to detect it

Available Actions

Toggle Switch

Reads the current state of a switch DP and sends the opposite value (on to off, or off to on).

Parameter Description Device Pick from your configured devices DP code The data point code (default: switch1)

Set Switch State

Sends a fixed ON or OFF value for a DP code, regardless of the current state.

Parameter Description Device Pick from your configured devices DP code The data point code (default: switch1) State (on) Toggle: true for ON, false for OFF

Send Custom Command

Sends any DP code and value pair. Useful for dimmers, color controls, modes, or any DP not covered by the other actions.

Parameter Description Device Pick from your configured devices DP code The data point code to send Value type Boolean, Integer, or Text Value The value to send

Detect Device (UDP)

Listens for 15 seconds for a device's Tuya LAN broadcast beacon to discover its current IP address and protocol version. Shows the result as a notification.

Parameter Description Device Pick from your configured devices

Variables

Variable Type Description tuyastate Boolean The on/off state of the first non-cloud device (refreshes every 5 seconds)

README badge

Paste this into your README so people can open this page in the Macro Deck Store.