Modify Linkage Rule

Last Updated on : 2024-06-29 02:06:47download

Modify the specified linkage rule.

API address

PUT: /v2.0/cloud/scene/rule/{rule_id}

Request parameter

Parameter nameTypeINRequiredDescription
rule_idStringuritrueThe ID of the specified linkage rule.

Description of body

Parameter nameTypeINRequiredDescription
space_idString trueThe ID of the specified space that is associated with the linkage rule.
nameString falseThe name of the specified linkage rule.
decision_exprString falseThe condition expression. Valid values:
  • and: AND.
  • or: OR.
  • c1&c2: custom expression.
conditionsList falseThe collection of conditions.
actionsList falseThe collection of actions.
effective_timeEffectiveTime falseThe effective time.

Description of effective_time

Parameter nameTypeINRequiredDescription
startString trueThe start time.
endString trueThe end time.
loopsString trueThe cycle when the specified linkage rule is triggered. The value is a seven-digit number consisting of 0 and 1. 0 means disabled and 1 means enabled. The first digit represents Sunday and the other digits represent Monday to Saturday sequentially. For example, 0011000 represents a scheduled task is executed every Tuesday and Wednesday.
time_zone_idString trueThe ID of the specified time zone.

Description of conditions

Parameter nameTypeINRequiredDescription
entity_idString trueThe object ID of the specified condition.
entity_typeString trueThe object type of the specified condition. Valid values:
  • timer: timer.
  • weather: weather condition.
  • device_report: data reporting by the device.
codeInteger trueThe unique code of the specified condition.
exprExpr trueThe calculation expression.

Description of actions

Parameter nameTypeINRequiredDescription
entity_idString trueThe object ID of the specified action.
action_executorString trueThe object type of the specified action. Valid values:
  • delay: Delay an action.
  • device_issue: Send an instruction to a device.
  • device_group_issue: Send an instruction to a device group.
executor_propertyExecutorProperty trueThe details of the specified action.

Description of expr

Parameter nameTypeINRequiredDescription
status_codeString trueThe code of the specified status. This parameter is required when entity_type is device_report.
comparatorString trueThe comparison expression. This parameter is required when entity_type is device_report and weather. Valid values:
  • ==: equal to.
  • >: greater than.
  • <: less than.
status_valueObject trueThe value of the specified status. This parameter is required when entity_type is device_report.
dateString falseThe date when the specified linkage rule is triggered.
timeString trueThe time when the specified linkage rule is triggered.
loopsString falseThe cycle when the specified linkage rule is triggered. The value is a seven-digit number consisting of 0 and 1. 0 means disabled and 1 means enabled. The first digit represents Sunday and the other digits represent Monday to Saturday sequentially. For example, 0011000 represents a scheduled task is executed every Tuesday and Wednesday.
time_zone_idString trueThe ID of the specified time zone.
weather_codeString trueThe code of the specified status. This parameter is required when entity_type is weather.
weather_valueObject trueThe value of the specified status. This parameter is required when entity_type is weather.

Description of executor_property

Parameter nameTypeINRequiredDescription
function_codeString trueThe code of the specified instruction. This parameter is required when action_executor is device_issue or device_group_issue.
function_valueObject trueThe value of the specified instruction. This parameter is required when action_executor is device_issue or device_group_issue.
delay_secondsInteger trueThe delay time. This parameter is required when action_executor is delay.

Return parameter

Parameter nameTypeDescription
resultBooleanIndicates whether the linkage rule is modified successfully.

Request example

PUT: /v2.0/cloud/scene/rule/***
{
  "space_id": "150***",
  "name": "Test Scene",
  "type": "automation",
  "decision_expr": "or",
  "effective_time": {
    "start": "00:00",
    "end": "23:00",
    "loops": "1111111",
    "timezone_id": "Asia/Shanghai"
  },
  "conditions": [
    {
      "code": 1,
      "entity_id": "****",
      "entity_type": "device_report",
      "expr": {
        "status_code": "switch_1",
        "comparator": "==",
        "status_value": true
      }
    }
  ],
  "actions": [
    {
      "entity_id": "****",
      "action_executor": "device_issue",
      "executor_property": {
        "function_code": "switch_1",
        "function_value": true
      }
    }
  ]
}

Return example

{
    "tid": "****",
    "result": true,
    "t": 1677741828415,
    "success": true
}

Error code

For more information, see error code.

Limits on API Request Frequency

For more information, see Limits on API Request Frequency.