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 requestInclude
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 |
Query |
Optional (See Note above) |
String |
The device key. To be used with |
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.
|
commandName |
StringI18n |
The command name. |
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.
|
tslIdentifier |
String |
Command Identifier. |
inputData |
Map (Key is of String type and the Value is of String, Number, Array or Object type) |
The input data. The key is the input parameter identifier, and the value’s data type needs to conform to the model’s definition. |
outputData |
Map (Key is of String type and the Value is of String, Number, Array or Object type) |
The output data. The key is the output parameter identifier, and the value is the service’s output result. The value’s data type needs to conform to the model’s definition |
Error Codes¶
Code |
Description |
---|---|
11404 |
The |
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: