Last Updated on : 2023-07-14 03:01:27download
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 the specified automation scene. | |
dsl | AutomationDsl | true | The language of automation rules. | |
preconditions | Preconditions | false | The preconditions for the 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 matching rules of automation conditions. Valid values:
| |
actions | List | true | The list of automation actions. |
Description of conditions
Parameter name | Type | IN | Required | Description |
---|---|---|---|---|
trigger_type | String | true | The type of trigger. Valid values:
| |
trigger_id | String | true | The ID of the specified triggering condition. When the value of trigger_type is deviceReport , trigger_id is the device ID. When the value of trigger_type is timer , trigger_id is fixed to timer . When the value of trigger_type is weather , trigger_id is fixed to the city ID. | |
trigger_rule | Object | true | The rule of the specified triggering condition. For more information, see details of trigger_rule . | |
rule_num | Integer | true | The serial number of the specified triggering condition, 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 | Type of execution. Valid values:
| |
execution_rule | Object | true | The execution rule. See the details of execution_rule . |
Parameter name | Type | Description |
---|---|---|
result | String | The ID of the specified automation scene. |
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 the specified device or device group. | Yes |
function_code | String | The instruction code of the specified device or device group. | Yes |
function_value | Object | The instruction value of the specified 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, 09: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