更新时间:2021-09-23 04:00:10下载pdf
本文介绍场景配置相关 API。
| 请求方式 | API | 描述 | 
|---|---|---|
| GET | /v1.0/illumination/smart/scene/list | 场景列表 | 
| GET | /v1.0/illumination/smart/scene/{id} | 场景详情查询接口 | 
| POST | /v1.0/illumination/smart/scene/add | 创建场景 | 
| POST | /v1.0/illumination/smart/scene/update | 更新场景 | 
| GET | /v1.0/illumination/smart/scene/action/property | 查询执行动作的数据 | 
| POST | /v1.0/illumination/smart/trigger | 一键执行场景 | 
功能描述
获取某个项目下的空间下的场景列表。
接口地址
GET /v1.0/illumination/smart/scene/list
请求参数
| 参数名 | 类型 | 参数类型 | 说明 | 是否必需 | 
|---|---|---|---|---|
| projectId | String | body | 项目 ID | 是 | 
| roomIds | List | body | 空间 ID 列表 | 否 | 
返回参数
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码(详情见错误码章节),成功时为空 | 
| success | Boolean | 是否成功:(true:成功,false:失败) | 
| msg | String | 请求失败的信息,成功时为空 | 
| t | Long | 返回时间戳,13 位 | 
| result | Object | 返回结果 | 
result 参数说明
[
  {
    "ruleId": "String //智能联动侧的ruleId,更新时使用",
    "name": "String //名称 true",
    "projectId": "String //项目ID true",
    "background": "String //背景图",
    "displayIcon": "String //用于主界面显示的图标",
    "displayColor": "String //颜色",
    "actions": [
      {
        "id": "String //智能联动侧的动作ID,更新时使用",
        "entityId": "String //执行对象ID true",
        "entityName": "String //执行对象名称 true",
        "executorProperty": {},
        "actionExecutor": "String //执行动作属性 true",
        "actionDisplay": "String //执行动作描述",
        "extraProperty": {},
        "actionDisplayNew": {},
        "executorType": "int //执行类型,1.dp点下发,3.设备群组dp点下发  4.场景作为动作被触发行  5.延迟动作  6.自动化作为动作被启用 7.自动化作为动作被停用",
        "iconUrl": "String //iconUrl",
        "productId": "String //产品ID",
        "orderNum": "int //顺序码"
      }
    ],
    "extendInfo": "String //扩展信息",
    "type": "int //智能联动类型 1:\"定时\",2:\"场景\",3:自动化\"",
    "roomId": "String //房间ID true",
    "deviceIds": "String[] //场景包含的单设备ID集合 false",
  }
]
请求示例
{
  "roomIds": "",
  "projectId": ""
}
响应示例
{
    "actions":[
        {
            "actionDisplayNew":{
                "1":[
                    "开关",
                    "开启"
                ]
            },
            "actionExecutor":"commerceLightDpIssue",
            "entityId":"1367290337185304576",
            "entityName":"autoTest_pkg_G_WIFI_24",
            "executorProperty":{
                "led_switch":true
            },
            "executorType":3,
            "extraProperty":{
                "roomName":"AutoTest_VirtualDevices"
            },
            "productId":"qadpdqfc0kkklov3"
        }
    ],
    "background":"https://images.tuyacn.com/smart/rule/cover/evening.png",
    "conditions":[
        {
            "entityId":"tuyadae641eb825d9db7",
            "entitySubIds":"101",
            "entityType":1,
            "expr":[
                [
                    "$dp101",
                    "==",
                    true
                ]
            ],
            "extraInfo":{
                "areaId":19797715
            }
        }
    ],
    "matchType":1,
    "name":"autoTest_Linkage19222",
    "preConditions":[
    ],
    "projectId":"1329400489246232576",
    "type":3
}
功能描述
通过场景 ID 查询场景详情。
接口地址
GET /v1.0/illumination/smart/scene/{id}
请求参数
| 参数名 | 类型 | 参数类型 | 说明 | 是否必需 | 
|---|---|---|---|---|
| id | String | url | 场景 ID | 是 | 
返回参数
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码(详情见错误码章节),成功时为空 | 
| success | Boolean | 是否成功:(true:成功,false:失败) | 
| msg | String | 请求失败的信息,成功时为空 | 
| t | Long | 返回时间戳,13 位 | 
| result | Object | 返回结果 | 
result 参数说明
参见场景列表 result 参数说明。
响应示例
参见场景列表响应示例。
功能描述
新建场景。
接口地址
POST /v1.0/illumination/smart/scene/add
请求参数
| 参数名 | 类型 | 参数类型 | 说明 | 是否必需 | 
|---|---|---|---|---|
| ruleId | String | body | 智能联动侧的 ruleId,更新时使用 | 否 | 
| name | String | body | 名称 | 是 | 
| projectId | String | body | 项目ID | 是 | 
| background | String | body | 背景图 | 否 | 
| displayIcon | String | body | 用于主界面显示的图标 | 否 | 
| displayColor | String | body | 颜色 | 否 | 
| actions.id | String | body | 智能联动侧的动作 ID,更新时使用 | 否 | 
| actions.entityId | String | body | 执行对象ID | 是 | 
| actions.entityName | String | body | 执行对象名称 | 是 | 
| actions.executorProperty | Object | body | 执行动作属性 | 是 | 
| actions.actionExecutor | String | body | 执行动作属性 | 是 | 
| actions.extraProperty | Object | body | 额外信息 | 否 | 
| actions.actionDisplayNew | Object | body | DP 动作描述 | 否 | 
| actions.executorType | int | body | 执行类型: 
 | 否 | 
| actions.iconUrl | String | body | 图标 URL | 否 | 
| actions.productId | String | body | 产品 ID | 否 | 
| actions.orderNum | int | body | 顺序码 | 否 | 
| extendInfo | String | body | 扩展信息 | 否 | 
| type | int | body | 智能联动类型: 
 | 否 | 
| roomId | String | body | 房间 ID | 是 | 
返回参数
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码(详情见错误码章节),成功时为空 | 
| success | Boolean | 是否成功:(true:成功,false:失败) | 
| msg | String | 请求失败的信息,成功时为空 | 
| t | Long | 返回时间戳,13 位 | 
| result | Object | 返回结果 | 
result 参数说明
{
    "ruleId": "String //智能联动侧的ruleId,更新时使用",
    "name": "String //名称 true",
    "projectId": "String //项目ID true",
    "background": "String //背景图",
    "displayIcon": "String //用于主界面显示的图标",
    "displayColor": "String //颜色",
    "actions": [
      {
        "id": "String //智能联动侧的动作ID,更新时使用",
        "entityId": "String //执行对象ID true",
        "entityName": "String //执行对象名称 true",
        "executorProperty": {},
        "actionExecutor": "String //执行动作属性 true",
        "actionDisplay": "String //执行动作描述",
        "extraProperty": {},
        "actionDisplayNew": {},
        "executorType": "int //执行类型,1.dp点下发,3.设备群组dp点下发  4.场景作为动作被触发行  5.延迟动作  6.自动化作为动作被启用 7.自动化作为动作被停用",
        "iconUrl": "String //iconUrl",
        "productId": "String //产品ID",
        "orderNum": "int //顺序码"
      }
    ],
    "extendInfo": "String //扩展信息",
    "type": "int //智能联动类型 1:\"定时\",2:\"场景\",3:自动化\"",
    "roomId": "String //房间ID true",
    "deviceIds": "String[] //场景包含的单设备ID集合 false",
  }
请求示例
{
    "actions":[
        {
            "actionDisplayNew":{
                "1":[
                    "开关",
                    "关闭"
                ]
            },
            "actionExecutor":"dpIssue",
            "entityId":"6cbf5559a8f6ab224evayv",
            "entityName":"Wifi",
            "executorProperty":{
                "1":true
            },
            "executorType":1,
            "extraProperty":{
                "roomName":"AutoTest_VirtualDevices"
            },
            "iconUrl":"https://images.tuyacn.com/smart/icon/ay1528439289656kE9yz/68c5be5e667596b6c1b033559868f2bd.png",
            "productId":"qadpdqfc0kkklov3"
        }
    ],
    "areaId":"19797715",
    "name":"autoTest_Scene20464",
    "projectId":"1329400489246232576",
    "roomId":"1349285973837565952",
    "type":2
}
响应示例
{
    "actions":[
        {
            "actionDisplayNew":{
                "1":[
                    "开关",
                    "关闭"
                ]
            },
            "actionExecutor":"dpIssue",
            "entityId":"6cbf5559a8f6ab224evayv",
            "entityName":"Wifi",
            "executorProperty":{
                "1":true
            },
            "executorType":1,
            "extraProperty":{
                "roomName":"AutoTest_VirtualDevices"
            },
            "productId":"qadpdqfc0kkklov3"
        }
    ],
    "name":"autoTest_Scene20464",
    "projectId":"1329400489246232576",
    "roomId":"1349285973837565952",
    "type":2,
    "ruleId":"FmMICDM7JtFuUIBC"
}
功能描述
更新场景。
接口地址
POST /v1.0/illumination/smart/scene/update
请求参数
参见创建场景请求参数。
返回参数
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码(详情见错误码章节),成功时为空 | 
| success | Boolean | 是否成功:(true:成功,false:失败) | 
| msg | String | 请求失败的信息,成功时为空 | 
| t | Long | 返回时间戳,13 位 | 
| result | Object | 返回结果 | 
result 参数说明
参见创建场景 result 参数说明。
请求示例
参见创建场景请求示例。
响应示例
参见创建场景响应示例。
功能描述
查询执行动作的数据。
接口地址
GET /v1.0/illumination/smart/scene/action/property
请求参数
| 参数名 | 类型 | 参数类型 | 说明 | 是否必需 | 
|---|---|---|---|---|
| deviceType | String | body | 设备类型 
 | 否 | 
| roomId | String | body | 房间 ID | 否 | 
返回参数
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码(详情见错误码章节),成功时为空 | 
| success | Boolean | 是否成功:(true:成功,false:失败) | 
| msg | String | 请求失败的信息,成功时为空 | 
| t | Long | 返回时间戳,13 位 | 
| result | Object | 返回结果 | 
请求示例
{
  "deviceType": "zm"
}
响应示例
[{
	"dataPoints": [{
		"defaultValue": true,
		"dpCode": "switch_led",
		"dpId": 20,
		"dpName": "开关",
		"dpProperty": "{\"type\":\"bool\"}",
		"editable": true,
		"valueRangeJson": [
			[true, "开启"],
			[false, "关闭"]
		]
	}],
	"functionName": "开关",
	"functionType": 0,
	"productId": "nspmvtve8q1gey4o"
}, {
	"dataPoints": [{
		"defaultValue": "white",
		"dpCode": "work_mode",
		"dpId": 21,
		"dpName": "模式",
		"dpProperty": "{\"range\":[\"white\",\"colour\",\"scene\",\"music\"],\"type\":\"enum\"}",
		"editable": true,
		"valueRangeJson": [
			["white", "白光"],
			["colour", "彩光"],
			["scene", "场景"],
			["music", "音乐"]
		]
	}],
	"functionName": "模式",
	"functionType": 0,
	"productId": "nspmvtve8q1gey4o"
}, {
	"dataPoints": [{
		"defaultValue": "10",
		"dpCode": "bright_value",
		"dpId": 22,
		"dpName": "亮度值",
		"dpProperty": "{\"unit\":\"\",\"min\":10,\"max\":1000,\"scale\":0,\"step\":1,\"type\":\"value\"}",
		"editable": true
	}],
	"functionName": "亮度值",
	"functionType": 0,
	"productId": "nspmvtve8q1gey4o"
}, {
	"dataPoints": [{
		"defaultValue": "0",
		"dpCode": "countdown",
		"dpId": 26,
		"dpName": "倒计时剩余时间",
		"dpProperty": "{\"unit\":\"秒\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1,\"type\":\"value\"}",
		"editable": true
	}],
	"functionName": "倒计时剩余时间",
	"functionType": 0,
	"productId": "nspmvtve8q1gey4o"
}]
功能描述
一键执行场景
接口地址
POST /v1.0/illumination/smart/trigger
请求参数
| 参数名 | 类型 | 参数类型 | 说明 | 是否必需 | 
|---|---|---|---|---|
| ruleId | String | body | 请添加备注 | true | 
| projectId | String | body | 请添加备注 | true | 
返回参数
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码(详情见错误码章节),成功时为空 | 
| success | Boolean | 是否成功:(true:成功,false:失败) | 
| msg | String | 请求失败的信息,成功时为空 | 
| t | Long | 返回时间戳,13位 | 
| result | Object | 返回结果 | 
请求示例
{
  "ruleId": "",
  "projectId":""
}
以下为该接口常见的业务异常,更多的异常错误,参见全局错误码。
| 错误码 | 说明 | 
|---|---|
| 500 | 系统错误 | 
| 1106 | 非法权限 | 
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈