Last Updated on : 2021-09-18 08:24:01download
Request method | API endpoint | Description |
---|---|---|
GET | /v1.0/illumination/smart/linkage(schedule)/list | Query the list of smart linkage |
GET | /v1.0/illumination/smart/linkage(schedule)/{id} | Query linkage details |
POST | /v1.0/illumination/smart/linkage(schedule)/add | Create a smart linkage |
POST | /v1.0/illumination/smart/linkage(schedule)/update | Update a smart leakage |
GET | /v1.0/illumination/smart/condition/list | Query the condition that triggers an action |
POST | /v1.0/illumination/smart/change-status | Enable or disable a rule |
POST | /v1.0/illumination/smart/remove | Remove a linkage rule |
API description
Get a list of smart linkages under a specified project.
API endpoint
Linkage: GET /v1.0/illumination/smart/linkage/list
Schedule: GET /v1.0/illumination/smart/schedule/list
Request parameter
Name | Type | Location | Description | Required |
---|---|---|---|---|
projectId | String | body | The project ID. | No |
Return parameter
Name | Type | Description |
---|---|---|
code | Integer | The response code. For more information, see the error code section. It is empty when the operation succeeded. |
success | Boolean | Indicate whether the operation succeeds.
|
msg | String | The error message that is returned if the request fails. It is empty if the request is successful. |
t | Long | The returned 13-bit timestamp. |
result | Object | The request result. |
Description of result
[
{
"ruleId": "String // The ruleId of the smart linkage. The value is used during updating",
"name": "String // The name",
"projectId": "String // The project ID",
"background": "String // The background image",
"displayIcon": "String // The icon to be displayed on the homepage",
"displayColor": "String // The color",
"actions": [
{
"id": "String // The action ID of the smart linkage. The value is used during updating",
"entityId": "String // The ID of the execution object",
"entityName": "String // The name of the execution object",
"executorProperty": {},
"actionExecutor": "String // The property of the execution action",
"actionDisplay": "String // The description of the execution action",
"extraProperty": {},
"actionDisplayNew": {},
"executorType": "int // The execution type. 1. Send a data point (DP). 3. Send a device group DP. 4. The scene is triggered as an action. 5. Delay an action. 6. The automation is enabled as an action. 7. The automation is disabled as an action.",
"iconUrl": "String // The URL address of the icon",
"productId": "String // The product ID",
"orderNum": "int // The sequence code"
}
],
"extendInfo": "String // Extended information",
"enabled": "boolean // Indicate whether it is enabled"
"preConditions": [
{
"id": "String // The precondition ID. The value is used during updating",
"condType": "String // The condition type. According to effective time, set to `timeCheck` for a fixed value",
"expr": {}
}
],
"conditions": [
{
"id": "String // The condition ID, which is used during updating",
"entityType": "int // The condition type. `entityType\u003d6`: Trigger at a specified time. `entityType\u003d1`: Trigger when the device is changed",
"entityId": "String // The ID of the entity that triggers the condition. Enter `timer` for the timing type",
"entitySubIds": "String // The `subID` of the entity that triggers the condition. Enter `dpId` for a device and `timer` for the timing type",
"entityName": "String // The name of the entity that triggers the condition",
"expr": {},
"exprDisplay": "String // Display as a conditional expression",
"orderNum": "int // The sequence"
"extraInfo": {},
"iconUrl": "String // The URL address of the icon",
"extra": "String // The additional information",
"productId": "String // The product ID"
}
],
"matchType": "int //matchType // `MatchType` enumeration. `1`: Triggered by any condition. `2`: Triggered when all conditions are met
}
]
Sample request
{
"projectId": ""
}
Sample response
{
"actions":[
{
"actionDisplayNew":{
"1":[
"Switch",
"On"
]
},
"actionExecutor":"dpIssue",
"entityId":"6cc5e16f547d3087easkej",
"entityName":"Staircase ceiling spotlight 2",
"executorProperty":{
"1":true
},
"executorType":1,
"extraProperty":{
"roomName":"Restaurant"
},
"iconUrl":"https://images.tuyacn.com/smart/icon/bay1603698514323MDS1/dde808cefa3622daada79f1379833d97.png",
"productId":"gmlvm3kc"
}
],
"conditions":[
{
"entityId":"54360746500291caa950",
"entitySubIds":"1",
"entityType":1,
"expr":[
[
"$dp1",
"==",
true
]
],
"extraInfo":{
"areaId":20696183
}
}
],
"displayColor":"50657A",
"matchType":1,
"name":"On",
"ruleId":"Gi7c4DG872VE0y7v",
"preConditions":[
"expr": {
"start": "00:00",
"end": "23:59",
"timeInterval": "allDay",
"loops": "1111111",
"timeZoneId": "Asia/Shanghai"
},
"condType": "timeCheck" // A fixed value
],
"projectId":"1353534067387195392",
"type":3
}
API description
Query linkage details by ruleID
.
API endpoint
Linkage: GET /v1.0/illumination/smart/linkage/{id}
Schedule: GET /v1.0/illumination/smart/schedule/{id}
Request parameter
Name | Type | Location | Description | Required |
---|---|---|---|---|
id | String | url | ruleID | No |
Return parameter
Name | Type | Description |
---|---|---|
code | Integer | The response code. For more information, see the error code section. It is empty when the operation succeeded. |
success | Boolean | Indicate whether the operation succeeds.
|
msg | String | The error message that is returned if the request fails. It is empty if the request is successful. |
t | Long | The returned 13-bit timestamp. |
result | Object | The request result. |
Description of result
For more information about the result parameter
, see Query the list of smart linkage.
Sample request
{
"id": ""
}
Sample response
For more information about the sample response, see Query the list of smart linkage.
API description
Create a smart linkage.
API endpoint
Linkage: POST /v1.0/illumination/smart/linkage/add
Schedule: GET /v1.0/illumination/smart/schedule/add
Request parameter
Name |
Type |
Location |
Description |
Required |
---|---|---|---|---|
ruleId | String | body | The ruleId of the smart linkage. The value is used during updating. |
No |
name | String | body | The name of the smart linkage. | No |
projectId | String | body | The project ID. | No |
background | String | body | The background image. | No |
displayIcon | String | body | The icon displayed on the homepage. | No |
displayColor | String | body | The color. | No |
actions.id | String | body | The action ID of the smart linkage. The value is used during updating. | No |
actions.entityId | String | body | The ID of the execution object. | No |
actions.entityName | String | body | The name of the execution object. | No |
actions.executorProperty | Object | body | The property of the execution action. | No |
actions.actionExecutor | String | body | The property of the execution action. | No |
actions.actionDisplay | String | body | The description of the execution action. | No |
actions.extraProperty | Object | body | The additional information. | No |
actions.actionDisplayNew | Object | body | The description of DP actions. | No |
actions.executorType | int | body | The execution type.
|
No |
actions.iconUrl | String | body | iconUrl | No |
actions.productId | String | body | The product ID. | No |
actions.orderNum | int | body | The sequence code. | No |
extendInfo | String | body | The extension information. | No |
enabled | boolean | body | Indicate whether it is enabled. | No |
preConditions.id | String | body | The precondition ID, which is used during updating. | No |
preConditions.condType | String | body | The condition type. According to effective time, set to timeCheck to a fixed value. |
No |
preConditions.expr | Object | body | The precondition for the effective time type. | No |
conditions.id | String | body | The condition ID, which is used during updating. | No |
conditions.entityType | int | body | The condition type. Valid values:
|
No |
conditions.entityId | String | body | The ID of the entity that triggers the condition. Enter timer for the timing type. |
No |
conditions.entitySubIds | String | body | The subID of the entity that triggers the condition. Set the device type to the value of dpId and set the timing type to timer . |
No |
conditions.entityName | String | body | The name of the entity that triggers the condition. | No |
conditions.expr | Object | body | Condition expression. | No |
conditions.exprDisplay | String | body | Displayed as a condition expression. | No |
conditions.orderNum | int | body | The sequence. | No |
conditions.extraInfo | Object | body | The additional information. | No |
conditions.iconUrl | String | body | iconURL | No |
conditions.extra | String | body | The additional information. | No |
conditions.productId | String | body | The product ID. | No |
matchType | int | body | The matching type. Valid values:
|
No |
Return parameter
Name | Type | Description |
---|---|---|
code | Integer | The response code. For more information, see the error code section. It is empty when the operation succeeded. |
success | Boolean | Indicate whether the operation succeeds.
|
msg | String | The error message that is returned if the request fails. It is empty if the request is successful. |
t | Long | The returned 13-bit timestamp. |
result | Object | The request result. |
Description of result
For more information about the result parameter
, see Query the list of smart linkage.
Sample request
{
"id": "zrwcA9OOL5Xm60uX", // The rule ID, which is used during updating.
"name": "asdf", // The rule name.
"matchType": 1, // `MatchType` enumeration. 1. Triggered by any condition. 2. Triggered when all conditions are met.
"enabled": true, // Enable or disable the rule.
"preConditions": [{
"id": "8EWSCpvD4nIqyWEY7UnH", // The precondition ID, which is used during updating.
"expr": {
"start": "00:00", // The start time. It is customized when `timeInterval` is `custom`, and defaults to `00:00` in other cases.
"end": "23:59", // The end time. It is customized when `timeInterval` is set to `custom`, and defaults to `23:59` in other cases.
"timeInterval": "allDay", // `PrecondTimeInterval` type. `custom`: in the custom mode. `allDay`: all the day. `daytime`: in the daytime. `night`: at night.
"loops": "1111111", // Mark in the order of 7123456. For example, `0001100` indicates every Wednesday and Thursday, and `0000000` indicates that it will be executed only once.
"timeZoneId": "Asia/Shanghai"
},
"condType": "timeCheck" // A fixed value.
}],
"conditions": [{
"id": "6Rmmw1IemKLAdJcAjraA", // The condition ID, which is used during updating.
"entityType": 6, // `entityType` is set to `6`. The value means to trigger at a specified time.
"entityId": "timer", // A fixed value.
"entitySubIds": "timer", // A fixed value.
"iconUrl": null, // An image.
"expr": [{
"timezoneId": "Asia/Shanghai", // A region.
"loops": "1111111", // Mark in the order of 7123456. For example, `0001100` indicates every Wednesday and Thursday, and `0000000` indicates that it will be executed only once.
"time": "16:23", // The time in the format of `HH:mm`.
"date": "20200228" // The date in the format of `yyyymmdd`.
}],
"extraInfo": {} // The additional information. No new JSONObject().
}, {
"id": "ZdWfwe84rEU5TcB4QSXt",
"entityType": 1, // `entityType` is set to `1`. The value means to report the DP to the cloud.
"entityId": "vdevo158460807245873", // The device ID that is specified by`devId`.
"entitySubIds": "21", // The device DP that is specified by `dpId`.
"iconUrl": "https://images.tuyacn.com/smart/rule/env/_new.png", // The image path.
"expr": [
["$dp21", "==", "colour"]
],// The rule expression.
"extraInfo": {} // The additional information. No new JSONObject().
}],
"actions": [{
"id": "VFz0PAgRKNWJjm7IbZja", // The action ID, which is used during updating.
"entityId": "vdevo157767633987152", // The device ID.
"actionExecutor": "dpIssue", // Send the DP.
"executorProperty": {
"1": true
}, // The action execution information. key: dpId, value: dpValue
"extraProperty": {}, // The additional information. No new JSONObject().
},{
"id": "xxx",
"entityId": "delay", // Delay the action.
"actionExecutor": "delay", // Delay the action.
"executorProperty": {
"minutes": "1", // The amount of time in minutes.
"seconds":"1" // The amount of time in seconds.
},
"extraProperty": {}, // The additional information. No new JSONObject().
}, {
"id": "xxx",
"entityId": "", // The scene ID.
"actionExecutor": "ruleTrigger", // The scene is triggered as an action.
"executorProperty": {},
"extraProperty": {},
}, {
"id": "xxx",
"entityId": "", // The automation ID.
"actionExecutor": "ruleEnable", // Automation is enabled as an action.
"executorProperty": {},
"extraProperty": {},
}]
}
Sample response
For more information about the sample response, see Query the list of smart linkage.
API description
Update a smart linkage.
API endpoint
Linkage: POST /v1.0/illumination/smart/linkage/update
Schedule: GET /v1.0/illumination/smart/schedule/update
Request parameter
For more information about the sample request, see Create a smart linkage.
Return parameter
For more information about the sample response, see Create a smart linkage.
API description
Query the condition that triggers an action.
API endpoint
GET /v1.0/illumination/smart/condition/list
Request parameter
Name | Type | Location | Description | Required |
---|---|---|---|---|
productId | String | body | Add comments | No |
Return parameter
Name | Type | Description |
---|---|---|
code | Integer | The response code. For more information, see the error code section. It is empty when the operation succeeded. |
success | Boolean | Indicate whether the operation succeeds.
|
msg | String | The error message that is returned if the request fails. It is empty if the request is successful. |
t | Long | The returned 13-bit timestamp. |
result | Object | The request result. |
Description of result
LinkageConditionSourceVO[]
Sample request
{
"productId": ""
}
Sample response
{
"entityId": "nspmvtve8q1gey4o",
"entityName": "Switch",
"entitySubId": "20",
"entityType": 1,
"id": 4423246,
"name":"Switch",
"operators": "[\"==\"]",
"property": {
"mode": "rw",
"code": "switch_led",
"name": "Switch",
"property": {
"type": "bool"
},
"iconname": "icon-dp_power2",
"id": 20,
"type": "obj",
"attr": 3,
"desc": ""
},
"trigger": 0,
"triggerStrategy": "",
"valueRangeDisplay": "Boolean type: [[true,\"on\"],[false,\"Off\"]]",
"valueRangeJson": [
[true, "On"],
[false, "Off"]
]
}, {
"entityId": "nspmvtve8q1gey4o",
"entityName": "Mode",
"entitySubId": "21",
"entityType": 1,
"id": 4423247,
"name":"Mode",
"operators": "[\"==\"]",
"property": {
"mode": "rw",
"code": "work_mode",
"name":"Mode",
"property": {
"range": ["white", "colour", "scene", "music"],
"type": "enum"
},
"iconname": "icon-dp_list",
"id": 21,
"type": "obj",
"attr": 0,
"desc": ""
},
"trigger": 0,
"triggerStrategy": "",
"valueRangeDisplay": "Enumeration:[[\"white\",\"whie light\"],[\"colour\",\"colored light\"],[\"scene\",\"scene\ "],[\"music\",\"music\"]]",
"valueRangeJson": [
["white", "white light"],
["colour", "colored light"],
["scene", "scene"],
["music", "music"]
]
}, {
"entityId": "nspmvtve8q1gey4o",
"entityName": "Brightness value",
"entitySubId": "22",
"entityType": 1,
"id": 4423248,
"name":"Brightness",
"operators": "[\"<\",\"==\",\">\"]",
"property": {
"mode": "rw",
"code": "bright_value",
"name": "Brightness value",
"property": {
"unit": "",
"min": 10,
"max": 1000,
"scale": 0,
"step": 1,
"type": "value"
},
"iconname": "icon-dp_light2",
"id": 22,
"type": "obj",
"attr": 2,
"desc": ""
},
"trigger": 0,
"triggerStrategy": "",
"valueRangeDisplay": "Numeric:{\"unit\":\"\",\"min\":10,\"max\":1000,\"scale\":0,\"step\": 1,\"type\":\"value\"}"
}, {
"entityId": "nspmvtve8q1gey4o",
"entityName": "The remaining time of the countdown",
"entitySubId": "26",
"entityType": 1,
"id": 4423249,
"name": "The remaining time of the countdown",
"operators": "[\"<\",\"==\",\">\"]",
"property": {
"mode": "rw",
"code": "countdown",
"name": "The remaining time of the countdown",
"property": {
"unit": "Second",
"min": 0,
"max": 86400,
"scale": 0,
"step": 1,
"type": "value"
},
"iconname": "icon-timer1",
"id": 26,
"type": "obj",
"attr": 2,
"desc": ""
},
"trigger": 0,
"triggerStrategy": "",
"valueRangeDisplay": "Numeric:{\"unit\":\"seconds\",\"min\":0,\"max\":86400,\"scale\":0,\"step\" :1,\"type\":\"value\"}"
}
API description
Enable or disable a rule.
API endpoint
POST /v1.0/illumination/smart/change-status
Request parameter
Name | Type | Location | Description | Required |
---|---|---|---|---|
ruleId | String | body | The ID of a rule. | No |
enabled | boolean | body | Specify whether to enable a rule. | No |
Return parameter
Name | Type | Description |
---|---|---|
code | Integer | The response code. For more information, see the error code section. It is empty when the operation succeeded. |
success | Boolean | Indicate whether the operation succeeds.
|
msg | String | The error message that is returned if the request fails. It is empty if the request is successful. |
t | Long | The returned 13-bit timestamp. |
result | Object | The request result. |
Description of result
{}
Sample request
{
"ruleId": "",
"enabled": ""
}
API description
Remove a linkage rule.
API endpoint
POST /v1.0/illumination/smart/remove
Request parameter
Name | Type | Location | Description | Required |
---|---|---|---|---|
ruleId | String | body | The ID of a rule. | No |
Return parameter
Name | Type | Description |
---|---|---|
code | Integer | The response code. For more information, see the error code section. It is empty when the operation succeeded. |
success | Boolean | Indicate whether the operation succeeds.
|
msg | String | The error message that is returned if the request fails. It is empty if the request is successful. |
t | Long | The returned 13-bit timestamp. |
result | Object | The request result. |
Description of result
{}
Sample request
{
"ruleId": ""
}
The following table describes common error codes for this API. For more information, see Error Code.
Error code | Description |
---|---|
500 | The error message is returned because a system error has occurred. |
1106 | The error message is returned because you are not authorized to make the API request. |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback