更新时间:2025-06-27 10:23:18下载pdf
场景控制也就是家庭下的一键执行场景,在 App 端完成场景创建后,中控端会同步创建的场景,支持场景的控制和状态的同步,下面将对各个接口的使用进行描述。
函数原型 | OPERATE_RET tuya_scene_info_list_get(OUT TUYA_SCENE_INFO_S **pp_list, OUT UINT_T *p_cnt) |
---|---|
函数描述 | 获取场景列表 |
参数说明 | pp_list,场景列表 p_cnt,场景列表的数量 |
返回值 | OPERATE_RET,0:成功; 其他:失败,详见错误码 |
详细描述 | 需要调用 tuya_scene_info_list_free 释放。 |
用法示例:
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);
}
}
函数原型 | OPERATE_RET tuya_scene_info_list_free(IN TUYA_SCENE_INFO_S *p_list, IN UINT_T p_cnt) |
---|---|
函数描述 | 释放场景列表 |
参数说明 | pp_list,场景列表 p_cnt,场景列表的数量 |
返回值 | OPERATE_RET,0:成功; 其他:失败,详见错误码 |
详细描述 | - |
用法示例:
if (count > 0 && NULL != scene) {
tuya_scene_info_list_free(scene, count);
}
函数原型 | OPERATE_RET tuya_scene_sync() |
---|---|
函数描述 | 场景同步 |
参数说明 | VOID |
返回值 | OPERATE_RET,0:成功; 其他:失败,详见错误码 |
详细描述 | - |
函数原型 | OPERATE_RET tuya_scene_triggle(IN CHAR_T *id, OUT TUYA_SCENE_DEV_STAT_E *status) |
---|---|
函数描述 | 场景下发,执行场景 |
参数说明 | id,场景 ID status,场景状态 |
返回值 | OPERATE_RET,0:成功; 其他:失败,详见错误码 |
详细描述 | - |
用法示例:
TUYA_SCENE_DEV_STAT_E result;
tuya_scene_triggle(id, &result);
PR_DEBUG("scene action result is %d", result);
函数原型 | TUYA_SCENE_ROOMS *tuya_scene_get_room_list(IN CONST CHAR_T *scene_id) |
---|---|
函数描述 | 获取指定场景所在的房间 |
参数说明 | scene_id,场景ID |
返回值 | TUYA_SCENE_ROOMS* 房间列表指针:成功;NULL:失败 |
详细描述 | - |
函数原型 | TY_SCENE_ROOM_LIST_S *tuya_scene_get_all_scene_room_list() |
---|---|
函数描述 | 获取所有场景所在的房间 |
参数说明 | VOID |
返回值 | TY_SCENE_ROOM_LIST_S* 房间列表指针:成功;NULL:失败 |
详细描述 | - |
用法示例:
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");
}
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈