Last Updated on : 2024-06-29 02:09:53download
Create a linkage rule based on conditions and actions that are passed in.
POST: /v2.0/cloud/scene/rule
Description of body
| Parameter name | Type | IN | Required | Description |
|---|---|---|---|---|
| space_id | String | body | true | The ID of the specified space that is associated with the linkage rule. |
| name | String | body | true | The name of the specified linkage rule. |
| type | String | body | true | The type of linkage. Valid values:
|
| decision_expr | String | body | true | The condition expression. Valid values:
|
| conditions | List | body | false | The collection of conditions. This parameter is optional when the linkage type is tap-to-run, and required when the linkage type is automation. |
| actions | List | body | true | The collection of actions. |
| effective_time | EffectiveTime | body | false | The time when the specified linkage rule takes effect. |
Description of effective_time
| Parameter name | Type | IN | Required | Description |
|---|---|---|---|---|
| start | String | body | true | The start time. |
| end | String | body | true | The end time. |
| loops | String | body | true | The cycle when the specified linkage rule is triggered. The value is a seven-digit number consisting of 0 and 1. 0 means disabled and 1 means enabled. The first digit represents Sunday and the other digits represent Monday to Saturday sequentially. For example, 0011000 represents a scheduled task is executed every Tuesday and Wednesday. |
| time_zone_id | String | body | true | The ID of the specified time zone. |
Description of conditions
| Parameter name | Type | IN | Required | Description |
|---|---|---|---|---|
| entity_id | String | body | true | The object ID of the specified condition. |
| entity_type | String | body | true | The object type of the specified condition. Valid values:
|
| code | Integer | body | true | The unique code of the specified condition. |
| expr | Expr | body | true | The calculation expression. |
Description of actions
| Parameter name | Type | IN | Required | Description |
|---|---|---|---|---|
| entity_id | String | body | true | The object ID of the specified action. |
| action_executor | String | body | true | The object type of the specified action. Valid values:
|
| executor_property | ExecutorProperty | body | true | The details of the specified action. |
Description of expr
| Parameter name | Type | IN | Required | Description |
|---|---|---|---|---|
| status_code | String | body | true | The code of the specified status. This parameter is required when entity_type is device_report. |
| comparator | String | body | true | The comparison expression. This parameter is required when entity_type is device_report and weather. Valid values:
|
| status_value | Object | body | true | The value of the specified status. This parameter is required when entity_type is device_report. |
| date | String | body | false | The date when the specified linkage rule is triggered. |
| time | String | body | true | The time when the specified linkage rule is triggered. |
| loops | String | body | false | The cycle when the specified linkage rule is triggered. The value is a seven-digit number consisting of 0 and 1. 0 means disabled and 1 means enabled. The first digit represents Sunday and the other digits represent Monday to Saturday sequentially. For example, 0011000 represents a scheduled task is executed every Tuesday and Wednesday. |
| time_zone_id | String | body | true | The ID of the specified time zone. |
| weather_code | String | body | true | The code of the specified status. This parameter is required when entity_type is weather. |
| weather_value | Object | body | true | The value of the specified status. This parameter is required when entity_type is weather. |
Description of executor_property
| Parameter name | Type | IN | Required | Description |
|---|---|---|---|---|
| function_code | String | body | true | The code of the specified instruction. This parameter is required when action_executor is device_issue or device_group_issue. |
| function_value | Object | body | true | The value of the specified instruction. This parameter is required when action_executor is device_issue or device_group_issue. |
| delay_seconds | Integer | body | true | The delay time. This parameter is required when action_executor is delay. |
| Parameter name | Type | Description |
|---|---|---|
| result | LinkageAddResponse | The returned result. |
Description of result
| Parameter name | Type | Description |
|---|---|---|
| id | String | The ID of the specified linkage rule. |
POST: /v2.0/cloud/scene/rule
{
"space_id": "150***",
"name": "Test Scene",
"type": "automation",
"decision_expr": "or",
"effective_time": {
"start": "00:00",
"end": "23:00",
"loops": "1111111",
"timezone_id": "Asia/Shanghai"
},
"conditions": [
{
"code": 1,
"entity_id": "****",
"entity_type": "device_report",
"expr": {
"status_code": "switch_1",
"comparator": "==",
"status_value": true
}
}
],
"actions": [
{
"entity_id": "****",
"action_executor": "device_issue",
"executor_property": {
"function_code": "switch_1",
"function_value": true
}
}
]
}
{
"tid": "***",
"result": {
"id": "***"
},
"t": 1677742076308,
"success": true
}
For more information, see error code.
For more information, see Limits on API Request Frequency.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback