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

objc
#import <QuecDeviceKit/QuecDeviceKit.h>
/// Initialize
[QuecDeviceGroupService sharedInstance]

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.

objc
- (void)getDeviceGroupListWithPageNumber:(NSInteger)pageNumber
                                  pageSize:(NSInteger)pageSize
                                     extra:(QuecDeviceGroupParamModel * _Nullable)infoModel
                                   success:(void(^)(NSArray<QuecDeviceGroupInfoModel *> *list, NSInteger total))success
                                   failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
pageNumberYPage number.
pageSizeYPage size.
infoModelNGroup expansion information.
successNCallback function of successful request.
failureNCallback function of failed request.

QuecDeviceGroupParamModel Definition

FieldTypeDescription
nameNSStringName, required when you create a group.
addressNSStringAddress.
contactPhoneListNSStringContact person.
coordinateNSStringLongitude and latitude.
coordinateSystemNSStringCoordinate system.
descripNSStringDescription.
managerNSStringAdministrator.
managerTypeNSStringAdministrator type.
parentIdNSStringParent device group ID.
extendNSStringExtended field.

QuecDeviceGroupInfoModel Definition

FieldTypeDescription
nameNSStringName, required when you create a group.
addressNSStringAddress.
contactPhoneListNSStringContact person.
coordinateNSStringLongitude and latitude.
coordinateSystemNSStringCoordinate system.
descripNSStringDescription
managerNSStringAdministrator.
managerTypeNSStringAdministrator type.
parentIdNSStringParent device group ID.
extendNSStringExtended field.
dgidNSStringGroup ID.
ownerNSStringOwner.
addTimeNSStringThe time to add the group.
addTimeTsNSStringThe timestamp to add the group.

Example

objc
[QuecDeviceGroupService.sharedInstance getDeviceGroupListWithPageNumber:1
                                                                   pageSize:10
                                                                      extra:nil
                                                                    success:^(NSArray<QuecDeviceGroupInfoModel *> *list, NSInteger total) {
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Add Device Group

API

Add a device group.

objc
- (void)addDeviceGroupWithInfo:(QuecDeviceGroupParamModel *)groupInfoModel
                        success:(QuecVoidBlock)success
                        failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
groupInfoModelYGroup information.
successNCallback function of successful request.
failureNCallback function of failed request.

See QuecDeviceGroupParamModel Definition above.

Example

objc
QuecDeviceGroupParamModel *paramModel = [[QuecDeviceGroupParamModel alloc] init];
paramModel.name = @"group name";
[QuecDeviceGroupService.sharedInstance addDeviceGroupWithInfo:paramModel success:^{
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Edit Device Group

API

Edit a device group.

objc
- (void)updateDeviceGroupInfoWithDeviceGroupId:(NSString *)deviceGroupId
                                       infoModel:(QuecDeviceGroupParamModel * _Nullable)infoModel
                                         success:(QuecVoidBlock)success
                                         failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
deviceGroupIdYGroup ID.
infoModelYGroup information.
successNCallback function of successful request.
failureNCallback function of failed request.

See QuecDeviceGroupParamModel Definition above.

Example

objc
QuecDeviceGroupParamModel *paramModel = [[QuecDeviceGroupParamModel alloc] init];
paramModel.name = @"group name";
[QuecDeviceGroupService.sharedInstance updateDeviceGroupInfoWithDeviceGroupId:@"dgid" infoModel:paramModel success:^{
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Delete Device Group

API

Delete a device group according to group ID.

objc
- (void)deleteDeviceGroupWithDeviceGroupId:(NSString *)deviceGroupId
                                     success:(QuecVoidBlock)success
                                     failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
deviceGroupIdYGroup ID.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecDeviceGroupService.sharedInstance deleteDeviceGroupWithDeviceGroupId:@"dgid" success:^{
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Get Device Group Information

API

Get device group information.

objc
- (void)getDeviceGroupInfoWithDeviceGroupId:(NSString *)deviceGroupId
                                      success:(void(^)(QuecDeviceGroupInfoModel *model))success
                                      failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
deviceGroupIdYGroup ID.
successNCallback function of successful request.
failureNCallback function of failed request.

See QuecDeviceGroupInfoModel Definition above.

Example

objc
[QuecDeviceGroupService.sharedInstance getDeviceGroupInfoWithDeviceGroupId:@"gpid" success:^(QuecDeviceGroupInfoModel * _Nonnull model) {
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Get Device List

API

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

objc
- (void)getDeviceListWithDeviceGroupId:(NSString *)deviceGroupId
                        deviceGroupName:(NSString * _Nullable)deviceGroupName
                          deviceKeyList:(NSString * _Nullable)deviceKeyList
                             productKey:(NSString * _Nullable)productKey
                             pageNumber:(NSInteger)pageNumber
                               pageSize:(NSInteger)pageSize
                                success:(void (^)(NSArray<QuecDeviceModel *> *list, NSInteger total))success
                                failure:(QuecErrorBlock)failure;

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.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecDeviceGroupService.sharedInstance getDeviceListWithDeviceGroupId:@"gpid"
                                                          deviceGroupName:nil
                                                            deviceKeyList:nil
                                                               productKey:nil
                                                               pageNumber:1
                                                                 pageSize:1000
                                                                  success:^(NSArray<QuecDeviceModel *> *list, NSInteger total) {
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Add Device to Group

API

Add a device to a group.

objc
- (void)addDeviceToGroupWithDeviceGroupId:(NSString *)deviceGroupId
                                 deviceList:(NSArray *)deviceList
                                    success:(void(^)(QuecOperateDeviceToGroupModel *model))success
                                    failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
deviceGroupIdYGroup ID.
deviceListYDevice list, example: @[{@"dk": @"value", @"pk": "value"}].
successNCallback function of successful request.
failureNCallback function of failed request.

QuecOperateDeviceToGroupModel Definition

FieldTypeDescription
successListNSArray<QuecOperateDeviceToGroupRstModel *> *List of successful executions.
failureListNSArray<QuecOperateDeviceToGroupRstModel *> *List of failed executions.

QuecOperateDeviceToGroupFailRstModel Definition

FieldTypeDescription
dataQuecOperateDeviceToGroupRstModelDevice information.
msgNSStringPrompt message.

QuecOperateDeviceToGroupRstModel Definition

FieldTypeDescription
pkNSStringProductKey.
dkNSStringDeviceKey.

Example

objc
[QuecDeviceGroupService.sharedInstance addDeviceToGroupWithDeviceGroupId:@"gpid"
                                                            deviceList:@[{@"dk": @"value", @"pk": "value"}]
                                                                success:^(QuecOperateDeviceToGroupModel * _Nonnull model) {
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Delete Device from Group

API

Delete a device from a group.

objc
- (void)deleteDeviceFromGroupWithDeviceGroupId:(NSString *)deviceGroupId
                                      deviceList:(NSArray *)deviceList
                                         success:(void(^)(QuecOperateDeviceToGroupModel *model))success
                                         failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
deviceGroupIdYGroup ID.
deviceListYDevice List, example: @[{@"dk": @"value", @"pk": "value"}].
successNCallback function of successful request.
failureNCallback function of failed request.

See QuecOperateDeviceToGroupModel Definition above.

Example

objc
[QuecDeviceGroupService.sharedInstance deleteDeviceFromGroupWithDeviceGroupId:@"gpid"
deviceList:@[{@"dk": @"value", @"pk": "value"}] success:^(QuecOperateDeviceToGroupModel * _Nonnull model) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Get Sub-device List of Gateway

API

Get a sub-device list of a gateway.

objc
- (void)getGatewayDeviceChildListWithDeviceKey:(NSString *)deviceKey
                                      productKey:(NSString *)productKey
                                      pageNumber:(NSInteger)pageNumber
                                        pageSize:(NSInteger)pageSize
                                         success:(void(^)(NSArray<QuecDeviceModel *> *list, NSInteger total))success
                                         failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
deviceKeyYDeviceKey.
productKeyYProductKey.
pageNumberYPage number.
pageSizeYPage size.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecDeviceGroupService.sharedInstance getGatewayDeviceChildListWithDeviceKey:@"deviceKey" productKey:@"productKey" pageNumber:1 pageSize:10 success:^(NSArray<QuecDeviceModel *> * _Nonnull list, NSInteger total) {
         /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

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.

objc
- (void)getDeviceListByNotInDeviceGroupWithPageNumber:(NSInteger)pageNumber
                                                pageSize:(NSInteger)pageSize
                                                 groupId:(NSString *)groupId
                                                 success:(void(^)(NSArray<QuecDeviceModel *> *list, NSInteger total))success
                                                 failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
deviceKeyYDeviceKey.
productKeyYProductKey.
groupIdYDevice group ID.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecDeviceGroupService.sharedInstance getDeviceListByNotInDeviceGroupWithPageNumber:1
                                                                                pageSize:10
                                                                                 groupId:@"gpId"
                                                                                 success:^(NSArray<QuecDeviceModel *> *list, NSInteger total) {
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];