Last Updated on : 2023-06-15 05:04:34
Add automation scenes that are triggered by different conditions or actions. The maximum number of conditions: 10
, and the maximum number of actions: 50
.
POST: /v2.0/iot-03/automations
Description of body
Parameter name | Type | IN | Required | Description |
---|---|---|---|---|
name | String | true | The name of a specified automation. | |
dsl | AutomationDsl | true | The language of automation rules. | |
preconditions | Preconditions | false | The preconditions for a specified automation execution. |
Description of preconditions
Parameter name | Type | IN | Required | Description |
---|---|---|---|---|
trigger_type | String | false | The type of trigger. Valid value: timeCheck . | |
precondition_trigger_rule | Object | false | The precondition trigger rule. See the details of precondition_trigger_rule . |
Description of dsl
Parameter name | Type | IN | Required | Description |
---|---|---|---|---|
conditions | List | true | The list of automation conditions. | |
conditions_rule | String | true | The automation condition matching rules. Valid values:
| |
actions | List | true | The list of automation actions. |
Description of conditions
Parameter name | Type | IN | Required | Description |
---|---|---|---|---|
trigger_type | String | true | The condition trigger type. Valid values:
| |
trigger_id | String | true | The condition trigger ID. When trigger_type is deviceReport , trigger_id is the device ID.When trigger_type is timer , trigger_id is set to timer .When trigger_type is weather , trigger_id is set to the city ID. | |
trigger_rule | Object | true | The condition trigger rule. See the details of trigger_rule . | |
rule_num | Integer | true | The trigger condition number, used for custom condition calculation of the matching rule. The value ranges from 1 to the number of conditions, and cannot be repeated. |
Description of actions
Parameter name | Type | IN | Required | Description |
---|---|---|---|---|
execution_type | String | true | The execution type.
| |
execution_rule | Object | true | The execution rule. See the details of execution_rule . |
Parameter name | Type | Description |
---|---|---|
result | String | The automation ID. |
POST: /v2.0/iot-03/automations
{
"name": "This is an automation scene",
"dsl": {
"conditions": [
{
"trigger_type": "deviceReport",
"trigger_id": "vdevo16292691746****",
"trigger_rule": {
"status_code": "switch_led",
"comparator": "==",
"status_value": true
},
"rule_num": 1
},
{
"trigger_type": "timer",
"trigger_id": "timer",
"trigger_rule": {
"timer_format": "18:00 11 09 * 2021"
},
"rule_num": 2
},
{
"trigger_type": "weather",
"trigger_id": "101069444120988****",
"trigger_rule": {
"weather_code": "temp",
"comparator": "==",
"weather_value": 20
},
"rule_num": 3
}
],
"conditions_rule": "or",
"actions": [
{
"execution_type": "delay",
"execution_rule": {
"delay_seconds": 60
}
},
{
"execution_type": "deviceIssue",
"execution_rule": {
"execution_id": "vdevo16292691746****",
"function_code": "bright_value",
"function_value": 20
}
},
{
"execution_type": "deviceGroupIssue",
"execution_rule": {
"execution_id": "144790134147200****",
"function_code": "switch_1",
"function_value": true
}
}
]
},
"preconditions": {
"trigger_type": "timeCheck",
"precondition_trigger_rule": {
"timer_format": "09:00-23:00 * * 0,1,2,3 *"
}
}
}
{
"result": "WeapZf6D1qI6****",
"t": 1635426480637,
"success": true
}
For more information, see error code.
trigger_rule
trigger_type
is deviceReport
:Parameter name | Type | Description | Required |
---|---|---|---|
status_code | String | The device instruction. | Yes |
comparator | String | The comparator. | Yes |
status_value | Object | The device instruction value. | Yes |
trigger_type
is timer
:Parameter name | Type | Description | Required |
---|---|---|---|
timer_format | String | The scheduled trigger time. Two formats are supported.
| Yes |
trigger_type
is weather
:Parameter name | Type | Description | Required |
---|---|---|---|
weather_code | String | The weather code. | Yes |
comparator | String | The comparator. | Yes |
weather_value | Object | The value of the weather code. | Yes |
execution_rule
execution_type
is delay
:Parameter name | Type | Description | Required |
---|---|---|---|
delay_seconds | Long | The delay time. The value range is 1 to 5 × 60 × 60. Unit: second. | Yes |
execution_type
is deviceIssue
or deviceGroupIssue
:Parameter name | Type | Description | Required |
---|---|---|---|
execution_id | String | The ID of a specified device or device group. | Yes |
function_code | String | The instruction code of a device or device group. | Yes |
function_value | Object | The instruction value of a device or device group. | Yes |
precondition_trigger_rule
Parameter name | Type | Description | Required |
---|---|---|---|
timer_format | String | The timer format. The format is: [hour:min]-[hour:min] [day of month] [month] [day of week] [year]. For example, 9:30-18:00 * * 0,1,2,3,4,5,6 * (9:30 am to 6:00 pm every week) | No |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback