Device Resource Management

Device resources refer to the data generated by the device, including the setting parameters and real-time status of the device. A device has multiple resources, and different resources represent data of different device attributes. For example, the switch status (plug_status) is a resource of the smart socket, which indicates whether the smart socket is currently powered on. Through this resource, the developer can query the current status of the socket and remotely control the socket. For a detailed list of resources, please log in to Aqara Developer Platform, enter the Console-Device Resources To view the list of currently device resources. It can also be queried through the following interface.

Query the details of the attributes

  • API intent: query.resource.info
  • Description: Query the device's resource attribute details according to the device's model.
  • Request parameters
Name Type Is required? Description
model String Yes Subject model
resourceId String No Resource ID, if it is empty, all resource IDs and details will be returned.
  • Request demo
{
  "intent": "query.resource.info",
  "data": {
      "model": "lumi.switch.n1aeu1",
      "resourceId":"8.1.2044"
  }
}
  • Response parameters
Name Type Description
enums String Enums description
resourceId String Resource id
minValue Integer Minimum value
unit Integer Unit
access Integer 0-read 1-write 2-write/read
maxValue Integer Maxinum value
defaultValue String Default value
name String Name
description String Description
model String Subject model
  • Response demo
{
    "code": 0,
    "message": "Success",
    "msgDetails": null,
    "requestId": "",
    "result": [
        {
            "enums": "0,1",
            "resourceId": "0.12.85",
            "minValue": null,
            "unit": 1,
            "access": 0,
            "maxValue": null,
            "defaultValue": "0",
            "name": "Load power",
            "description": "Load power",
            "model": "lumi.switch.n1aeu1"
        }
    ]
}

Query device attribute name

  • API intent: query.resource.name
  • Description: This interface is used to query the default name of all resources of the device based on the device ID, which can be modified through the "config.resource.info" interface.
  • Request parameters
Name Type Is required? Description
subjectIds Array(String) Yes Device id Array
  • Request Demo
{
    "intent": "query.resource.name",
    "data": {
        "subjectIds": ["virtual2.55266893697941"]
    }
}
  • Response parameters
Name Type Description
subjectId String Device id
resourceId String Resource id
name String Resource name
  • Response demo
{
    "code": 0,
    "message": "Success",
    "msgDetails": null,
    "requestId": "",
    "result": [
        {
            "resourceId": "4.1.85",
            "name": "plug status",
            "subjectId": "virtual2.55266893697941"
        }
    ]
}

Modify device attribute information

  • API intent: config.resource.info
  • Description: This interface is used to customize the name of the device resource. For example: the first button, second button, and third button of a three-button switch can be named according to the user's purpose, such as living room lights, bedroom lights, etc., to facilitate identification.
  • Request parameters
Name Type Is required? Description
subjectId String Yes Device id array
resourceId String Yes Resource id
name String Yes Resource name
  • Request Demo
{
    "intent": "config.resource.info",
    "data": {
        "subjectId":"virtual2.xxx",
        "resourceId":"14.7.111",
        "name":"Light"
    }
}
  • Response parameters: NA
  • Response demo
{
    "code": 0,
    "message": "Success",
    "msgDetails": "",
    "requestId": "",
    "result": ""
}

Query device attribute value

  • API intent: query.resource.value
  • Description: This interface is used to query the current status of the specified resource of the device.
  • Request parameters
Name Type Is required? Description
resources Array(Object) Yes Device attribute list

Resources description

Name Type Is required? Description
subjectId String Yes Device id
resourceIds Array(String) No Device attribute, see device attribute page.
If it is empty, query all open resources of the device.
  • Request Demo
{
  "intent": "query.resource.value",
  "data": {
    "resources": [
      {
        "subjectId": "virtual2.11774113824794",
        "resourceIds": [
          "4.1.85"
        ]
      }
    ]
  }
}
  • Response parameters
Name Type Description
subjectId String Device id
resourceId String Resource id
value String Resource value
timeStamp Long Time stamp(the unit is ms)
  • Response demo
{
  "code": 0,
  "message": "Success",
  "msgDetails": "",
  "requestId": "",
  "result": [
    {
      "timeStamp": 1617886614176,
      "resourceId": "4.1.85",
      "value": "1",
      "subjectId": "virtual2.11774113824794"
    }
  ]
}

Update device attribute (control device)

  • API intent: write.resource.device
  • Description: Update device resource, that is, device control. For example, turn on the smart socket, set 4.1.85 to 1. On the console-device attribute page, you can query the attribute description based on the device name or device model, and the writable attribute represents controllable.
  • Request parameters
Name Type Is required? Description
subjectId String Yes Device id
resources Array Yes Resource list

Resources description

Name Type Is required? Description
resourceId String Yes Resource id
value String Yes Resource value

Note: The format of data is Array.

  • Request Demo
{
  "intent": "write.resource.device",
  "data": [
    {
      "subjectId": "lumi.158d000488d874",
      "resources": [
        {
          "resourceId": "14.7.111",
          "value": "1"
        }
      ]
    }
  ]
}
  • Response parameters: NA

  • Response demo

{
  "code": 0,
  "message": "Success",
  "msgDetails": "",
  "requestId": "",
  "result": ""
}

Query the history of device attributes

  • API intent: fetch.resource.history
  • Description: This interface is used to query the resource history records of the device in a certain period of time. Only the data within 7 days can be queried.
  • Request parameters
Name Type Is required? Description
subjectId String Yes Object id
resourceIds Array Yes Resource id array
startTime String Yes Start time (timestamp, unit is ms)
endTime String No End time (timestamp, unit is ms)Default value is current time.
size int No Pull quantity. The default value is 30, and the maximum is 300.
scanId String No Pull Id cyclically, this field will be returned each time historical data is pulled, if you need to continue to pull down, carry this parameter
  • Request Demo
{
  "intent": "fetch.resource.history",
  "data": {
    "subjectId": "lumi.158d00041a3e08",
    "resourceIds": [
      "4.1.85"
    ],
    "startTime": "1619850596000",
    "endTime": "1620811092000"
  }
}
  • Response parameters
Name Type Description
scanId String Scan id
data Array Query data list

Data description

Name Type Description
subjectId String Device id
resourceId String Resource id
value String Resource value
timeStamp Long Time stamp
  • Response demo
{
  "code": 0,
  "message": "Success",
  "msgDetails": "",
  "requestId": "4665.51.16208112921411357",
  "result": {
    "data": [
      {
        "timeStamp": 1620810084129,
        "resourceId": "4.1.85",
        "value": "0",
        "subjectId": "lumi.158d00041a3e08"
      },
      {
        "timeStamp": 1620810083568,
        "resourceId": "4.1.85",
        "value": "1",
        "subjectId": "lumi.158d00041a3e08"
      },
      {
        "timeStamp": 1620810077058,
        "resourceId": "4.1.85",
        "value": "0",
        "subjectId": "lumi.158d00041a3e08"
      }
    ]
  }
}

Query the statistical history value of the device attribute

  • API intent: fetch.resource.statistics
  • Description: This interface is used to query the specified statistical information of device resources, such as the minimum, maximum, average, etc.. Only the data within half a year can be queried. For specific value definitions, please refer to the Console-Device Resources page, supported statistical types to view.

Some of device attributes that currently support aggregation is as follows:

Attribute Option
Cost energy Difference
Load power Min, Max, Average
Lux Min, Max, Average
Temperature value Min, Max, Average
Humidity value Min, Max, Average
Pressure value Min, Max, Average
Example: Clicks' number of the wireless switch Frequency
  • Request parameters
Name Type Is required? Description
resources Array(Object) Yes Resource list
startTime String Yes Start time (timestamp, unit is ms)
endTime String No End time (timestamp, unit is ms). Default value is current time.
dimension String Yes Fixed enumeration value: 30m, 1h, 2h, 3h, 4h, 5h, 6h, 12h, 1d, 7d, month
aggrTypes Array(Num) Yes 0-Difference; 1-Min; 2-Max; 3-Average; 4-Frequency. If empty, all aggregated type supported are displayed.
size Integer No The default value is 100, the minimum is 10 and the maximum is 300.
scanId String No Pull Id cyclically, this field will be returned each time historical data is pulled, if you need to continue to pull down, carry this parameter

Resources description

Name Type Is required? Description
subjectId String Yes Subject id
resourceIds Array(String) Yes Device attribute, see device attribute page.
  • Request parameters
{
  "intent": "fetch.resource.statistics",
  "data": {
    "resources": {
      "subjectId": "lumi.158d000488d874",
      "aggrTypes": [1,2],      
      "resourceIds": [
        "0.1.85"
      ]
    },
    "startTime": "1612789463000",
    "dimension": "30m"
  }
}
  • Response parameters
Name Type Description
scanId String Scan id
data Array Query data list

Data description

Name Type Description
timeStamp Long Time stamp, the unit is ms.
resourceId String Resource id
value String Device resource value
subjectId String Subject id
aggrType Int 0-Difference; 1-Min; 2-Max; 3-Average; 4-Frequency
startTimeZone String Start time
endTimeZone String End time
  • Response demo
{
  "code": 0,
  "requestId": "844.28149.16099008675670099",
  "message": "Success",
  "msgDetails": null,
  "result": {
    "data": [
        {
            "timeStamp": 1623913188280,
            "resourceId": "0.1.85",
            "endTimeZone": 1623913200000,
            "value": "2651",
            "subjectId": "lumi.158d000488d874",
            "aggrType": 1,
            "startTimeZone": 1623911400000
        }
    ],
    "scanId": null
  }
}
Copyright © 2023 Lumi United Technology Co., Ltd. all right reserved,powered by GitbookFile Modify: 2024-04-24 15:18:24

results matching ""

    No results matching ""