Queries devices by state.
Usage notes
After the state of a device changes, the new state takes effect within 10 seconds. After the new state takes effect, you can search for the device by using the new state. Before the new state takes effect, you can search for the device by using the previous state.
QPS limits
You can call this API operation up to 50 times per second per account.
The Resource Access Management (RAM) users of an Alibaba Cloud account share the quota of the account.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | QueryDeviceByStatus | The operation that you want to perform. Set the value to QueryDeviceByStatus. |
Status | Integer | Yes | 1 | The state of the device. Valid values:
|
IotInstanceId | String | No | iot_instc_pu****_c*-v64******** | The instance ID. You can view the instance ID on the Overview tab of the IoT Platform console. Important
|
ProductKey | String | No | a1BwAGV**** | The ProductKey of the product to which the device belongs. |
CurrentPage | Integer | No | 1 | The page number. |
PageSize | Integer | No | 10 | The number of entries per page. Valid values: 1 to 50. |
ResourceGroupId | String | No | rg-acfm4l5tcwd*** | The resource group ID. Important IoT Platform supports resource group management only by instance. The ResourceGroupId parameter is invalid. You do not need to specify this parameter. |
In addition to the preceding operation-specific request parameters, you must specify common request parameters when you call this operation. For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
Code | String | iot.system.SystemException | The error code returned if the request failed. For more information, see Error codes. |
Data | Array of SimpleDeviceInfo | The device information returned if the request was successful. The SimpleDeviceInfo parameter includes the details of the devices. | |
SimpleDeviceInfo | |||
DeviceName | String | light | The name of the device. |
DeviceSecret | String | sLefbFmN9SYfnWLJTePG893XNuRV**** | The secret of the device. |
GmtCreate | String | 2021-02-18 10:46:32 | The time when the device was created. The time is displayed in GMT. |
GmtModified | String | 2021-02-18 10:46:32 | The time when the device information was last modified. The time is displayed in GMT. |
IotId | String | Av8NGHGtwPrH9BYGLMBi00**** | The ID of the device. |
Nickname | String | SensorInShanghai | The alias of the device. |
ProductKey | String | a1BwAGV**** | The ProductKey of the product to which the device belongs. |
Status | String | ONLINE | The state of the device. Valid values:
|
UtcCreate | String | 2021-02-18T02:46:32.000Z | The time when the device was created. The time is displayed in UTC. |
UtcModified | String | 2021-02-18T02:46:32.000Z | The time when the device information was last modified. The time is displayed in UTC. |
ErrorMessage | String | A system exception occurred. | The error message returned if the request failed. |
Page | Integer | 1 | The page number. |
PageCount | Integer | 1 | The total number of pages. |
PageSize | Integer | 10 | The number of entries per page. |
RequestId | String | E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565 | The request ID. |
Success | Boolean | true | Indicates whether the request was successful. Valid values:
|
Total | Integer | 2 | The total number of devices returned. |
Examples
Sample requests
https://iot.cn-shanghai.aliyuncs.com/?Action=QueryDeviceByStatus
&ProductKey=aldafD****
&Status=0
&PageSize=10
&CurrentPage=1
&<Common request parameters>
Sample success responses
XML
format
<QueryDeviceByStatusResponse>
<RequestId>CD9E5F99-A095-4A05-9256-D924EA3075E8</RequestId>
<Success>true</Success>
<CurrentPage>1</CurrentPage>
<PageSize>10</PageSize>
<TotalPageCount>1</TotalPageCount>
<TotalCount>2</TotalCount>
<Data>
<SimpleDeviceInfo>
<IotId>Av8NGHGtwPrH9BYGLMBi00****</IotId>
<DeviceName>Av8NGHG***</DeviceName>
<ProductKey>a1dafDE****</ProductKey>
<DeviceSecret>d7GYhf5hfcPHDe1bXSd3n9MjO1G3****</DeviceSecret>
<UtcModified>2021-02-18T02:46:32.000Z</UtcModified>
<GmtCreate>2021-02-18 10:46:32</GmtCreate>
<UtcCreate>2021-02-18T02:46:32.000Z</UtcCreate>
<GmtModified>2021-02-18 10:46:32</GmtModified>
<Status>UNACTIVE</Status>
<Nickname>SensorInShanghai</Nickname>
</SimpleDeviceInfo>
<SimpleDeviceInfo>
<IotId>zNIcSmWQ9BPJlmkjn3H100****</IotId>
<DeviceName>zNIcSmWQ***</DeviceName>
<ProductKey>a1dafDE****</ProductKey>
<DeviceSecret>C27XXmC18yLIEDXvUj6FSlvgO7ag****</DeviceSecret>
<UtcModified>2021-02-09T09:44:55.000Z</UtcModified>
<GmtCreate>2021-02-09 17:44:55</GmtCreate>
<UtcCreate>2021-02-09T09:44:55.000Z</UtcCreate>
<GmtModified>2021-02-09 17:44:55</GmtModified>
<DeviceStatus>UNACTIVE</DeviceStatus>
<Nickname>DriverInShanghai</Nickname>
</SimpleDeviceInfo>
</Data>
</QueryDeviceByStatusResponse>
JSON
format
{
"RequestId": "CD9E5F99-A095-4A05-9256-D924EA3075E8",
"Success": true,
"CurrentPage": 1,
"PageSize": 10,
"TotalPageCount": 1,
"TotalCount": 2,
"Data": {
"SimpleDeviceInfo": [
{
"IotId": "Av8NGHGtwPrH9BYGLMBi00****",
"DeviceName": "Av8NGHG***",
"ProductKey": "a1dafDE****",
"DeviceSecret": "d7GYhf5hfcPHDe1bXSd3n9MjO1G3****",
"UtcModified": "2021-02-18T02:46:32.000Z",
"GmtCreate": "2021-02-18 10:46:32",
"UtcCreate": "2021-02-18T02:46:32.000Z",
"GmtModified": "2021-02-18 10:46:32",
"Status": "UNACTIVE",
"Nickname": "SensorInShanghai"
},
{
"IotId": "zNIcSmWQ9BPJlmkjn3H100****",
"DeviceName": "zNIcSmWQ***",
"ProductKey": "a1dafDE****",
"DeviceSecret": "C27XXmC18yLIEDXvUj6FSlvgO7ag****",
"UtcModified": "2021-02-09T09:44:55.000Z",
"GmtCreate": "2021-02-09 17:44:55",
"UtcCreate": "2021-02-09T09:44:55.000Z",
"GmtModified": "2021-02-09 17:44:55",
"DeviceStatus": "UNACTIVE",
"Nickname": "DriverInShanghai"
}
]
}
}
Error codes
For a list of error codes, see Service error codes.