Help Center> IoT Device Access> API Reference> API Reference on the Application Side> API> Data Transfer APIs> Push an Asynchronous Device Command Status Change Notification
Updated on 2023-11-08 GMT+08:00

Push an Asynchronous Device Command Status Change Notification

Function

This API is used by the platform to push a notification for command status changes to an application after the application calls the APIs for Creating A Rule Triggering Condition (resource is set to device.command.status and event to update), Creating A Rule Action, and Modifying a Rule Triggering Condition to configure and activate a rule.

Precautions

The application must send a response code after receiving a message pushed by the platform.

URI

Request Method

POST

URI

URL (HTTP) determined when the application creates an asynchronous device command status change notification rule. The AMQP channel does not require the URL.

Transport Protocol

HTTPS

Request Parameters

Parameter

Mandatory

Type

Location

Description

resource

Yes

String

Body

Subscribed resource name. Set this parameter to device.commmad.status.

event

Yes

String

Body

Subscribed event. Set this parameter to update.

event_time

Yes

String

Body

UTC time when the resource event was generated. The value is in the format of yyyyMMdd'T'HHmmss'Z', for example, 20151212T121212Z. If necessary, convert the time to display in the local time zone format.

event_time_ms

No

String

Body

Time when a resource event is generated. The value is a UTC character string in the format of yyyy-MM-dd'T'HH:mm:ss.SSS'Z', for example, 2019-03-03T08:10:11.000Z. If necessary, convert the time to display in the local time zone format.

request_id

No

String

Body

Message ID which is specified by the device or generated by the platform and is used to trace the service process.

notify_data

Yes

DeviceCommandStatusUpdateNotifyDataV5 Object

Body

Message to push.

Table 1 DeviceCommandStatusUpdateNotifyDataV5

Parameter

Mandatory

Type

Description

header

Yes

NotifyDataHeader Object

Message header.

body

Yes

DeviceCommandStatusUpdate Object

Message body.

Table 2 NotifyDataHeader

Parameter

Mandatory

Type

Description

app_id

No

String

Application ID.

device_id

No

String

Device ID. The ID is unique and is allocated by the platform during device registration.

node_id

No

String

Device identifier. This parameter is set to the IMEI, MAC address, or serial number.

product_id

No

String

Product ID. The ID is unique and is allocated by the platform during product registration.

gateway_id

No

String

Unique gateway ID. The gateway ID is the same as the device ID if the device is a directly connected device. If the device is an indirectly connected device, the gateway ID is the device ID of the directly connected device (that is, the gateway) with which it associates.

tags

No

List<TagV5DTO>

List of tags to be bound to a specific resource. Each tag key must be unique in the tag list. Up to 10 tags can be bound to a resource.

Table 3 TagV5DTO

Parameter

Mandatory

Type

Description

tag_key

Yes

String

Tag key, which is unique for a resource. If the specified key already exists, the value of the existing tag is overwritten. If the specified key does not exist, a new tag is added.

tag_value

No

String

Tag value.

Table 4 DeviceCommandStatusUpdate

Parameter

Mandatory

Type

Description

command_id

Yes

String

Command ID, which uniquely identifies a command.

created_time

No

String

UTC time when the command was created. The value is in the format of yyyyMMdd'T'HHmmss'Z'.

sent_time

No

String

UTC time when the platform sent the command. If the command was sent immediately, the value was the same as the command creation time. If the command had been cached, the value was the time when the command was actually sent. The value is in the format of yyyyMMdd'T'HHmmss'Z'.

delivered_time

No

String

UTC time when the device received the command. The value is in the format of yyyyMMdd'T'HHmmss'Z'.

response_time

No

String

UTC time when the device responded to the command. The value is in the format of yyyyMMdd'T'HHmmss'Z'.

status

No

String

Command status.

  • PENDING: The command is not delivered and is cached on the platform.
  • EXPIRED: The command has expired, that is, the cache time exceeds the value of expireTime.
  • SENT: The command is being delivered.
  • DELIVERED: The command has been delivered.
  • SUCCESSFUL: The command has been executed.
  • FAILED: The command fails to be executed.
  • TIMEOUT: After a command is delivered, no response is received from the device or the response times out.

result

No

Object

Detailed command execution result, which is returned by the device in JSON format.

Example Request

POST https://{Endpoint} URL (HTTP) determined when the application creates an asynchronous device command status change notification rule. The AMQP channel does not require the URL.
Content-Type: application/json

{
  "resource" : "device.commmad.status",
  "event" : "update",
  "event_time" : "20190303T081011Z",
  "event_time_ms" : "2019-03-03T08:10:11.000Z",
  "request_id" : "3fe58d5e-8697-4849-a165-7db128f7e776",
  "notify_data" : {
    "header" : {
      "device_id" : "d4922d8a-6c8e-4396-852c-164aefa6638f",
      "product_id" : "ABC123456789",
      "app_id" : "d4922d8a-6c8e-4396-852c-164aefa6638f",
      "gateway_id" : "d4922d8a-6c8e-4396-852c-164aefa6638f",
      "node_id" : "ABC123456789",
      "tags" : [ {
        "tag_value" : "testTagValue",
        "tag_key" : "testTagName"
      } ]
    },
    "body" : {
      "result" : {
        "key" : "value"
      },
      "created_time" : "20151212T121212Z",
      "sent_time" : "20151212T121212Z",
      "command_id" : "id",
      "delivered_time" : "20151212T131212Z",
      "response_time" : "20151212T131212Z",
      "status" : "SUCCESSFUL"
    }
  }
}

Example Response

Status Code: 200 OK