Multi-Device Management Usage
The multi-device management capability is built on SmartDevicesManager and the extended SdmProvider, enabling management of multiple device instances within a single MiniApp — including reading their state and sending commands independently.
Relationship with Smart Group Model
Smart Group Model (SGM) is for group devices manually created through the Tuya App on a device detail page. The group panel is allocated by the Tuya cloud, and developers integrate via SmartGroupModel — its behavior is consistent with a single-device panel.
Multi-Device Management is fundamentally different: it does not depend on the cloud-side group concept. Instead, it lets you freely manage multiple independent device instances within the MiniApp — you can add / batchAdd any device IDs at any time, and read each device's DP state or send commands independently via multi-device Hooks. Typical use cases include gateway sub-device batch control pages and multi-device linkage panels.
Relationship with Single Device
- Single device: Use Smart Device Model (SDM) with
SdmProvider value={singleDevice}foruseProps,useDevice,useActions, etc. - Multi-Device Management: Inject
SmartDevicesManagerviaSdmProvider'sdeviceManagerand use multi-device Hooks:useDevices,useDevicesProps,useDevicesActions, etc. See Multi-Device Management - Hooks. For TypeScript type inference and more, see FAQ.
SdmProvider Multi-Device Setup
In multi-device mode, pass a deviceManager (SmartDevicesManager instance) to the root provider. Use isNeedMainDeviceInitialized and isNeedAllDevicesInitialized to control when to render children after initialization.
With isNeedAllDevicesInitialized={true}, SdmProvider waits until all added devices are initialized before rendering children. With false, children render immediately. Enable this when the device list is known upfront; set to false when the number of devices is dynamic.
Typical Scenarios
Scenario 1: All device IDs available at launch
Suitable for gateway sub-device batch control pages — call batchAdd at launch:
Scenario 2: Main device first, sub-devices loaded asynchronously
Initialize the main device separately and pass it via value; add sub-devices via add / batchAdd asynchronously:
For API details, see Multi-Device Management - API (add, delete, batchAdd, batchDelete).