Skip to the content.

Python API Reference

This document provides a detailed reference for the rustuya Python bindings.

For practical code examples, see the Python Examples page.


1. System Optimization

To handle high-concurrency environments with many device connections, use this utility.

maximize_fd_limit()


2. Device API

Direct interaction and control for individual Tuya devices.

Device()

device.status()

device.set_value()

device.set_dps()

device.request()

device.listener()

unified_listener()


3. SubDevice API

Interaction with sub-devices (endpoints) through a parent Gateway Device. Obtained via device.sub(cid).

device.sub()

sub_device.status() / set_value() / set_dps()


4. Discovery (Scanner)

Search for devices on the local network.

Scanner.scan()

Scanner.scan_stream()


5. Thread Safety

The rustuya Python API is fully thread-safe. All core objects—Device, SubDevice, and Scanner—are designed to be shared across multiple threads without additional locking in Python.