Modify Scene Template

Last Updated on : 2023-06-15 05:07:37

Modify a scene template based on the scene template ID and information. The maximum number of conditions: 10, and the maximum number of actions: 50.

API address

PUT: /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.

Description of body

Parameter name Type IN Required Description
req Object body true The scene template struct.

Description of req

Parameter name Type IN Required Description
name String true The name 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.
desc String true The description 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:
  • and: All conditions are met.
  • or: Any condition is met.
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:
  • 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 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:
  • categoryIssue: sent by a specified category.
  • delay: delay action.
execution_rule Object true The execution rule. See the details of execution_rule.

Return parameter

Parameter name Type Description
result Boolean Indicates whether the operation is successful.

Request example

PUT: /v1.0/iot-03/scene-templates/189***01
{ "dsl": { "actions": [ { "execution_rule": { "execution_id": "fskg", "function_code": "switch_fan", "function_value": true }, "execution_type": "categoryIssue" }, { "execution_rule": { "delay_seconds": 100 }, "execution_type": "delay" }, { "execution_rule": { "execution_id": "fskg", "function_code": "switch_fan", "function_value": false }, "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 * * 0,1,2,3,4,5,6 *" }, "trigger_type": "timer" } ], "conditions_rule": "or" }, "name": "Update Template", "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" } }

Return example

{ "result": true, "t": 1636545567882, "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