Skip to the content.

Getting Started

A lightweight and efficient Rust library for controlling Tuya-compatible smart devices.


Rust Installation

Add the following to the Cargo.toml file:

[dependencies]
rustuya = "0.2"

Quick Start (Rust)

Minimal example to control a device from Rust:

use rustuya::sync::Device;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a device handle
    let device = Device::new("DEVICE_ID", "LOCAL_KEY");

    // Set a DP value (e.g., DP 1 to true)
    device.set_value(1, true)?;

    Ok(())
}

Python Installation

Install the package via pip:

pip install rustuya

Quick Start (Python)

Minimal example to control a device from Python:

from rustuya import Device

# Create a device handle
device = Device("DEVICE_ID", "LOCAL_KEY")

# Set a DP value (e.g., DP 1 to true)
device.set_value(1, True)

Next Steps