Add Tap-to-Run

Last Updated on : 2023-06-15 05:05:14

Add tap-to-run scenes of different actions. The maximum number of actions is 50.

API address

POST: /v2.0/iot-03/scenes

Request parameter

Description of body

Parameter nameTypeINRequiredDescription
nameString trueThe name of a specified tap-to-run scene.
dslSceneDsl trueThe language of tap-to-run rules.

Description of dsl

Parameter nameTypeINRequiredDescription
actionsList trueThe list of tap-to-run actions.

Description of actions

Parameter nameTypeINRequiredDescription
execution_typeString trueThe execution type.
  • deviceIssue: sent by a device.
  • deviceGroupIssue: sent by a device group.
  • delay: delay action.
execution_ruleObject trueThe execution rule. See the details of execution_rule.

Return parameter

Parameter nameTypeDescription
resultStringThe ID of a tap-to-run scene.

Request example

POST: /v2.0/iot-03/scenes
{
  "name": "This is a tap-to-run",
  "dsl": {
    "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
        }
      }
    ]
  }
}

Return example

{
    "result": "OrVvumqZ6G0g****",
    "t": 1635845369037,
    "success": true
}

Error code

For more information, see error code.

Details of execution_rule

  • When execution_type is delay:

    Parameter nameTypeDescriptionRequired
    delay_secondsLongThe delay time. The value range is 1 to 5 × 60 × 60. Unit: second.Yes
  • When execution_type is deviceIssue or deviceGroupIssue:

    Parameter nameTypeDescriptionRequired
    execution_idStringThe ID of a specified device or device group.Yes
    function_codeStringThe instruction code of a device or device group.Yes
    function_valueObjectThe instruction value of a device or device group.Yes