Queries devices by status.

Limits

  • If you use an Enterprise Edition instance, you must specify the IotInstanceId parameter. Otherwise, the call fails.
  • After the status of a device changes, the new status is applied within 10 seconds. After the new status is applied, you can search for the device by using the new status. Before the new status is applied, you can search for the device by using the previous status.
  • Each Alibaba Cloud account can run a maximum of 50 queries per second (QPS).
    Note RAM users of an Alibaba Cloud account share the quota of the account.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes QueryDeviceByStatus

The operation that you want to perform. Set the value to QueryDeviceByStatus.

IotInstanceId String No iot_instc_pu****_c*-v64********

The ID of the instance.

  • If you use an Enterprise Edition instance, you must specify this parameter. On the Instance Overview page in the IoT Platform console, you can view the ID of your Enterprise Edition instance.
  • If you use a public instance, you do not need to specify this parameter.
ProductKey String No a1BwAGV****

The ProductKey of the product to which the device belongs.

Status Integer No 1

The status of the device. Valid values:

  • 0: inactive
  • 1: online
  • 3: offline
  • 8: disabled
CurrentPage Integer No 1

The number of the page to return.

PageSize Integer No 10

The number of entries to return on each page. Valid values: 1 to 50.

ResourceGroupId String No rg-acfm4l5tcwd***

The ID of the resource group to which the product belongs. You can view the resource group ID in the IoT Platform console.

Note If you specify this parameter, the system returns devices of the specified status in the resource group. If you do not specify this parameter, the system returns all devices of the specified status in the current account.

In addition to the preceding operation-specific request parameters, you must specify common request parameters when you call this operation. For more information, see Common request parameters.

Response parameters

Parameter Type Example Description
Code String iot.system.SystemException

The error code returned if the call fails. For more information, see Error codes.

Data Array of SimpleDeviceInfo

The device information returned if the call succeeds. The SimpleDeviceInfo parameter includes the details of the devices.

SimpleDeviceInfo
DeviceName String light

The DeviceName of the device.

DeviceSecret String sLefbFmN9SYfnWLJTePG893XNuRV****

The DeviceSecret of the device.

GmtCreate String 2021-02-18 10:46:32

The time when the device was created. The time is displayed in UTC.

GmtModified String 2021-02-18 10:46:32

The time when the device information was last modified. The time is displayed in UTC.

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 status of the device. Valid values:

  • UNACTIVE: The device is not activated.
  • ONLINE: The device is online.
  • OFFLINE: The device is offline.
  • DISABLE: The device is disabled.
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 call fails.

Page Integer 1

The page number of the returned page.

PageCount Integer 1

The total number of pages returned.

PageSize Integer 10

The number of entries returned per page.

RequestId String E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565

The ID of the request.

Success Boolean true

Indicates whether the call was successful.

  • true: The call was successful.
  • false: The call failed.
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, visit the API Error Center.