Skip to content

Device Group

Feature Description

Device grouping refers to grouping multiple devices into one group for easier management, such as batch control and batch query operations.

See QuecDeviceModel Definition in Device Management

kotlin
QuecDeviceGroupService

Device Group

Get Device Group List

API

Get a device group list. You can first call Add Device Group interface and then obtain the device group list.

kotlin
fun getDeviceGroupList(
    pageNumber: Int,
    pageSize: Int,
    extra: QuecDeviceGroupParamModel?,
    callback: QuecCallback<QuecPageResponse<QuecDeviceGroupInfoModel>>
)

Parameter

ParameterRequiredDescription
pageNumberYPage number.
pageSizeYPage size.
infoModelNGroup expansion information.
callbackYCallback function of the request.

QuecDeviceGroupParamModel Definition

FieldTypeDescription
nameStringName, required when you create a group.
addressStringAddress.
contactPhoneListStringContact person.
coordinateStringLongitude and latitude.
coordinateSystemStringCoordinate system.
descripStringDescription.
managerStringAdministrator.
managerTypeStringAdministrator type.
parentIdStringParent device group ID.
extendStringExtended field.

QuecDeviceGroupInfoModel Definition

FieldTypeDescription
nameStringName, required when you create a group.
addressStringAddress.
contactPhoneListStringContact person.
coordinateStringLongitude and latitude.
coordinateSystemStringCoordinate system.
descripStringDescription.
managerStringAdministrator.
managerTypeStringAdministrator type.
parentIdStringParent device group ID.
extendStringExtended field.
dgidStringGroup ID.
ownerStringOwner.
addTimeStringThe time to add the group.
addTimeTsStringThe timestamp to add the group.

Example

kotlin
QuecDeviceGroupService.getDeviceGroupList(1, 10, null) {
    if (it.isSuccess) {
        val data = it.data //Get a device group list successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Add Device Group

API

Add a device group.

kotlin
fun addDeviceGroup(
    groupInfoModel: QuecDeviceGroupParamModel,
    callback: QuecCallback<Unit>
)

Parameter

ParameterRequiredDescription
groupInfoModelYGroup information.
callbackYCallback function of the request.

See QuecDeviceGroupParamModel Definition above.

Example

kotlin
QuecDeviceGroupService.addDeviceGroup(
    QuecDeviceGroupParamModel(
        name = "name"
    )
) {
    if (it.isSuccess) {
        //Add a device group successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Edit Device Group

API

Edit a device group.

kotlin
fun updateDeviceGroupInfo(
    deviceGroupId: String,
    infoModel: QuecDeviceGroupParamModel,
    callback: QuecCallback<Unit>
)

Parameter

ParameterRequiredDescription
deviceGroupIdYGroup ID.
infoModelYGroup information.
callbackYCallback function of the request.

See QuecDeviceGroupParamModel Definition above.

Example

kotlin
val info = getInfo() //Group information obtained from the cloud
info.name = "name"
QuecDeviceGroupService.updateDeviceGroupInfo(
    "id",
    info
) {
    if (it.isSuccess) {
        //Edit a device group successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Delete Device Group

API

Delete a device group according to group ID.

kotlin
fun deleteDeviceGroup(
    deviceGroupId: String,
    callback: QuecCallback<Unit>
)

Parameter

ParameterRequiredDescription
deviceGroupIdYGroup ID.
callbackYCallback function of the request.

Example

kotlin
QuecDeviceGroupService.deleteDeviceGroup("groupId") {
    if (it.isSuccess) {
        //Delete a device group successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Get Device Group Information

API

Get device group information.

kotlin
fun getDeviceGroupInfo(
    deviceGroupId: String,
    callback: QuecCallback<QuecDeviceGroupInfoModel>
)

Parameter

ParameterRequiredDescription
deviceGroupIdYGroup ID.
callbackYCallback function of the request.

See QuecDeviceGroupInfoModel Definition above.

Example

kotlin
QuecDeviceGroupService.getDeviceGroupInfo("groupId") {
    if (it.isSuccess) {
        val data = it.data //Get device group information successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Get Device List

API

Get a device list. The list data is added through [Add Device to Group] interface.

kotlin
fun getDeviceList(
    deviceGroupId: String?,
    deviceGroupName: String?,
    deviceKeyList: String?,
    productKey: String?,
    pageNumber: Int,
    pageSize: Int,
    callback: QuecCallback<QuecPageResponse<QuecDeviceModel>>
)

Parameter

ParameterRequiredDescription
deviceGroupIdYGroup ID.
deviceGroupNameNDevice group name.
deviceKeyListNDeviceKey list, containing multiple Devicekeys separated by commas.
productKeyNProductKey.
pageNumberYCurrent Page. Default value: 1.
pageSizeYPage size: Default value: 10.
callbackYCallback function of the request.

See QuecDeviceModel Definition above.

Example

kotlin
QuecDeviceGroupService.getDeviceList("groupId", null, null, null, 1, 10) {
    if (it.isSuccess) {
        val data = it.data //Get a device list successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Add Device to Group

API

Add a device to a group.

kotlin
fun addDeviceToGroup(
    deviceGroupId: String,
    deviceList: List<QuecDeviceModel>,
    callback: QuecCallback<QuecOperateDeviceToGroupModel>
)

Parameter

ParameterRequiredDescription
deviceGroupIdYGroup ID.
deviceListYDevice list.
callbackYCallback function of the request.

QuecOperateDeviceToGroupModel Definition

FieldTypeDescription
successListList<QuecOperateDeviceToGroupRstModel>List of successful executions.
failureListList<QuecOperateDeviceToGroupRstModel>List of failed executions.

QuecOperateDeviceToGroupFailRstModel Definition

FieldTypeDescription
dataQuecOperateDeviceToGroupRstModelDevice information.
msgStringPrompt message.

QuecOperateDeviceToGroupRstModel Definition

FieldTypeDescription
pkStringProductKey.
dkStringDeviceKey.

Example

kotlin
QuecDeviceGroupService.addDeviceToGroup(
    "groupId",
    listOf(QuecDeviceModel("productKey", "deviceKey"))
) {
    if (it.isSuccess) {
        val data = it.data //Add a device to a group successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Delete Device from Group

API

Delete a device from a group.

kotlin
fun deleteDeviceFromGroup(
    deviceGroupId: String,
    deviceList: List<QuecDeviceModel>,
    callback: QuecCallback<QuecOperateDeviceToGroupModel>
)

Parameter

ParameterRequiredDescription
deviceGroupIdYGroup ID.
deviceListYDevice List.
callbackYCallback function of the request.

See QuecOperateDeviceToGroupModel Definition above.

Example

kotlin
QuecDeviceGroupService.deleteDeviceFromGroup(
    "groupId",
    listOf(QuecDeviceModel("productKey", "deviceKey"))
) {
    if (it.isSuccess) {
        //Delete a device from a group successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Get Sub-device List of Gateway

API

Get a sub-device list of a gateway.

kotlin
fun getGatewayDeviceChildList(
    deviceKey: String,
    productKey: String,
    pageNumber: Int,
    pageSize: Int,
    callback: QuecCallback<QuecPageResponse<QuecDeviceModel>>
)

Parameter

ParameterRequiredDescription
deviceKeyYDeviceKey.
productKeyYProductKey.
pageNumberYPage number.
pageSizeYPage size.
callbackYCallback function of the request.

See QuecDeviceModel Definition above.

Example

kotlin
QuecDeviceGroupService.getGatewayDeviceChildList("deviceKey", "productKey", 1, 10) {
    if (it.isSuccess) {
        val data = it.data //Get a sub-device list of a gateway successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Get Device List Not in Device Group

API

Get a device list not in a device group for devices filtering and adding them to a device group.

kotlin
fun getDeviceListByNotInDeviceGroup(
    pageNumber: Int,
    pageSize: Int,
    groupId:String,
    callback: QuecCallback<QuecPageResponse<QuecDeviceModel>>
)

Parameter

ParameterRequiredDescription
pageNumberYPage number.
pageSizeYPage size.
groupIdYDevice group ID.
callbackYCallback function of the request.

See QuecDeviceModel Definition above.

Example

kotlin
QuecDeviceGroupService.getDeviceListByNotInDeviceGroup(1, 10, "groupId") {
    if (it.isSuccess) {
        val data = it.data //Get a device list not in a device group successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}