Add Scene Linkage

Last Updated on : 2021-11-02 02:51:38download

Add a scene linkage. Specific conditions can trigger devices and device groups to implement linkage under the specified scene.

API address

POST: /v1.0/iot-03/automations

Request parameter

Description of body

Parameter name Type IN Required Description
name String true The name of a specified scene linkage.
conditions List true The trigger condition.
actions List true The executed actions.
match_type Integer true Indicates the matching types.
  • 1: Trigger when any condition is met.
  • 2: Trigger when all conditions are met.
  • 3: Trigger when the custom conditions are met. Set the logic operation parameter condition_rule.
condition_rule String false Custom condition rules. This parameter is required when match_type is 3. The custom condition rules follow the AND OR formula. Each automation condition is identified by its order_num. For example, in the expression of c1 && c2, we can see that c1 and c2 respectively represent the calculation results of the expressions where order_num is 1 and 2.
preconditions List false The preconditions with the highest priority.

Description of preconditions

Parameter name Type IN Required Description
cond_type String true The type of preconditions. According to effective time, set timeCheck to a fixed value.
display JSONObject true Shows the conditions. See details of the request parameters.

Description of conditions

Parameter name Type IN Required Description
entity_type Integer true The type of a specified condition. Valid values:
  • 1: device status condition.
  • 3: weather condition.
  • 6: scheduled condition.
display JSONObject true Shows the conditions.
order_num Integer true The serial number of a specified condition, starting from 1.
entity_id String true The ID of a specified entity that executes the action.
  • When entity_type is 1, the value of entity_id is the device ID. Required.
  • When entity_type is 3, the value of entity_id is city ID.
  • When entity_type is 6, the value of entity_id is timer.

Description of actions

Parameter name Type IN Required Description
entity_id String true Indicates the target ID.
  • When action_executor is dpIssue, the value of entity_id is the device ID.
  • When action_executor is deviceGroupDpIssue, the value of entity_id is the group ID.
  • When action_executor is warnReport, the value of entity_id is the linkage alarm.
executor_property List true The parameter of the executed action. When action_executor is warnReport, the value can be empty.
action_executor String true The type of the execution action:
  • dpIssue: the action of a device.
  • deviceGroupDpIssue: the action of a device group.
  • warnReport: the action of an alert.

Description of executor_property

Parameter name Type IN Required Description
code String true The code of the data point (DP).
value Object true The value of the DP.

Return parameter

Parameter name Type Description
result String The ID of a scene linkage.

Request example

POST: /v1.0/iot-03/automations
{ "name": "xxx", "match_type": 3, "condition_rule": "c1||c2||c3", "preconditions": [ { "cond_type": "timeCheck", "display": { "start": "01:00", "end": "23:00", "time_interval": "custom", "loops": "1111111", "time_zone_id": "Asia/Shanghai" } } ], "conditions": [ { "entity_id": "vdevo33333333333333", "entity_type": 1, "order_num": 1, "display": { "code": "switch_led", "operator": "==", "value": true } }, { "entity_id": "1001803662567473213", "entity_type": 3, "order_num": 2, "display": { "code": "sunsetrise", "operator": "==", "value": "sunset" } }, { "entity_id": "timer", "entity_type": 6, "order_num": 3, "display": { "date": "20210616", "loops": "1111111", "time": "16:16", "time_zone_id": "Asia/Shanghai" } } ], "actions": [ { "entity_id": "140433911111111111", "action_executor": "deviceGroupDpIssue", "executor_property": [ { "code": "switch_led", "value": true } ] }, { "entity_id": "vdevo33333333333333", "action_executor": "dpIssue", "executor_property": [ { "code": "bright_value", "value": 50 } ] } ] }

Return example

{ "result": "xxxxxx", "t": 1111111111111, "success": true }

Error code

For more information, see error code.