Last Updated on : 2023-06-15 05:07:48
Add scene templates that are triggered by different conditions or actions. The maximum number of conditions: 10
, and the maximum number of actions: 50
.
POST: /v1.0/iot-03/scene-templates
Description of body
Parameter name | Type | IN | Required | Description |
---|---|---|---|---|
name | String | true | The name of a specified scene template. | |
desc | String | true | The description of a specified scene template. | |
dsl | Object | true | The rule language of a specified scene template. | |
preconditions | Object | false | The preconditions of a specified scene template. |
Description of preconditions
Parameter name | Type | IN | Required | Description |
---|---|---|---|---|
trigger_type | String | false | The type of trigger. Valid value: timeCheck . | |
trigger_rule | Object | false | The precondition trigger rule. See the details of trigger_rule . |
Description of dsl
Parameter name | Type | IN | Required | Description |
---|---|---|---|---|
conditions | List | true | The list of scene template conditions. | |
conditions_rule | String | true | The condition matching rules of scene templates. Valid values:
| |
actions | List | true | The list of scene template 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 categoryReport , trigger_id is the category 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 in conditions . | |
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. Valid values:
| |
execution_rule | Object | true | The execution rule. See the details of execution_rule . |
Parameter name | Type | Description |
---|---|---|
result | Long | The ID of a specified scene template. |
POST: /v1.0/iot-03/scene-templates
{
"dsl": {
"actions": [
{
"execution_rule": {
"execution_id": "fskg",
"function_code": "switch_fan",
"function_value": true
},
"execution_type": "categoryIssue"
}
],
"conditions": [
{
"rule_num": 1,
"trigger_id": "dj",
"trigger_rule": {
"comparator": "==",
"status_code": "switch_led",
"status_value": true
},
"trigger_type": "categoryReport"
},
{
"rule_num": 2,
"trigger_id": "793409547065757***",
"trigger_rule": {
"comparator": "<",
"weather_code": "temp",
"weather_value": 20
},
"trigger_type": "weather"
},
{
"rule_num": 3,
"trigger_id": "timer",
"trigger_rule": {
"timer_format": "20:59 5 5 * 2021"
},
"trigger_type": "timer"
}
],
"conditions_rule": "or"
},
"name": "Test 1",
"desc": "The first weather timer template",
"preconditions": {
"trigger_rule": {
"timer_format": "00:00-23:59 * * 0,1,2,3,4,5,6 *"
},
"trigger_type": "timeCheck"
}
}
{
"result": "19**1007",
"t": 1636546481484,
"success": true
}
For more information, see error code.
trigger_rule
in conditions
trigger_type
is categoryReport
: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 categoryIssue
:Parameter name | Type | Description | Required |
---|---|---|---|
execution_id | String | The ID of a specified category. | Yes |
function_code | String | The instruction code of a category. | Yes |
function_value | Object | The instruction value of a category. | Yes |
trigger_rule
in preconditions
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) | Yes |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback