[FREE] Tuya Devices Control Component

The extension allows you to control IoT devices connected to the Tuya cloud service.
Previously, devices must be registered using the Tuya Smart application.

Why is this necessary, you ask? The Tuya Smart application already allows you to control devices, create smart scenarios and connect popular voice assistants.
My answer, for example, if you are tired of saying “OK Google” 25 times a day, and you want to create your own voice assistant to control your smart home. Or you want to combine the management of devices from different manufacturers in one application. Or….
For me, this is just an interesting experiment.
Currently, I have only done basic functions for the main appliances (smart lamp, switch, socket). If the extension is of interest, the functionality can be expanded.

void LoginEmail(String email) - Tuya LogIn Email.
void LoginPassword(String password) - Tuya LogIn Password.

void LogIn() - Logging to account created in the Tuya Smart app. Calling an OperationComplete event

void LoadDevices() - Load online devices connected with the Tuya Smart app. Calling an OperationComplete event

List GetDevicesList() - Get connected Devices names list.

Dictionary GetDeviceParam(String devName) - Get Device parameters. Returns a dictionary with the following keys:
‘name’ - the name you gave the device (all names must be different)
‘dev_type’ - standard device type (‘light’,‘switch’,‘socket’…),
‘id’ - unique id assigned during device registration,
‘state’ - true if the device is ON, false if OFF,
‘icon’ - stores the URL to the device image,
‘brightness’ - 0…100,
‘color_mode’ - ‘white’ or ‘colour’ (for RGB lamp only) ,
‘color_temp’ - 0…100"

boolean IsDeviceOn(String devName) - Device is ON?

void OnOffDevice(String devName, boolean on) - Put ON or OFF device.

String GetOnOffBtnTxt(String devName) - Get text for ON/OFF button.

void SendCmdToDevice(String devName, String cmd, String value) - Send command to device. Calling an OperationComplete event.
Possible commands and values:
cmd= ‘turnOnOff’, value= 1 or 0,
cmd= ‘brightnessSet’, value=0…100 (only for dev_type=‘light’),
cmd= ‘colorTemperatureSet’, value=0…100 (only for dev_type=‘light’).

void OperationComplete(boolean ok, String operation, String message) - This event fires after the call to the web server is completed.
ok=true if the operation was successful,
operation takes a value, depending on the running function:
‘LogIn’,‘LoadDevices’ or ‘DeviceControl’,
message returns ‘SUCCESS’ or error details.

ScTuya.aix (21.1 KB)
ScTuyaTest.aia (31.0 KB)


u can share some demo screenshorts, please add more devices. :pray:

Hi. The attached test project shows an example of using all the functions of the extension.
At the moment, the extension works with lamps, switches and sockets. I have these devices in stock, and I can check their performance. Tell me what specific device you want to add and I’ll see what I can do.
It may be enough to just change the name of the command and the parameter in the SendCmdToDevice function, without making changes to the extension itself.