跳至主要内容

Create a data analyzer

POST 

/api/v1/orgs/{orgId}/devices/{deviceId}/analyzers

Create a new analyzer to transform input data stream values using a mathematical expression or a JavaScript script. Analyzers are always created disabled; use the enable/disable action to activate.

Request Body

  • name (string, required): Human-readable analyzer name. Maximum length: 256.
  • description (string, optional): Analyzer description. Maximum length: 500.
  • type (AnalyzerType, required): TransferFunction or JavaScript.
  • inputParameters (array, required): Binds input data streams to the variable names used by the expression or script. TransferFunction requires exactly one; JavaScript accepts up to ten.
  • config.expression (string): Required for TransferFunction.
  • config.script (string): Required for JavaScript. Each input is a variable named after its parameter, holding the incoming value as value or val and its source time in milliseconds as timestamp or ts.
  • outputs (array, required): Target data streams. TransferFunction emits exactly one; JavaScript may emit several, each selecting from the script result with valueJsonPath and timeJsonPath.
  • dataAssemblyPolicy (object, optional): Data Assembly settings. Valid only when inputParameters holds two or more data streams; omit it to take the defaults.

Responses

  • 201 Created: Analyzer created successfully.
  • 400 Bad Request: Invalid request, expression, or script; an expression or script that does not name every declared input parameter; a duplicate or self-referencing data stream, or more than ten inputs; a duplicate input parameter name; an unsupported JSONPath, or a JavaScript output without one; a dataAssemblyPolicy value outside its range; or a dependency graph exceeding the maximum chain depth of five analyzers or containing a cycle.
  • 401 Unauthorized: Missing or invalid authentication token.
  • 403 Forbidden: The caller is not permitted to access this organization or device.
  • 404 Not Found: Device, input data stream, or output data stream not found.
  • 409 Conflict: The output data stream already has a data source: another analyzer, or a node, subnode, or device.
  • 500 Internal Server Error: An upstream service (device management, data streams, or Data Assembly) was unreachable or failed.

Security

  • This API requires authentication.

Request​

Responses​

Created