Skip to content

设备分组

功能概述

设备分组是指将多个设备归为一组,便于管理,比如将多个设备归为一组,便于进行批量控制、批量查询等操作。

QuecDeviceModel属性定义参考设备管理

objc
#import <QuecDeviceKit/QuecDeviceKit.h>
/// 初始化
[QuecDeviceGroupService sharedInstance]

设备分组

分组列表

接口说明

获取分组列表, 可先调用添加分组接口后获取分组列表数据

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

参数说明

参数是否必传说明
pageNumber页码
pageSize页数据数量
infoModel分组拓展信息
success接口请求成功回调
failure接口请求失败回调

QuecDeviceGroupParamModel属性定义

字段类型描述
nameNSString名称,创建分组时该字段必传
addressNSString地址
contactPhoneListNSString联系人
coordinateNSString经纬度
coordinateSystemNSString坐标系
descripNSString说明
managerNSString管理员
managerTypeNSString管理员类型
parentIdNSString父设备组ID
extendNSString拓展字段

QuecDeviceGroupInfoModel属性定义

字段类型描述
nameNSString名称,创建分组时该字段必传
addressNSString地址
contactPhoneListNSString联系人
coordinateNSString经纬度
coordinateSystemNSString坐标系
descripNSString说明
managerNSString管理员
managerTypeNSString管理员类型
parentIdNSString父设备组ID
extendNSString拓展字段
dgidNSString分组ID
ownerNSString拥有者
addTimeNSString添加时间
addTimeTsNSString添加时间戳

示例代码

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

添加设备分组

接口说明

添加设备分组

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

参数说明

参数是否必传说明
groupInfoModel分组信息
success接口请求成功回调
failure接口请求失败回调

QuecDeviceGroupParamModel属性定义同上

示例代码

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

修改设备组

接口说明

修改设备组信息

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

参数说明

参数是否必传说明
deviceGroupId分组ID
infoModel分组信息
success接口请求成功回调
failure接口请求失败回调

QuecDeviceGroupParamModel属性定义同上

示例代码

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);
    }];

删除设备组

接口说明

根据分组Id删除设备组

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

参数说明

参数是否必传说明
deviceGroupId分组id
success接口请求成功回调
failure接口请求失败回调

示例代码

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

获取分组详情

接口说明

获取分组详情信息

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

参数说明

参数是否必传说明
deviceGroupId分组id
success接口请求成功回调
failure接口请求失败回调

QuecDeviceGroupInfoModel属性定义同上

示例代码

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

分组设备列表

接口说明

获取分组设备列表, 列表数据由[添加设备到设备组中]接口加入

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;

参数说明

参数是否必传说明
deviceGroupId分组id
deviceGroupName分组名称
deviceKeyListdevice key列表,多个device key,使用英文逗号分隔
productKey产品key
pageNumber当前页,默认为第 1 页
pageSize页大小,默认为 10 条
success接口请求成功回调
failure接口请求失败回调

示例代码

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);
    }];

添加设备到设备组中

接口说明

将设备添加到设备组中

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

参数说明

参数是否必传说明
deviceGroupId分组id
deviceList设备列表,示例:@[{@"dk": @"value", @"pk": "value"}]
success接口请求成功回调
failure接口请求失败回调

QuecOperateDeviceToGroupModel属性定义

字段类型描述
successListNSArray<QuecOperateDeviceToGroupRstModel *> *成功列表
failureListNSArray<QuecOperateDeviceToGroupRstModel *> *失败列表

QuecOperateDeviceToGroupFailRstModel属性定义

字段类型描述
dataQuecOperateDeviceToGroupRstModel设备信息
msgNSString错误提示

QuecOperateDeviceToGroupRstModel属性定义

字段类型描述
pkNSString产品pk
dkNSString设备dk

示例代码

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

删除分组中的设备

接口说明

将分组中的设备删除

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

参数说明

参数是否必传说明
deviceGroupId分组id
deviceList设备列表,示例:@[{@"dk": @"value", @"pk": "value"}]
success接口请求成功回调
failure接口请求失败回调

QuecOperateDeviceToGroupModel属性定义同上

示例代码

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

网关设备下子设备列表

接口说明

查询网关设备下子设备列表

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;

参数说明

参数是否必传说明
deviceKey设备dk
productKey产品pk
pageNumber页码
pageSize页大小
success接口请求成功回调
failure接口请求失败回调

示例代码

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);
    }];

不在设备组内的设备列表

接口说明

查询不在设备组内的设备列表, 用于设备过滤添加进设备组

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

参数说明

参数是否必传说明
deviceKey设备dk
productKey产品pk
groupId设备组ID
success接口请求成功回调
failure接口请求失败回调

示例代码

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