Updated on 2024-12-02 GMT+08:00

Device Reporting Properties

Function

This API is used by a device to report property data in the format defined in the product model to the platform. For differences between property reporting and message reporting, see Message Communications Overview.

It is not suitable to report data in JSON format for devices with low configuration and limited resources or with limits on bandwidth usage. In this case, devices can transparently transmit the original binary data to the platform, but a codec is required to convert binary data to JSON format. For details about how to develop codecs, see Developing a Codec.

Topic

Upstream: $oc/devices/{device_id}/sys/properties/report

You can add ?request_id to the end of the topic to specify the request ID for the data reporting. Message reporting example: $oc/devices/{device_id}/sys/properties/report?request_id={request_id}. If this parameter is not specified, the platform automatically generates a request ID to identify the request.

Parameters

Parameter

Mandatory/Optional

Type

Description

services

Mandatory

List<ServiceProperty>

Explanation:

Indicates a list of device services. For details, see ServiceProperty structure.

ServiceProperty structure

Parameter

Mandatory/Optional

Type

Description

service_id

Mandatory

String

Explanation:

Service ID of the device, which is determined by the product model.

properties

Mandatory

Object

Explanation:

Indicates the property list of the device service. Multiple property parameters can be defined in the product model associated with the device.

event_time

Optional

String

Explanation:

Indicates the UTC time when the device collects data. The value is in the format of yyyyMMdd'T'HHmmss'Z' or yyyy-MM-dd'T'HH:mm:ss.SSS'Z', for example, 20161219T114920Z or 2020-08-12T12:12:12.333Z.

If this parameter is not carried in the reported data or is in incorrect format, the time when the platform receives the data is used.

Example

Topic: $oc/devices/{device_id}/sys/properties/report  
Data format:
{
    "services": [{
            "service_id": "Temperature",
            "properties": {
                "value": 57,
                "value2": 60
            },
            "event_time": "20151212T121212Z"
        },
        {
            "service_id": "Battery",
            "properties": {
                "level": 80,
                "level2": 90
            },
            "event_time": "20151212T121212Z"
        }
    ]
}