{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/aqara/json-schema/aqara-automation-capabilities-response-schema.json",
  "title": "AutomationCapabilitiesResponse",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/data-export-api-zh.yaml#/components/schemas/AutomationCapabilitiesResponse",
  "allOf": [
    {
      "$ref": "#/$defs/BaseResponse"
    },
    {
      "type": "object",
      "properties": {
        "data": {
          "$ref": "#/$defs/AutomationCapabilitiesData"
        }
      }
    }
  ],
  "$defs": {
    "AutomationCapabilitiesData": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "devices": {
          "type": "array",
          "description": "可用于自动化编排的设备能力列表",
          "items": {
            "$ref": "#/$defs/AutomationCapabilityDevice"
          }
        }
      }
    },
    "AutomationCapabilityDevice": {
      "type": "object",
      "required": [
        "deviceId",
        "deviceName",
        "endpoints"
      ],
      "properties": {
        "deviceId": {
          "type": "string",
          "description": "设备ID"
        },
        "deviceName": {
          "type": "string",
          "description": "设备名称"
        },
        "endpoints": {
          "type": "array",
          "description": "设备端点列表",
          "items": {
            "$ref": "#/$defs/AutomationCapabilityEndpoint"
          }
        }
      }
    },
    "AutomationCapabilityEndpoint": {
      "type": "object",
      "required": [
        "endpointName",
        "endpointId",
        "properties"
      ],
      "properties": {
        "endpointName": {
          "type": "string",
          "description": "端点名称"
        },
        "endpointId": {
          "type": "integer",
          "description": "端点ID"
        },
        "properties": {
          "type": "array",
          "description": "端点可用能力列表（功能点/事件/命令）",
          "items": {
            "$ref": "#/$defs/AutomationCapabilityProperty"
          }
        }
      }
    },
    "AutomationCapabilityEnumItem": {
      "type": "object",
      "description": "枚举范围",
      "required": [
        "value",
        "key"
      ],
      "properties": {
        "value": {
          "type": "string",
          "description": "枚举值（接口返回中通常为字符串）"
        },
        "key": {
          "type": "string",
          "description": "枚举显示文案"
        }
      }
    },
    "AutomationCapabilityProperty": {
      "type": "object",
      "required": [
        "deviceType",
        "functionCode",
        "functionName",
        "valueType",
        "semanticRole"
      ],
      "properties": {
        "deviceType": {
          "type": "string",
          "description": "设备类型"
        },
        "functionCode": {
          "type": "string",
          "description": "功能编码"
        },
        "functionName": {
          "type": "string",
          "description": "功能名称"
        },
        "traitCode": {
          "type": "string",
          "description": "功能点代码（valueType 非 cmd 时常见）"
        },
        "traitName": {
          "type": "string",
          "description": "功能点名称"
        },
        "commandCode": {
          "type": "string",
          "description": "命令编码（valueType 为 cmd 时常见）"
        },
        "commandName": {
          "type": "string",
          "description": "命令名称"
        },
        "valueType": {
          "type": "string",
          "description": "值类型（如 boolean/number/enum/event/cmd）"
        },
        "semanticRole": {
          "type": "array",
          "description": "自动化环节角色",
          "items": {
            "type": "string",
            "enum": [
              "starter",
              "condition",
              "action"
            ]
          }
        },
        "unit": {
          "type": "string",
          "description": "单位（如 %, °C, lx 等）"
        },
        "valueRange": {
          "$ref": "#/$defs/AutomationCapabilityValueRange"
        }
      }
    },
    "AutomationCapabilityValueRange": {
      "type": "object",
      "description": "数值范围或枚举范围",
      "properties": {
        "min": {
          "type": "number",
          "format": "double",
          "description": "最小值"
        },
        "max": {
          "type": "number",
          "format": "double",
          "description": "最大值"
        },
        "enumRange": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AutomationCapabilityEnumItem"
          }
        }
      }
    },
    "BaseResponse": {
      "type": "object",
      "required": [
        "type",
        "version",
        "msgId",
        "code"
      ],
      "properties": {
        "type": {
          "type": "string",
          "description": "消息类型"
        },
        "version": {
          "type": "string",
          "description": "接口版本"
        },
        "msgId": {
          "type": "string",
          "description": "消息 ID"
        },
        "code": {
          "type": "integer",
          "description": "业务状态码，0 表示成功"
        },
        "message": {
          "type": "string",
          "description": "提示信息"
        }
      }
    }
  }
}