V2.1 Get Command


Get the details of a command.


This API is available in EnOS 2.1.0 and above.

If you need to invoke this API after performing bulk updates to relevant commands using other APIs, it is recommended to wait for about 2 seconds to avoid obtaining unupdated data.

Request Format

GET https://{apigw-address}/connect-service/v2.1/commands?action=get

Request Parameters (URI)

Note

Use one of the following methods to specify the device:

  • Include assetId in the request

  • Include productKey + deviceKey in the request

Name

Location (Path/Query)

Mandatory/Optional

Data Type

Description

orgId

Query

Mandatory

String

The organization ID which the asset belongs to. How to get orgId>>

assetId

Query

Optional (See Note above)

String

The asset ID. How to get assetId>>

productKey

Query

Optional (See Note above)

String

The product key. To be used with deviceKey.

deviceKey

Query

Optional (See Note above)

String

The device key. To be used with productKey.

commandId

Query

Mandatory

String

The command ID.

Response Parameters

Name

Data Type

Description

data

Command Struct

The details of the command. For details, see Command Struct.

Command Struct

Name

Data Type

Description

commandId

String

The command ID.

orgId

String

The organization ID which the asset belongs to.

productKey

String

The product key.

deviceKey

String

The device key.

assetId

String

The asset ID.

createTime

String

The time when the command was invoked.

createLocaltime

String

The local time when the command was invoked.

commandType

Integer

The command type.

  • 1 = Measurement point setting

  • 2 = Service invocation

commandName

StringI18n

The command name. Refers to the measurement point name for measurement point setting. Refers to the service name for service invocation.

timeout

Integer

The command timeout duration. Its unit is seconds and its range is [1-60]. The default value is 30.

pendingTtl

Long

The command cache duration. Its unit is seconds and its range is [ 0 - 48 * 60 * 60 ], which is 0 by default. If the pendingTtl is 0, it indicates that the commands will be executed immediately.

state

Integer

The command status, which is represented by an integer from 1-7.

  • 1 = Created

  • 2 = Canceled

  • 3 = Expired

  • 4 = Released

  • 5 = Send successfully

  • 6 = Failed

  • 7 - Response timed out

tslIdentifier

String

The corresponding identifier in the ThingModel. Refers to the measurement point identifier for measurement point setting. Refers to the service identifier for service invocation.

inputData

Map (Key is of String type and the Value is of String, Number, Array or Object type)

The input data. For measurement point setting commands, the key is the measurement point identifier and the value is the measurement point value to be set. For service invocation commands, the key is the service input parameter identifier. The value data type will be as per defined in the ThingModel.

outputData

Map (Key is of String type and the Value is of String, Number, Array or Object type)

The output data. No return value is provided for this field for measurement point setting commands. For service invocation commands, this will return the service output results. The value data type will be as per defined in the ThingModel.

Error Codes

Code

Description

11404

The commandId cannot be found or does not exist.

11810

The command can not be encoded into the product-customized format when the product supports custom data formats.

11888

The device is not activated and the instant command cannot be sent.

11900

The device is offline and the instant command cannot be sent.

11902

The number of cached commands reached the upper limit.

11904

The command is not sent, and the instant command timed out.

11915

The command is sent, but the response timed out.

Samples

Request Sample

url: https://{apigw-address}/connect-service/v2.1/commands?action=get&deviceKey=yourDeviceKey&productKey=yourProductKey&commandId= yourCommandId&orgId=yourOrgId
method: GET

Return Sample

{
    "code": 0,
    "msg": "OK",
    "requestId": "7d863d517eae4f18a2776452eb1305bb",
    "data": {
        "commandId": "2242591201245044736",
        "orgId": "yourOrgId",
        "productKey": "yourProductKey",
        "deviceKey": "yourDeviceKey",
        "assetId": "yourAssetId",
        "createTime": "15910899018",
        "createLocalTime": "2020-06-02 17:25:01",
        "commandType": 2,
        "commandName": {
            "defaultValue": "",
            "i18nValue": {
                "en_US": "test_service"
            }
        },
        "timeout": 30,
        "pendingTtl": 1000,
        "state": 2,

        "tslIdentifier": "test_service",
        "inputData": {
            "parameter_1": 1.3,
            "parameter_2": 13
        },
        "outputData": null
    }
}

SDK Samples


You can access the SDK samples for Connection Service on GitHub: