Product node

更新时间:
复制 MD 格式

A Product Node represents a Product in the current service's project. You can use this node to send commands to a device to set properties or call services, query the snapshot or historical values of device properties, and retrieve other device information, such as basic information, thing model details, and event data.

Products you import or create on the Product page of the current project automatically appear under the Device tab of Function Nodes.

Click Associate IoT Platform Product to import an existing Product, or click New Product to create a new Product.

If you have not added any Products to the current project, no Product Nodes appear on the Device tab.

Node configuration

Parameter Description
Node name Set the node name. The name can contain Chinese characters, English letters, digits, and underscores (_), and must not exceed 30 characters.
Select device to control Select the control target. You can select one of the following:
  • A parameter from a node that precedes this Product Node.
  • A specific device under the current Product.
Select operation type Select the operation to perform. The options are:
  • Device action execution: Set a property or call a service.
  • Query device properties: Query the snapshot or historical value of a device property.
  • Query other device information: Query other information about a device, such as its basic information, thing model details, and event data.
Command data This field is displayed when you set Select operation type to Device action execution.

Send a command to the device to set a specific property or call a specific service.

Note The selected property must be read/write.

The data format for setting properties is as follows:

{
   "properties": {
    "identifierForProperty1": "targetValue",
    "identifierForProperty2": "targetValue"
   }
}
Select properties to query This field is displayed when you set Select operation type to Query device properties.

You can select all properties or a specific property.

Query dimension This field is displayed when you set Select operation type to Query device properties.
  • Snapshot value: The latest reported value of the property.
  • Historical value: Query the historical records of a single property reported within a specified time range. You must configure the start time, end time, number of records, and sort order.

    The following example shows the data format for the request:

    {
       "start": 1526900000000, // The start time for the historical data query (timestamp in milliseconds).
       "end": 1526900000001, // The end time for the historical data query (timestamp in milliseconds).
       "pageSize": 10,  // The number of records to query.
       "ordered": true // The query order (true for chronological order, false for reverse chronological order).
    }
    Note
    • If you select chronological order, the query returns the first 10 property records from the start time.
    • If you select reverse chronological order, the query returns the last 10 property records between the start and end times.
Query type This field is displayed when you set Select operation type to Query other device information.

From the drop-down list, select the type of information to query and provide the required parameters. For details on the parameters required for each type, see the API documentation in the Thing Management service.

You can set parameters as variables. IoT Studio provides the following built-in global variables:

  • Output data from the previous node: payload. Use payload.key_in_payload_object to access a specific key's value.
  • Data from the service input node: query. For example, input parameters for an HTTP Request node or device data from a Device Trigger node. Use query.parameter_name to access a specific parameter's value.
  • Output data from a specific node: node.node_ID. Use node.node_ID.key_in_node_output to access a specific key's value in the node's output.

Example:

{
   "productKey": "{{payload.productKey}}",  // The previous node's output is {productKey: 'value'}. Retrieves the value of productKey.
   "deviceName": "{{query.deviceName}}", // An input parameter named deviceName is defined in the API request node. This retrieves the value of deviceName.
   "pageNum": "{{node.node_399591c0.pageNum}}" // The output of node_399591c0 is pageNum. This retrieves the value of pageNum.
}

To access a nested value within a parameter, use the following format:

Use {{payload.props.PM10.value}} to access the value of the PM10 property within the props object from the previous node's output.

Use {{query.deviceContext.deviceName}} to access the deviceName variable within the deviceContext object from the first node's output.

The following is an example of configuring a device action execution.

In the Command data section, select property. For each property (such as RoomHumidity, RoomTemperature, power_LED, and DiskUsage), select Fixed value and set the target value according to its data type (for example, boolean or number).

The following is an example of querying device properties.

When Select operation type is set to Query device properties, you must configure parameters such as ProductKey, DeviceName, and the identifiers of the properties to query. The system returns the latest value of the specified device properties.

The following is an example of querying other device information.

When Select operation type is set to Query other device information, select a specific query type, such as Get thing's service call records, from the Query type drop-down list. Then, in the JSON editor below, configure the request parameters, including fields such as serviceIdentifier, start, end, pageSize, and ordered.

Output data

The data returned after a command executes is the node's output.

After a successful debugging session, you can view the output data structure in the node's logs.

The node's output data includes fields such as a return code (code), a device data source (dataSource), and a device ID. For example:
{
    "code": 200,
    "data": {
        "dataSource": {
            "deviceName": "yInf...",
            "status": "Online"
        },
        "id": "194572"
    }
}