Get Details of Scene Template

Last Updated on : 2021-11-26 02:54:56download

Get the details of a scene template based on the scene template ID.

API address

GET: /v1.0/iot-03/scene-templates/{template_id}

Request parameter

Parameter name Type IN Required Description
template_id Long uri true The ID of a specified scene template.

Return parameter

Parameter name Type Description
result SceneTemplateRes The returned result.

Description of result

Parameter name Type Description
name String The name of a specified scene template.
desc String The description of a specified scene template.
dsl Object The rule language of a specified scene template.
preconditions Object The preconditions of a specified scene template.

Description of preconditions

Parameter name Type Description
trigger_type String The type of trigger. Valid value: timeCheck.
trigger_rule Object The precondition trigger rule. See the details of trigger_rule.

Description of dsl

Parameter name Type Description
conditions List The list of scene template conditions.
conditions_rule String The condition matching rules of scene templates. Valid values:
  • and: All conditions are met.
  • or: Any condition is met.
actions List The list of scene template actions.

Description of conditions

Parameter name Type Description
trigger_type String The condition trigger type. Valid values:
  • categoryReport: It is triggered when a specified category reports data.
  • timer: It is triggered at the scheduled time.
  • weather: It is triggered by the specified weather condition.
trigger_id String 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 The condition trigger rule. See the details of trigger_rule in conditions.
rule_num Integer 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 Description
execution_type String The execution type. Valid values:
  • categoryIssue: sent by a specified category.
  • delay: delay action.
execution_rule Object The execution rule. See the details of execution_rule.

Request example

GET: /v1.0/iot-03/scene-templates/18*****8

Return example

{ "result": { "preconditions": { "trigger_rule": { "timer_format": "00:00-23:59 * * 0,1,2,3,4,5,6 *" }, "trigger_type": "timeCheck" }, "name": "Linkage Template", "dsl": { "conditions_rule": "or", "conditions": [ { "rule_num": 1, "trigger_rule": { "status_code": "switch_led", "status_value": true, "comparator": "==" }, "trigger_id": "dj", "trigger_type": "categoryReport" } ], "actions": [ { "execution_rule": { "execution_id": "fskg", "function_value": true, "function_code": "switch_fan" }, "execution_type": "categoryIssue" } ] }, "desc": "The second template" }, "t": 1636613445945, "success": true }

Error code

For more information, see error code.

Details of trigger_rule in conditions

  1. When 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
  1. When trigger_type is timer:
Parameter name Type Description Required
timer_format String The scheduled trigger time. Two formats are supported.
  • Specify the scheduled date in the format such as: [hour:min] [day of month] [month] [day of week] [year]. For example, 20:00 20 10 * 2021 (October 20, 2021, 8:00 pm).
  • Specify the weekly cycle timer in the format such as: [hour:min] [day of month] [month] [day of week] [year]. For example, 20:00 * * 0,1,2,3 * (every Sunday, Monday, Tuesday, and Wednesday at 8:00 pm).
Yes
  1. When 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

Details of execution_rule

  1. When 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
  1. When 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

Details of 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