Synchronize devices or rooms
Function prototype |
OPERATE_RET tuya_ctrl_center_sync() |
Function description |
Synchronize the device and room information. |
Parameter |
VOID |
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
This interface only synchronizes the device and room information, which generally works together with the scene synchronization interface tuya_scene_sync . |
Get the device list
Function prototype |
OPERATE_RET tuya_get_dev_brief_info_list(OUT TUYA_DEV_BRIEF_INFO_S **pp_list, OUT UINT_T *p_cnt) |
Function description |
Get the device list. |
Parameter |
- Output parameter
pp_list : The device list.p_cnt : The number of device lists.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
Call tuya_dev_brief_info_list_free to free the resources. |
Example
TUYA_DEV_BRIEF_INFO_S* dev_list;
UINT_T dev_count = 0;
OPERATE_RET result = tuya_get_dev_brief_info_list(&dev_list, &dev_count);
if (OPRT_OK != result) {
PR_ERR("tuya_get_dev_brief_info_list failed %d", result);
return OPRT_COM_ERROR;
}
Free the device list
Function prototype |
OPERATE_RET tuya_dev_brief_info_list_free(IN TUYA_DEV_BRIEF_INFO_S *p_list, IN UINT_T *p_cnt) |
Function description |
Free the device list |
Parameter |
- Request parameter
p_list : The device list.p_cnt : The number of device lists.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
- |
Get the room list
Function prototype |
OPERATE_RET tuya_get_room_info_list(OUT TUYA_ROOM_INFO_S **pp_list, OUT UINT_T *p_cnt) |
Function description |
Get the room list. |
Parameter |
- Output parameter
pp_list : The room list.p_cnt : The number of room lists.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
Call tuya_room_info_list_free to free resources. |
Example
int result;
UINT_T room_count = 0;
TUYA_ROOM_INFO_S *room_list;
result = tuya_get_room_info_list(&room_list, &room_count);
if (OPRT_OK != result) {
PR_ERR("tuya_get_room_info_list failed %d", result);
return OPRT_COM_ERROR;
}
if (home->room_list && home->room_count) {
tuya_room_info_list_free(home->room_list, home->room_count);
}
home->room_list = room_list;
home->room_count = room_count;
Free the room list
Function prototype |
OPERATE_RET tuya_room_info_list_free(IN TUYA_ROOM_INFO_S *p_list, IN UINT_T cnt) |
Function description |
Free the room list. |
Parameter |
- Request parameter
p_list : The room list.cnt : The number of room lists.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
- |
Example
if (home->room_list && home->room_count) {
tuya_room_info_list_free(home->room_list, home->room_count);
}
Turn on the specified device
Function prototype |
TY_HOME_CTRL_DEV_T tuya_home_ctrl_dev_open(IN CONST CHAR_T* dev_id, IN CONST TY_HOME_CTRL_DEV_CB* dev_cb) |
Function description |
Turn on the specified device. |
Parameter |
- Request parameter
dev_id : The device ID.report_cb : The data reporting callback.
|
Return value |
TY_HOME_CTRL_DEV_T : The device descriptor. |
Detailed description |
Call tuya_home_ctrl_dev_close to turn off the device. |
Example
void callback_fun(const TY_HOME_CTRL_DEV_DP_S* dp, void* user_arg)
{
DEV_INFO *dev_info = (DEV_INFO *)user_arg;
printf("dev_id:%s", dev_info->dev_id);
bool_value = true;
tuya_home_ctrl_dev_set_dp_value(dev_info->dev_des, HOME_CTRL_SWITCH_SWITCH_INDEX(1), PROP_BOOL,
(TY_HOME_CTRL_DEV_DP_VALUE_U *)(&bool_value));
}
typedef struct {
char *dev_id;
TY_HOME_CTRL_DEV_T dev_des;
} DEV_INFO;
DEV_INFO dev[255];
void __dps_update_fun(void *user_arg)
{
tuya_home_ctrl_dev_close(dev_des);
tuya_home_ctrl_dev_open[dev_des], &dev_cb);
}
TY_HOME_CTRL_DEV_CB dev_cb = {0};
dev_cb.report_cb.function = __dp_callback_fun;
dev_cb.dev_online_cb.function = __dev_online_cb;
dev_cb.dp_name_update_cb.function = __dp_name_fun;
dev_cb.dps_update_cb.function = __dps_update_fun;
for (int i = 0; i < sizeof(dev) / sizeof(dev[0]; i++) {
dev_cb.report_cb.user_arg = &(dev[i]);
dev[i].dev_des = tuya_home_ctrl_dev_open[dev[i].dev_id], &dev_cb);
}
For v3.4.2 and later, open
supports multiple instances. Opening
the same dev_id
multiple times returns multiple handles that point to the same memory partition. The memory can be freed only when all the handles of this dev_id
are closed
. Versions earlier than v3.4.2 only support a single instance. Opening
the same dev_id
returns the same handle. Adapt your code if needed.
Turn off the specified device
Function prototype |
OPERATE_RET tuya_home_ctrl_dev_close(IN TY_HOME_CTRL_DEV_T dev_des) |
Function description |
Turn off the specified device. |
Parameter |
- Request parameter
dev_des : The device descriptor.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
- |
Get all the data points (DPs) of the device
Function prototype |
OPERATE_RET tuya_home_ctrl_dev_get_all_dp(IN CONST TY_HOME_CTRL_DEV_T dev_des, OUT BYTE_T* dp_num, OUT TY_HOME_CTRL_DEV_DP_S** dp_sets) |
Function description |
Get all the data points (DPs) of the device. |
Parameter |
- Request parameter
dev_des : The device descriptor.
- Output parameter
dp_num : The number of DPs.dp_sets : The collection of DPs.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
- |
Example
TY_HOME_CTRL_DEV_T dev_info = tuya_home_ctrl_dev_open(dev_id, &dev_cb);
BYTE_T dp_num;
TY_HOME_CTRL_DEV_DP_S* dp_sets;
OPERATE_RET ret = tuya_home_ctrl_dev_get_all_dp(dev_info, &dp_num, &dp_sets);
if (ret != OPRT_OK) {
PR_ERR("tuya_home_ctrl_dev_get_all_dp err:%d", ret);
ret = tuya_home_ctrl_dev_close(dev_info);
return;
}
PR_DEBUG("dev_id:%s, support %d dps:", dev_id, dp_num);
for (BYTE_T i = 0; i < dp_num; i++) {
tuya_home_ctrl_dev_show_dp(&(dp_sets[i]));
}
ret = tuya_home_ctrl_dev_close(dev_info);
if (ret != OPRT_OK) {
PR_ERR("tuya_home_ctrl_light_close err:%d, dev_id:%s", ret, dev_id);
return;
}
Get the specified DP of the device
Function prototype |
OPERATE_RET tuya_home_ctrl_dev_get_dp_value(IN CONST TY_HOME_CTRL_DEV_T dev_des, IN CONST CHAR_T* dp_code, OUT CONST TY_HOME_CTRL_DEV_DP_S** dp_info) |
Function description |
Get the specified DP of the device. |
Parameter |
- Request parameter
dev_des : The device descriptor.dp_code : The DP.
- Output parameter
dp_value : The value of the DP.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
- |
Example
TY_HOME_CTRL_DEV_T dev_info = tuya_home_ctrl_dev_open(dev_id, &dev_cb);
CONST TY_HOME_CTRL_DEV_DP_S* dp_info;
tuya_home_ctrl_dev_get_dp_value(dev_info, HOME_CTRL_LIGHT_SWITCH_LED, &dp_info);
tuya_home_ctrl_dev_show_dp(dp_info);
ret = tuya_home_ctrl_dev_close(dev_info);
if (ret != OPRT_OK) {
PR_ERR("tuya_home_ctrl_light_close err:%d, dev_id:%s", ret, dev_id);
return;
}
Set the specified DP of the device
Function prototype |
OPERATE_RET tuya_home_ctrl_dev_set_dp_value(IN CONST TY_HOME_CTRL_DEV_T dev_des, IN CONST CHAR_T* dp_code, IN TY_HOME_CTRL_DEV_DP_DATA_TP_E dp_type, IN CONST TY_HOME_CTRL_DEV_DP_VALUE_U* dp_value) |
Function description |
Get the specified DP of the device. |
Parameter |
- Request parameter
dev_des : The device descriptor.dp_code : The DP.dp_type : The data type of the DP.dp_value : The value of the DP.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
It is recommended to use TY_BASE_DP_DATA_TP_VALUE_SACLE to set a DP of integer type. |
Example
TY_HOME_CTRL_DEV_T dev_info = tuya_home_ctrl_dev_open(dev_id, &dev_cb);
BOOL_T bool_value = true;
tuya_home_ctrl_dev_set_dp_value(dev_info, HOME_CTRL_LIGHT_SWITCH_LED, PROP_BOOL, (TY_HOME_CTRL_DEV_DP_VALUE_U*)(&bool_value));
ret = tuya_home_ctrl_dev_close(dev_info);
if (ret != OPRT_OK) {
PR_ERR("tuya_home_ctrl_light_close err:%d, dev_id:%s", ret, dev_id);
return;
}
TY_HOME_CTRL_SCALE_INTEGER temp_scale_value;
temp_scale_value.value = 18;
temp_scale_value.scale = 0;
tuya_home_ctrl_dev_set_dp_value(dev_info, HOME_CTRL_LIGHT_BRIGHT, TY_BASE_DP_DATA_TP_VALUE_SACLE,
(TY_HOME_CTRL_DEV_DP_VALUE_U*)(&temp_scale_value));
Supported DPs
This section describes the standard DPs across different product categories. You can select the required DPs based on UI capability and product features.
The common and popular DPs are emphasized in bold for your reference.
Switch (kg)
Data point (DP) |
Description |
HOME_CTRL_SWITCH_SWITCH_INDEX(index_num) |
Switches 1 to 8 |
HOME_CTRL_SWITCH_COUNTDOWN_INDEX(index_num) |
Switches 1 to 8 countdown timer |
HOME_CTRL_SWITCH_SWITCH_ALL |
Main switch |
Socket (cz)
Data point (DP) |
Description |
HOME_CTRL_SOCKET_SWITCH |
Switch |
HOME_CTRL_SOCKET_CHILD_LOCK |
Child lock |
HOME_CTRL_SOCKET_RELAY_STATUS |
Power-on state |
HOME_CTRL_SOCKET_LIGHT_MODE |
Indicator state |
HOME_CTRL_SOCKET_COUNTDOWN_1 |
Countdown timer |
Lights (dj)
Data point (DP) |
Description |
HOME_CTRL_LIGHT_SWITCH_LED |
Switch |
HOME_CTRL_LIGHT_WORK_MODE |
Mode |
HOME_CTRL_LIGHT_BRIGHT |
Brightness |
HOME_CTRL_LIGHT_TEMP |
Color temperature |
HOME_CTRL_LIGHT_COLOUR |
Colorful |
HOME_CTRL_LIGHT_SCENE |
Scene |
Curtain motor (cl)
Data point (DP) |
Description |
HOME_CTRL_CURTAIN_CONTROL |
Control |
HOME_CTRL_CURTAIN_PERCENT_CONTROL |
Control by percentage |
HOME_CTRL_CURTAIN_MODE |
Mode |
HOME_CTRL_CURTAIN_CONTROL_BACK_MODE |
Reverse rotation |
HOME_CTRL_CURTAIN_AUTO_POWER |
Auto open |
HOME_CTRL_CURTAIN_COUNTDOWN_SET |
Countdown timer (new) |
HOME_CTRL_CURTAIN_PERCENT_STATE |
Opening percentage |
HOME_CTRL_CURTAIN_WORK_STATE |
Working state |
HOME_CTRL_CURTAIN_COUNTDOWN_LEFT |
Time left on the timer |
HOME_CTRL_CURTAIN_TIME_TOTAL |
Total travel time |
HOME_CTRL_CURTAIN_SITUATION_SET |
Position |
Air conditioner (kt)
Data point (DP) |
Description |
HOME_CTRL_AC_SWITCH |
Switch |
HOME_CTRL_AC_TEMP_SET |
Set temperature (°C) |
HOME_CTRL_AC_TEMP_CURRENT |
Current temperature |
HOME_CTRL_AC_MODE |
Mode |
HOME_CTRL_AC_FAN_SPEED_ENUM |
Fan speed mode |
HOME_CTRL_AC_MODE_ECO |
ECO |
HOME_CTRL_AC_HEAT |
Heating |
HOME_CTRL_AC_LIGHT |
LED light |
HOME_CTRL_AC_LOCK |
Child lock |
HOME_CTRL_AC_SWITCH_VERTICAL |
Vertical swing on/off |
HOME_CTRL_AC_SWING_3D |
3D swing |
HOME_CTRL_AC_SLEEP |
Sleep |
HOME_CTRL_AC_HEALTH |
Health |
HOME_CTRL_AC_CLEANING |
Cleaning |
HOME_CTRL_AC_GEAR_HORIZONTAL |
Horizontal swing |
HOME_CTRL_AC_POWER_CONSUMPTION |
Energy consumption |
HOME_CTRL_AC_TEMP_SET_F |
Set temperature (°F) |
HOME_CTRL_AC_WINDSPEED |
Fan speed level |
HOME_CTRL_AC_MODE_AUTO |
Auto mode |
HOME_CTRL_AC_MODE_DRY |
Dry mode |
HOME_CTRL_AC_MODE_VENTILATION |
Ventilation |
HOME_CTRL_AC_ANION |
Anion |
HOME_CTRL_AC_SWITCH_HORIZONTAL |
Horizontal swing on/off |
HOME_CTRL_AC_WINDSHAKE |
Air swing |
HOME_CTRL_AC_BEEP |
Beep |
HOME_CTRL_AC_HUMIDITY_SET |
Set humidity |
HOME_CTRL_AC_TEMP_UNIT_CONVERT |
Change temperature unit |
HOME_CTRL_AC_COUNTDOWN |
Countdown timer |
HOME_CTRL_AC_TEMP_CURRENT_F |
Current temperature (°F) |
HOME_CTRL_AC_WORK_STATUS |
Working state |
HOME_CTRL_AC_HUMIDITY_CURRENT |
Current humidity |
HOME_CTRL_AC_COUNTDOWN_LEFT |
Time left on the timer |
HOME_CTRL_AC_STATUS |
Status |
Ventilation system (xfj)
Data point (DP) |
Description |
HOME_CTRL_FRESH_AIR_SWITCH |
Switch |
HOME_CTRL_FRESH_AIR_MODE |
Mode |
HOME_CTRL_FRESH_AIR_PM25 |
PM2.5 |
HOME_CTRL_FRESH_AIR_UV_LIGHT |
UV light |
HOME_CTRL_FRESH_AIR_ANION |
Anion |
HOME_CTRL_FRESH_AIR_ECO2 |
eCO2 |
HOME_CTRL_FRESH_AIR_TVOC |
TVOC |
HOME_CTRL_FRESH_AIR_HUMIDITY_INDOOR |
Indoor humidity |
HOME_CTRL_FRESH_AIR_TEMP_INDOOR |
Indoor temperature |
HOME_CTRL_FRESH_AIR_UV_LIFE |
UV life |
HOME_CTRL_FRESH_AIR_FILTER_LIFE |
Filter life |
HOME_CTRL_FRESH_AIR_FAN_SPEED_ENUM |
Fan speed |
HOME_CTRL_FRESH_AIR_FILTER_RESET |
Filter reset |
HOME_CTRL_FRESH_AIR_CHILD_LOCK |
Child lock |
HOME_CTRL_FRESH_AIR_FACTORY_RESET |
Factory reset |
HOME_CTRL_FRESH_AIR_COUNTDOWN_SET |
Countdown timer |
HOME_CTRL_FRESH_AIR_COUNTDOWN_LEFT |
Time left on the timer |
HOME_CTRL_FRESH_AIR_FAULT |
Fault alert |
HOME_CTRL_FRESH_AIR_HCHO_SENSOR_VALUE |
HCHO parameter |
HOME_CTRL_FRESH_AIR_PM10 |
PM10 |
HOME_CTRL_FRESH_AIR_HUMIDITY_OUTDOOR |
Outdoor humidity |
HOME_CTRL_FRESH_AIR_TEMP_OUTDOOR |
Outdoor temperature |
HOME_CTRL_FRESH_AIR_AIR_QUALITY |
Air quality |
HOME_CTRL_FRESH_AIR_AIR_VOLUME |
Air volume |
HOME_CTRL_FRESH_AIR_LOOP_MODE |
Circulation mode |
HOME_CTRL_FRESH_AIR_SUPPLY_FAN_SPEED |
Supply air speed |
HOME_CTRL_FRESH_AIR_EXHAUST_FAN_SPEED |
Exhaust air speed |
HOME_CTRL_FRESH_AIR_SUPPLY_TEMP |
Supply air temperature |
HOME_CTRL_FRESH_AIR_EXHAUST_TEMP |
Exhaust air temperature |
HOME_CTRL_FRESH_AIR_SUPPLY_AIR_VOL |
Supply air volume |
HOME_CTRL_FRESH_AIR_EXHAUST_AIR_VOL |
Exhaust air volume |
HOME_CTRL_FRESH_AIR_FRESH_AIR_VALVE |
Fresh air valve |
HOME_CTRL_FRESH_AIR_AIR_EXHAUST_FAN |
Exhaust fan |
HOME_CTRL_FRESH_AIR_PRIMARY_FILTER_LIFE |
Remaining life of primary filter |
HOME_CTRL_FRESH_AIR_PRIMARY_FILTER_RESET |
Primary filter reset |
HOME_CTRL_FRESH_AIR_MEDIUM_FILTER_LIFE |
Remaining life of secondary filter |
HOME_CTRL_FRESH_AIR_MEDIUM_FILTER_RESET |
Secondary filter reset |
HOME_CTRL_FRESH_AIR_HIGH_FILTER_LIFE |
Remaining life of HEPA filter |
HOME_CTRL_FRESH_AIR_HIGH_FILTER_RESET |
HEPA filter reset |
HOME_CTRL_FRESH_AIR_STERILIZE |
Sterilization |
HOME_CTRL_FRESH_AIR_BYPASS_FUNCTION |
Bypass function |
HOME_CTRL_FRESH_AIR_HEAT |
Heating |
HOME_CTRL_FRESH_AIR_PM25_SET |
Set PM2.5 parameter |
HOME_CTRL_FRESH_AIR_ECO2_SET |
Set eCO2 parameter |
HOME_CTRL_FRESH_AIR_TEMP_SET |
Set temperature |
HOME_CTRL_FRESH_AIR_HUMIDITY_SET |
Set humidity |
HOME_CTRL_FRESH_AIR_TVOC_SET |
Set TVOC parameter |
HOME_CTRL_FRESH_AIR_AIR_CONDITIONING |
Air conditioning |
HOME_CTRL_FRESH_AIR_BACKLIGHT |
Backlight brightness |
HOME_CTRL_FRESH_AIR_PURIFY_MODE |
Purification mode |
HOME_CTRL_FRESH_AIR_PURIFICATION |
Purification |
HOME_CTRL_FRESH_AIR_DEHUMIDIFIER |
Dehumidification |
HOME_CTRL_FRESH_AIR_DEFROST |
Defrost |
HOME_CTRL_FRESH_AIR_PM10_SET |
Set PM10 parameter |
Thermostat (wk)
Data point (DP) |
Description |
HOME_CTRL_TEMP_CTRL_SWITCH |
Switch |
HOME_CTRL_TEMP_CTRL_MODE |
Mode |
HOME_CTRL_TEMP_CTRL_ECO |
ECO |
HOME_CTRL_TEMP_CTRL_ANION |
Anion |
HOME_CTRL_TEMP_CTRL_LIGHT |
LED light |
HOME_CTRL_TEMP_CTRL_SOUND |
Sound |
HOME_CTRL_TEMP_CTRL_FACTORY_RESET |
Factory reset |
HOME_CTRL_TEMP_CTRL_WINDOW_CHECK |
Window-opening detection |
HOME_CTRL_TEMP_CTRL_SLEEP |
Sleep function |
HOME_CTRL_TEMP_CTRL_FROST |
Frost protection |
HOME_CTRL_TEMP_CTRL_VALVE_CHECK |
Valve check |
HOME_CTRL_TEMP_CTRL_SWITCH_VERTICAL |
Vertical swing on/off |
HOME_CTRL_TEMP_CTRL_SWITCH_HORIZONTAL |
Horizontal swing on/off |
HOME_CTRL_TEMP_CTRL_FAN_HORIZONTAL |
Horizontal swing angle |
HOME_CTRL_TEMP_CTRL_FAN_VERTICAL |
Vertical swing angle |
HOME_CTRL_TEMP_CTRL_TEMP_SET |
Target temperature (°C) |
HOME_CTRL_TEMP_CTRL_UPPER_TEMP |
Set the upper limit of temperature (°C) |
HOME_CTRL_TEMP_CTRL_LOWER_TEMP |
Set the lower limit of temperature (°C) |
HOME_CTRL_TEMP_CTRL_TEMP_SET_F |
Target temperature (°F) |
HOME_CTRL_TEMP_CTRL_UPPER_TEMP_F |
Set the upper limit of temperature (°F) |
HOME_CTRL_TEMP_CTRL_LOWER_TEMP_F |
Set the lower limit of temperature (°F) |
HOME_CTRL_TEMP_CTRL_CAPACITY_SET |
Set the power |
HOME_CTRL_TEMP_CTRL_TEMP_CORRECTION |
Calibrate temperature |
HOME_CTRL_TEMP_CTRL_LEVEL |
Speed |
HOME_CTRL_TEMP_CTRL_WORK_DAYS |
Set the weekday |
HOME_CTRL_TEMP_CTRL_HOLIDAY_TEMP_SET |
Set the holiday temperature (°C) |
HOME_CTRL_TEMP_CTRL_HOLIDAY_TEMP_SET_F |
Set the holiday temperature (°F) |
HOME_CTRL_TEMP_CTRL_HOLIDAY_DAYS_SET |
Set the holiday day |
HOME_CTRL_TEMP_CTRL_HOLIDAY_SET |
Set the holiday time |
HOME_CTRL_TEMP_CTRL_CHILD_LOCK |
Child lock |
HOME_CTRL_TEMP_CTRL_COUNTDOWN |
Countdown timer |
HOME_CTRL_TEMP_CTRL_SENSOR_CHOOSE |
Choose sensor |
HOME_CTRL_TEMP_CTRL_BACKLIGHT |
Backlight brightness |
HOME_CTRL_TEMP_CTRL_BACKLIGHT_ENUM |
Quick setting of backlight brightness |
HOME_CTRL_TEMP_CTRL_TEMP_UNIT_CONVERT |
Change temperature unit |
HOME_CTRL_TEMP_CTRL_LOOP_MODE |
Circulation mode |
HOME_CTRL_TEMP_CTRL_FAN_SPEED_ENUM |
Set the fan speed |
HOME_CTRL_TEMP_CTRL_WORK_STATE |
Working state |
HOME_CTRL_TEMP_CTRL_WORK_POWER |
Current power |
HOME_CTRL_TEMP_CTRL_TEMP_CURRENT |
Current temperature (°C) |
HOME_CTRL_TEMP_CTRL_WINDOW_STATE |
Window state |
HOME_CTRL_TEMP_CTRL_TEMP_CURRENT_F |
Current temperature (°F) |
HOME_CTRL_TEMP_CTRL_VALVE_STATE |
Valve state |
HOME_CTRL_TEMP_CTRL_COUNTDOWN_LEFT |
Time left on the timer |
HOME_CTRL_TEMP_CTRL_BATTERY_PERCENTAGE |
Battery level |
HOME_CTRL_TEMP_CTRL_HUMIDITY |
Humidity |
Air purifier (kj)
Data point (DP) |
Description |
HOME_CTRL_AIR_PURIFIER_SWITCH |
Switch |
HOME_CTRL_AIR_PURIFIER_MODE |
Mode |
HOME_CTRL_AIR_PURIFIER_SPEED |
Fan speed level |
HOME_CTRL_AIR_PURIFIER_FAN_SPEED_ENUM |
Fan speed mode |
HOME_CTRL_AIR_PURIFIER_ANION |
Anion |
HOME_CTRL_AIR_PURIFIER_LOCK |
Child lock |
HOME_CTRL_AIR_PURIFIER_LIGHT |
LED light |
HOME_CTRL_AIR_PURIFIER_UV |
UV |
HOME_CTRL_AIR_PURIFIER_WET |
Humidification |
HOME_CTRL_AIR_PURIFIER_FILTER_RESET |
Filter reset |
HOME_CTRL_AIR_PURIFIER_COUNTDOWN_SET |
Countdown timer |
HOME_CTRL_AIR_PURIFIER_FILTER |
Filter usage |
HOME_CTRL_AIR_PURIFIER_PM25 |
PM2.5 |
HOME_CTRL_AIR_PURIFIER_TEMP |
Indoor temperature |
HOME_CTRL_AIR_PURIFIER_HUMIDITY |
Indoor humidity |
HOME_CTRL_AIR_PURIFIER_TVOC |
TVOC |
HOME_CTRL_AIR_PURIFIER_ECO2 |
eCO2 |
HOME_CTRL_AIR_PURIFIER_FILTER_DAYS |
Remaining life of filter |
HOME_CTRL_AIR_PURIFIER_TOTAL_TIME |
Total operation time |
HOME_CTRL_AIR_PURIFIER_TOTAL_PM |
Total amount of captured particles |
HOME_CTRL_AIR_PURIFIER_COUNTDOWN_LEFT |
Time left on the timer |
HOME_CTRL_AIR_PURIFIER_AIR_QUALITY |
Indoor air quality |
Drying rack (lyj)
Data point (DP) |
Description |
HOME_CTRL_AIRER_SWITCH |
Switch |
HOME_CTRL_AIRER_CONTROL |
Device control |
HOME_CTRL_AIRER_LIGHT |
LED light |
HOME_CTRL_AIRER_DISINFECTION |
Disinfection |
HOME_CTRL_AIRER_WIND_DRY |
Cold air dry |
HOME_CTRL_AIRER_HOT_DRY |
Hot air dry |
HOME_CTRL_AIRER_DISINFECTION_SET |
Disinfection countdown timer |
HOME_CTRL_AIRER_HOT_DRY_SET |
Hot dry countdown timer |
HOME_CTRL_AIRER_ANION_SET |
Anion countdown timer |
HOME_CTRL_AIRER_WIND_DRY_SET |
Cold dry countdown timer |
HOME_CTRL_AIRER_ANION |
Anion |
HOME_CTRL_AIRER_POSITION |
Position |
HOME_CTRL_AIRER_DISINFECT_LEFT |
Time left for disinfection |
HOME_CTRL_AIRER_WIND_LEFT |
Time left for cold dry |
HOME_CTRL_AIRER_HOT_LEFT |
Time left for hot dry |
HOME_CTRL_AIRER_ANION_LEFT |
Time left for anion |
HOME_CTRL_AIRER_WORK_STATE |
Working state |
Power strip (pc)
Data point (DP) |
Description |
HOME_CTRL_SOCKETS_SWITCH |
Switch |
HOME_CTRL_SOCKETS_SWITCH_1 |
Switch 1 |
HOME_CTRL_SOCKETS_SWITCH_2 |
Switch 2 |
HOME_CTRL_SOCKETS_SWITCH_3 |
Switch 3 |
HOME_CTRL_SOCKETS_SWITCH_4 |
Switch 4 |
HOME_CTRL_SOCKETS_SWITCH_5 |
Switch 5 |
HOME_CTRL_SOCKETS_SWITCH_6 |
Switch 6 |
HOME_CTRL_SOCKETS_COUNTDOWN_1 |
Switch 1 countdown timer |
HOME_CTRL_SOCKETS_COUNTDOWN_2 |
Switch 2 countdown timer |
HOME_CTRL_SOCKETS_COUNTDOWN_3 |
Switch 3 countdown timer |
HOME_CTRL_SOCKETS_COUNTDOWN_4 |
Switch 4 countdown timer |
HOME_CTRL_SOCKETS_COUNTDOWN_5 |
Switch 5 countdown timer |
HOME_CTRL_SOCKETS_COUNTDOWN_6 |
Switch 6 countdown timer |
HOME_CTRL_SOCKETS_SWITCH_USB1 |
USB 1 |
HOME_CTRL_SOCKETS_SWITCH_USB2 |
USB 2 |
HOME_CTRL_SOCKETS_SWITCH_USB3 |
USB 3 |
HOME_CTRL_SOCKETS_SWITCH_USB4 |
USB 4 |
HOME_CTRL_SOCKETS_SWITCH_USB5 |
USB 5 |
HOME_CTRL_SOCKETS_SWITCH_USB6 |
USB 6 |
HOME_CTRL_SOCKETS_COUNTDOWN_USB1 |
USB 1 countdown timer |
HOME_CTRL_SOCKETS_COUNTDOWN_USB2 |
USB 2 countdown timer |
HOME_CTRL_SOCKETS_COUNTDOWN_USB3 |
USB 3 countdown timer |
HOME_CTRL_SOCKETS_COUNTDOWN_USB4 |
USB 4 countdown timer |
HOME_CTRL_SOCKETS_COUNTDOWN_USB5 |
USB 5 countdown timer |
HOME_CTRL_SOCKETS_COUNTDOWN_USB6 |
USB 6 countdown timer |
HOME_CTRL_SOCKETS_CHILD_LOCK |
Child lock |
HOME_CTRL_SOCKETS_RELAY_STATUS |
Power-on state |
HOME_CTRL_SOCKETS_LIGHT_MODE |
Indicator state |
HOME_CTRL_SOCKETS_SWITCH_BACKLIGHT |
Backlight on/off |
HOME_CTRL_SOCKETS_CUR_CURRENT |
Actual current |
HOME_CTRL_SOCKETS_CUR_POWER |
Actual power |
HOME_CTRL_SOCKETS_CUR_VOLTAGE |
Actual voltage |
Dimmer switch (tgkg)
Data point (DP) |
Description |
HOME_CTRL_DIMMER_SWITCH_COLOUR_DATA |
Colorful |
HOME_CTRL_DIMMER_SWITCH_TEMP_VALUE |
Color temperature value |
HOME_CTRL_DIMMER_SWITCH_LIGHT_MODE |
Indicator state |
HOME_CTRL_DIMMER_SWITCH_RELAY_STATUS |
Power-on state |
HOME_CTRL_DIMMER_SWITCH_WORK_MODE |
Mode |
HOME_CTRL_DIMMER_SWITCH_SWITCH_LED_1 |
Switch 1 |
HOME_CTRL_DIMMER_SWITCH_SWITCH_LED_2 |
Switch 2 |
HOME_CTRL_DIMMER_SWITCH_SWITCH_LED_3 |
Switch 3 |
HOME_CTRL_DIMMER_SWITCH_BRIGHTNESS_MIN_1 |
Minimum brightness 1 |
HOME_CTRL_DIMMER_SWITCH_BRIGHTNESS_MIN_2 |
Minimum brightness 2 |
HOME_CTRL_DIMMER_SWITCH_BRIGHTNESS_MIN_3 |
Minimum brightness 3 |
HOME_CTRL_DIMMER_SWITCH_BRIGHTNESS_MAX_1 |
Maximum brightness 1 |
HOME_CTRL_DIMMER_SWITCH_BRIGHTNESS_MAX_2 |
Maximum brightness 2 |
HOME_CTRL_DIMMER_SWITCH_BRIGHTNESS_MAX_3 |
Maximum brightness 3 |
HOME_CTRL_DIMMER_SWITCH_BRIGHT_VALUE_1 |
Brightness 1 |
HOME_CTRL_DIMMER_SWITCH_BRIGHT_VALUE_2 |
Brightness 2 |
HOME_CTRL_DIMMER_SWITCH_BRIGHT_VALUE_3 |
Brightness 3 |
HOME_CTRL_DIMMER_SWITCH_COUNTDOWN_1 |
Switch 1 countdown timer |
HOME_CTRL_DIMMER_SWITCH_COUNTDOWN_2 |
Switch 2 countdown timer |
HOME_CTRL_DIMMER_SWITCH_COUNTDOWN_3 |
Switch 3 countdown timer |
HOME_CTRL_DIMMER_SWITCH_LED_TYPE_1 |
Light source 1 |
HOME_CTRL_DIMMER_SWITCH_LED_TYPE_2 |
Light source 2 |
HOME_CTRL_DIMMER_SWITCH_LED_TYPE_3 |
Light source 3 |
Aroma diffuser (xxj)
Data point (DP) |
Description |
HOME_CTRL_AROMA_DIFFUSER_SWITCH |
Main switch |
HOME_CTRL_AROMA_DIFFUSER_SWITCH_SPRAY |
Spray on/off |
HOME_CTRL_AROMA_DIFFUSER_MODE |
Spray mode (mist intensity) |
HOME_CTRL_AROMA_DIFFUSER_COUNTDOWN |
Spray countdown timer |
HOME_CTRL_AROMA_DIFFUSER_SWITCH_LED |
Light on/off |
HOME_CTRL_AROMA_DIFFUSER_WORK_MODE |
Light mode |
HOME_CTRL_AROMA_DIFFUSER_COLOUR_DATA_HSV |
Light color in HSV |
HOME_CTRL_AROMA_DIFFUSER_BRIGHT_VALUE |
Brightness |
HOME_CTRL_AROMA_DIFFUSER_SWITCH_SOUND |
Sound on/off |
HOME_CTRL_AROMA_DIFFUSER_LEVEL |
Spray intensity |
HOME_CTRL_AROMA_DIFFUSER_MOODLIGHTING |
Ambient light |
HOME_CTRL_AROMA_DIFFUSER_COLOUR_DATA |
Color value |
HOME_CTRL_AROMA_DIFFUSER_COUNTDOWN_LEFT |
Time left on spray countdown timer |
Humidifier (jsq)
Data point (DP) |
Description |
HOME_CTRL_HUMIDIFIER_SWITCH |
Main switch |
HOME_CTRL_HUMIDIFIER_SWITCH_SPRAY |
Spray on/off |
HOME_CTRL_HUMIDIFIER_MODE |
Spray mode (mist intensity) |
HOME_CTRL_HUMIDIFIER_SPRAY_MODE |
Spray mode (adjustment) |
HOME_CTRL_HUMIDIFIER_LEVEL |
Spray intensity |
HOME_CTRL_HUMIDIFIER_COUNTDOWN_SET |
Set spray countdown timer |
HOME_CTRL_HUMIDIFIER_SWITCH_LED |
Light on/off |
HOME_CTRL_HUMIDIFIER_WORK_MODE |
Light mode |
HOME_CTRL_HUMIDIFIER_COLOUR_DATA_HSV |
Color value |
HOME_CTRL_HUMIDIFIER_BRIGHT_VALUE |
Brightness |
HOME_CTRL_HUMIDIFIER_SWITCH_SOUND |
Sound on/off |
HOME_CTRL_HUMIDIFIER_TEMP_SET |
Set temperature |
HOME_CTRL_HUMIDIFIER_TEMP_SET_F |
Set temperature in °F |
HOME_CTRL_HUMIDIFIER_HUMIDITY_SET |
Set humidity |
HOME_CTRL_HUMIDIFIER_SLEEP |
Sleep function |
HOME_CTRL_HUMIDIFIER_TEMP_UNIT_CONVERT |
Set temperature unit |
HOME_CTRL_HUMIDIFIER_STERILIZATION |
Sterilization |
HOME_CTRL_HUMIDIFIER_CHILD_LOCK |
Child lock |
HOME_CTRL_HUMIDIFIER_COUNTDOWN |
Spray countdown timer |
HOME_CTRL_HUMIDIFIER_COLOUR_DATA |
Color value |
HOME_CTRL_HUMIDIFIER_C_F |
Change temperature unit |
HOME_CTRL_HUMIDIFIER_MOODLIGHTING |
Ambient light |
HOME_CTRL_HUMIDIFIER_COUNTDOWN_LEFT |
Time left on spray countdown timer |
HOME_CTRL_HUMIDIFIER_TEMP_CURRENT |
Current temperature |
HOME_CTRL_HUMIDIFIER_TEMP_CURRENT_F |
Current temperature (°F) |
HOME_CTRL_HUMIDIFIER_HUMIDITY_CURRENT |
Current humidity |
HOME_CTRL_HUMIDIFIER_LEVEL_CURRENT |
Current water level |
Contact sensor (mcs)
Data point (DP) |
Description |
HOME_CTRL_DOOR_SENSOR_DOORCONTACT_STATE |
Contact sensor state |
HOME_CTRL_DOOR_SENSOR_TEMPER_ALARM |
Tamper alarm |
HOME_CTRL_DOOR_SENSOR_BATTERY_PERCENTAGE |
Battery percentage |
HOME_CTRL_DOOR_SENSOR_BATTERY_VALUE |
Battery level |
HOME_CTRL_DOOR_SENSOR_BATTERY_STATE |
Battery state |
Water detector (sj)
Data point (DP) |
Description |
HOME_CTRL_WATER_SENSOR_WATERSENSOR_STATE |
Water detection state |
HOME_CTRL_WATER_SENSOR_TEMPER_ALARM |
Tamper alarm |
HOME_CTRL_WATER_SENSOR_BATTERY_PERCENTAGE |
Battery percentage |
HOME_CTRL_WATER_SENSOR_BATTERY_VALUE |
Battery level |
HOME_CTRL_WATER_SENSOR_BATTERY_STATE |
Battery state |
Passive infrared sensor (pir)
Data point (DP) |
Description |
HOME_CTRL_PIR_SENSOR_PIR |
PIR detection state |
HOME_CTRL_PIR_SENSOR_TEMPER_ALARM |
Tamper alarm |
HOME_CTRL_PIR_SENSOR_BATTERY_PERCENTAGE |
Battery percentage |
HOME_CTRL_PIR_SENSOR_BATTERY_STATE |
Battery state |
HOME_CTRL_PIR_SENSOR_BATTERY |
Battery level |
HOME_CTRL_PIR_SENSOR_BATTERY_VALUE |
Battery level value |
Temperature and humidity sensor (wsdcg)
Data point (DP) |
Description |
HOME_CTRL_THTB_SENSOR_VA_TEMPERATURE |
Current temperature |
HOME_CTRL_THTB_SENSOR_VA_HUMIDITY |
Current humidity |
HOME_CTRL_THTB_SENSOR_TEMPER_ALARM |
Tamper alarm |
HOME_CTRL_THTB_SENSOR_BATTERY_PERCENTAGE |
Battery percentage |
HOME_CTRL_THTB_SENSOR_BATTERY_STATE |
Battery state |
HOME_CTRL_THTB_SENSOR_VA_BATTERY |
Battery level |
HOME_CTRL_THTB_SENSOR_BATTERY_VALUE |
Battery level value |
Gas detector (rqbj)
Data point (DP) |
Description |
HOME_CTRL_GAS_ALARM_SENSOR_MUFFLING |
Mute |
HOME_CTRL_GAS_ALARM_SENSOR_ALARM_RINGTONE |
Alarm ringtone |
HOME_CTRL_GAS_ALARM_SENSOR_ALARM_TIME |
Alarm duration |
HOME_CTRL_GAS_ALARM_SENSOR_SELF_CHECKING |
Self-check |
HOME_CTRL_GAS_ALARM_SENSOR_ALARM_VOLUME |
Alarm volume |
HOME_CTRL_GAS_ALARM_SENSOR_ALARM_SWITCH |
Alarm on/off |
HOME_CTRL_GAS_ALARM_SENSOR_PREHEAT |
Preheat state |
HOME_CTRL_GAS_ALARM_SENSOR_TEMPER_ALARM |
Tamper alarm |
HOME_CTRL_GAS_ALARM_SENSOR_LIFECYCLE |
Service life |
HOME_CTRL_GAS_ALARM_SENSOR_CHECKING_RESULT |
Self-check result |
HOME_CTRL_GAS_ALARM_SENSOR_BATTERY_PERCENTAGE |
Battery percentage |
HOME_CTRL_GAS_ALARM_SENSOR_BATTERY_VALUE |
Battery level |
HOME_CTRL_GAS_ALARM_SENSOR_BATTERY_STATE |
Battery state |
HOME_CTRL_GAS_ALARM_SENSOR_GAS_SENSOR_VALUE |
Gas density |
HOME_CTRL_GAS_ALARM_SENSOR_GAS_SENSOR_STATUS |
Gas detection state |
Sofa (sf)
Data point (DP) |
Description |
HOME_CTRL_SOFA_SWITCH |
Switch |
HOME_CTRL_SOFA_STOP |
Stop |
HOME_CTRL_SOFA_LOCK |
Child lock |
HOME_CTRL_SOFA_LIE |
One-touch lie flat |
HOME_CTRL_SOFA_HEAD_RUN |
Motor travel for head massage |
HOME_CTRL_SOFA_WHOLE_RUN |
Motor travel for full body massage |
HOME_CTRL_SOFA_MODE |
Mode |
Scene switch (cjkg)
Data point (DP) |
Description |
HOME_CTRL_SCENE_SWITCH_SCENE_INDEX (index_num) |
Scenes 1 to 8 |
HOME_CTRL_SCENE_SWITCH_COUNTDOWN_INDEX (index_num) |
Switches 1 to 8 countdown timer |
HOME_CTRL_SCENE_SWITCH_SWITCH_INDEX(index_num) |
Switches 1 to 8 |
SOS sensor (sos)
Data point (DP) |
Description |
HOME_CTRL_SOS_SENSOR_SOS_STATE |
Emergency mode |
HOME_CTRL_SOS_SENSOR_BATTERY_STATE |
Battery state |
HOME_CTRL_SOS_SENSOR_TEMPER_ALARM |
Tamper alarm |
HOME_CTRL_SOS_SENSOR_BATTERY_PERCENTAGE |
Battery level |
Get the DP name list
Function prototype |
OPERATE_RET tuya_home_ctrl_get_dp_name_list(IN CONST TY_HOME_CTRL_DEV_T dev_des, OUT TY_HOME_CTRL_DP_NAME_S **pp_list, OUT BYTE_T *num) |
Function description |
Get the specified DP of the device. |
Parameter |
- Request parameter
dev_des : The device descriptor.
- Output parameter
pp_list : The list of DP names.num : The number of DP names.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
- |
Example
TY_HOME_CTRL_DEV_T dev_info = tuya_home_ctrl_dev_open(dev_id, &dev_cb);
BYTE_T dp_name_num;
TY_HOME_CTRL_DP_NAME_S *dp_name_list = NULL;
ret = tuya_home_ctrl_get_dp_name_list(dev_info, &dp_name_list, &dp_name_num);
if (ret != OPRT_OK) {
PR_ERR("tuya_home_ctrl_get_dp_name_list err:%d", ret);
ret = tuya_home_ctrl_dev_close(dev_info);
return;
}
for (i = 0; i < dp_name_num; i++) {
PR_DEBUG("dp std_code : %s --> dp_name : %s", dp_name_list[i].std_code, dp_name_list[i].dp_name);
}
Get the brief device information by descriptor
Function prototype |
OPERATE_RET tuya_home_ctrl_get_dev_brief(IN CONST TY_HOME_CTRL_DEV_T dev_des, OUT TY_HOME_CTRL_DEV_BRIEF_S *brief_info) |
Function description |
Get the brief information about the device by device descriptor. |
Parameter |
- Request parameter
dev_des : The device descriptor.
- Output parameter
brief_info : Brief device information.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
- |
Example
TY_HOME_CTRL_DEV_BRIEF_S brief_info = {0};
OPERATE_RET ret = tuya_home_ctrl_get_dev_brief(dev_info, &brief_info);
if (ret != OPRT_OK) {
PR_ERR("tuya_home_ctrl_get_dev_brief err:%d", ret);
}
PR_DEBUG("dev_id:%s, dev_name:%s, category:%s, online:%d", brief_info.id, brief_info.name, brief_info.category,
brief_info.online_stat);
Scene switch
Get the scene switch information
Function prototype |
OPERATE_RET tuya_home_ctrl_dev_get_scene_switch_info(IN CONST TY_HOME_CTRL_DEV_T dev_des, OUT TY_HOME_CTRL_DEV_SCENE_SWITCH_INFO_S *p_scene_switch_info) |
Function description |
Get the mapping between the standard DP of the scene switch and the scene name. |
Parameter |
- Request parameter
dev_des : The device descriptor.
- Output parameter
p_scene_switch_info : The mapping information.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
This interface is used to get the mapping between the standard DP of the scene switch and the scene name, for example, std_code:scene1 and rule_name:sleep mode . For more information, see the demo. After the function call, call tuya_home_ctrl_dev_scene_switch_info_destroy to free the memory. |
Free the memory for scene switch information
Function prototype |
OPERATE_RET tuya_home_ctrl_dev_scene_switch_info_destroy(IN TY_HOME_CTRL_DEV_SCENE_SWITCH_INFO_S* p_scene_switch_info) |
Function description |
Free the memory allocated for scene switch information. |
Parameter |
- Request parameter
p_scene_switch_info : The mapping information.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
- |
Custom DP
For more information about the custom DP, see test_home_ctrl_switch.c
in the demo.
Get all custom DPs
Function prototype |
OPERATE_RET tuya_home_ctrl_dev_get_all_custom_dp(IN CONST TY_HOME_CTRL_DEV_T dev_des,OUT BYTE_T *dp_num,OUT TUYA_CUSTOM_DP_PROP_S **dp_sets) |
Function description |
Get the information about all custom DPs of a device. |
Parameter |
- Request parameter
dev_des : The device descriptor.
- Output parameter
dp_num : The number of DPs.dp_sets : The collection of DPs.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
- |
Specify the value of a custom DP
Function prototype |
OPERATE_RET tuya_home_ctrl_dev_set_custom_dp_value(IN CONST TY_HOME_CTRL_DEV_T dev_des,IN CONST INT_T dp_id,IN TY_HOME_CTRL_DEV_DP_DATA_TP_E dp_type,IN CONST TY_HOME_CTRL_DEV_DP_VALUE_U *dp_value) |
Function description |
Specify the value of a custom DP. |
Parameter |
- Request parameter
dev_des : The device descriptor.dp_id : DP ID.dp_type : DP type.dp_value : The value of the DP.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
- |
Get the value of the specified custom DP
Function prototype |
OPERATE_RET tuya_home_ctrl_dev_get_custom_dp_value(IN CONST TY_HOME_CTRL_DEV_T dev_des,IN CONST INT_T dp_id,OUT TUYA_CUSTOM_DP_PROP_S **dp_info) |
Function description |
Get the value of the specified custom DP. |
Parameter |
- Request parameter
dev_des : The device descriptor.dp_id : DP ID.
- Output parameter
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
- |
Print the content of a custom DP
Function prototype |
VOID tuya_home_ctrl_dev_show_custom_dp(IN CONST TUYA_CUSTOM_DP_PROP_S *dp) |
Function description |
Print the content of a custom DP. |
Parameter |
- Request parameter
dev_des : The device descriptor.dp_id : DP ID.dp_type : DP type.dp_value : The value of the DP.
|
Return value |
OPERATE_RET:0 : Success.- Other values: Failure. See the error code.
|
Detailed description |
- |
Callback for changes of custom DP status
Function prototype |
VOID (*TY_HOME_CTRL_DEV_REPORT_CUSTOM_FUNC)(IN CONST TUYA_CUSTOM_DP_PROP_S *dp, IN VOID *user_arg); |
Function description |
The callback invoked when the status of a custom DP changes. |
Parameter |
- Request parameter
dp : DP data.user_arg : User parameter.
|
Return value |
VOID |
Detailed description |
- |