Last Updated on : 2025-06-30 01:47:22download
The scene created with the Tap-to-Run feature on the mobile app is synchronized to the central control device for device control and status synchronization. This topic describes the APIs used in scene control.
Function prototype | OPERATE_RET tuya_scene_info_list_get(OUT TUYA_SCENE_INFO_S **pp_list, OUT UINT_T *p_cnt) |
---|---|
Function description | Get the scene list |
Parameter | pp_list : The scene list. p_cnt : The number of scene lists. |
Return value | OPERATE_RET , 0 : Success. Other values: Failure. See the error code. |
Detailed description | Call tuya_scene_info_list_free to free resources. |
Example
UINT_T count = 0;
TUYA_SCENE_INFO_S *scene = NULL;
OPERATE_RET op_ret = OPRT_OK;
op_ret = tuya_scene_info_list_get(&scene, &count);
PR_DEBUG("op_ret===================================%d count:%d", op_ret, count);
if (op_ret == OPRT_OK && scene){
for (i = 0; i < count; i++){
PR_DEBUG("scene[%d]: id:%s, name:%s, icon_path:%s", i, scene[i].id, scene[i].name, scene[i].icon_path);
}
}
Function prototype | OPERATE_RET tuya_scene_info_list_free(IN TUYA_SCENE_INFO_S *p_list, IN UINT_T p_cnt) |
---|---|
Function description | Get the scene list. |
Parameter | pp_list : The scene list. p_cnt : The number of scene lists. |
Return value | OPERATE_RET , 0 : Success. Other values: Failure. See the error code. |
Detailed description | - |
Example
if (count > 0 && NULL != scene) {
tuya_scene_info_list_free(scene, count);
}
Function prototype | OPERATE_RET tuya_scene_sync() |
---|---|
Function description | Synchronize the scene. |
Parameter | VOID |
Return value | OPERATE_RET , 0 : Success. Other values: Failure. See the error code. |
Detailed description | - |
Function prototype | OPERATE_RET tuya_scene_triggle(IN CHAR_T *id, OUT TUYA_SCENE_DEV_STAT_E *status) |
---|---|
Function description | Run the specified scene. |
Parameter | id : The scene ID. status : The scene status. |
Return value | OPERATE_RET , 0 : Success. Other values: Failure. See the error code. |
Detailed description | - |
Example
TUYA_SCENE_DEV_STAT_E result;
tuya_scene_triggle(id, &result);
PR_DEBUG("scene action result is %d", result);
Function prototype | TUYA_SCENE_ROOMS *tuya_scene_get_room_list(IN CONST CHAR_T *scene_id) |
---|---|
Function description | Get the room where the scene is located. |
Parameter | scene_id : The scene ID. |
Return value | TUYA_SCENE_ROOMS* Room list pointer: Success; NULL: Failure |
Detailed description | - |
Function prototype | TY_SCENE_ROOM_LIST_S *tuya_scene_get_all_scene_room_list() |
---|---|
Function description | Get rooms where all scenes are located. |
Parameter | VOID |
Return value | TY_SCENE_ROOM_LIST_S* Room list pointer: Success; NULL: Failure |
Detailed description | - |
Example
int i = 0;
UINT_T count = 0;
TY_SCENE_ROOM_LIST_S *room_list = tuya_scene_get_all_scene_room_list();
if (room_list != NULL) {
PR_DEBUG("scene num:%d", room_list->num);
for (i = 0; i < room_list->num; i++) {
PR_DEBUG("scene[%d]: id:%s, count:%d", i, room_list->list[i].id, room_list->list[i].rooms.count);
for (UINT_T j = 0; j < room_list->list[i].rooms.count; j++) {
PR_DEBUG("room[%d] id:%d", j, room_list->list[i].rooms.room_ids[j]);
}
}
tuya_scene_free_room_list(room_list);
room_list = NULL;
} else {
PR_DEBUG("room_list is NULL");
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback