更新时间:2023-06-15 05:07:37
本文介绍修改场景模板的 API。
通过模板ID和模板信息,修改场景模板。条件个数上限10个,动作个数上限50个。
PUT: /v1.0/iot-03/scene-templates/{template_id}
| 参数名 | 类型 | 参数位置 | 是否必填 | 说明 | 
|---|---|---|---|---|
| template_id | Long | uri | true | 场景模板id | 
body 说明
| 参数名 | 类型 | 参数位置 | 是否必填 | 说明 | 
|---|---|---|---|---|
| req | Object | body | true | 场景模板结构体 | 
req 说明
| 参数名 | 类型 | 参数位置 | 是否必填 | 说明 | 
|---|---|---|---|---|
| name | String | true | 场景模板名称 | |
| dsl | Object | true | 场景模板规则语言 | |
| preconditions | Object | false | 场景模板前置条件 | |
| desc | String | true | 场景模板描述 | 
preconditions 说明
| 参数名 | 类型 | 参数位置 | 是否必填 | 说明 | 
|---|---|---|---|---|
| trigger_type | String | false | 触发类型。目前只有 timeCheck。 | |
| trigger_rule | Object | false | 前置条件触发规则。见前置条件的trigger_rule 详细说明。 | 
dsl 说明
| 参数名 | 类型 | 参数位置 | 是否必填 | 说明 | 
|---|---|---|---|---|
| conditions | List | true | 场景模板条件列表 | |
| conditions_rule | String | true | 场景模板条件匹配规则:
  | 
|
| actions | List | true | 场景模板动作列表 | 
conditions 说明
| 参数名 | 类型 | 参数位置 | 是否必填 | 说明 | 
|---|---|---|---|---|
| trigger_type | String | true | 触发类型:
  | 
|
| trigger_id | String | true | 条件触发 ID: 条件触发类型 trigger_type为categoryReport时,trigger_id为品类码;条件触发类型 trigger_type为timer时,trigger_id固定为timer;条件触发类型 trigger_type为weather时,trigger_id固定城市 ID。 | 
|
| trigger_rule | Object | true | 条件触发规则。见conditions的trigger_rule详细说明 | 
|
| rule_num | Integer | true | 触发条件编号,用于条件匹配规则自定义条件计算。取值范围为1~条件的个数,且不能重复。 | 
actions 说明
| 参数名 | 类型 | 参数位置 | 是否必填 | 说明 | 
|---|---|---|---|---|
| execution_type | String | true | 执行类型:
  | 
|
| execution_rule | Object | true | 执行规则。见 execution_rule 详细说明。 | 
| 参数名 | 类型 | 说明 | 
|---|---|---|
| result | Boolean | 是否更新成功 | 
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": "793409547065757696",
        "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": "bulu-更新模板",
  "desc": "第一天气定时模板",
  "preconditions": {
    "trigger_rule": {
      "timer_format": "00:00-23:59 * * 0,1,2,3,4,5,6 *"
    },
    "trigger_type": "timeCheck"
  }
}
{
    "result": true,
    "t": 1636545567882,
    "success": true
}
参考 错误码。
1、当 trigger_type 为categoryReport时:
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| status_code | String | 设备指令 | 是 | 
| comparator | String | 比较符 | 是 | 
| status_value | Object | 设备指令值 | 是 | 
2、当 trigger_type 为timer时:
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| timer_format | String | 定时触发时间。支持两种格式:
  | 
是 | 
3、当trigger_type为weather时:
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| weather_code | String | 天气码 | 是 | 
| comparator | String | 比较符 | 是 | 
| weather_value | Object | 天气码值 | 是 | 
1、当execution_type为delay时:
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| delay_seconds | Long | 延时时间,取值范围 1~5 * 60 * 60,单位:秒 | 是 | 
2、当execution_type为categoryIssue时:
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| execution_id | String | 品类码 | 是 | 
| function_code | String | 品类支持的指令码 | 是 | 
| function_value | Object | 品类支持的指令值 | 是 | 
| 参数名 | 类型 | 描述 | 必填 | 
|---|---|---|---|
| timer_format | String | 定时格式。格式为: [hour:min]-[hour:min] [day of month] [month] [day of week] [year],例如: 9:30-18:00 * * 0,1,2,3,4,5,6 * (每周上午9点半到下午6点) | 是 | 
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈