Skip to content

Group Control

Feature Description

Device group: organize multiple devices to form a group for easy management and control.

Note

Only when home mode is enabled can the group feature be used.

For all SDK APIs requiring the fid parameter, you can obtain it by calling QuecSmartHomeService.currentFamily().

SDK Integration Method

Note

The group SDK depends on the core library QuecIotSdk to run. Please integrate the core library according to the IoT SDK Integration Guide.

objc
pod 'QuecGroupKit', '~> 0.5.0'

QuecGroupBean Definition

FieldTypeDescription
nameNSStringGroup name.
fidNSStringHome ID.
fridNSStringRoom ID.
gdidNSStringGroup ID.
roomNameNSStringRoom name.
onlineStatusNSUIntegerDevice status.
0-Offline
1-Online
productKeyNSStringProductKey.
deviceKeyNSStringDeviceKey.
isCommonUsedBOOLWhether the device is commonly used.
0-Not commonly used
1-Commonly used
groupDeviceDeviceNumNSIntegerThe number of devices included in the group.
deviceListNSArray<QuecGroupDeviceBean *> *Device list.

QuecGroupDeviceBean Definition

FieldTypeDescription
productKeyNSStringProductKey.
deviceKeyNSStringDeviceKey.
deviceNameNSStringDevice name.
logoImageNSStringDevice logo.
fridNSStringRoom ID.
roomNameNSStringRoom name.
onlineStatusNSIntegerDevice status.
0-Offline
1-Online
msgNSStringMessage of API response.
codeNSIntegerAPI response code.
lowPowerProductBOOLWhether it is a low-power product.
lowPowerStatusBOOLWhether the low-power mode is enabled.
lowPowerCacheNSIntegerCache duration in low-power mode. Unit: second.
lowPowerAliveNSIntegerHeartbeat interval in low-power mode. Unit: minute.
lastOfflineTimeTsNSIntegerTimestamp of device offline.
capabilitiesBitmaskQuecIotChannelBitMaskDevice channel capability mask.
objc
typedef NS_OPTIONS(NSUInteger, QuecIotChannelBitMask)
{
    QuecIotChannelBitMaskWan = 1 << 0,
    QuecIotChannelBitMaskLan = 1 << 1,
    QuecIotChannelBitMaskBle = 1 << 2,
    QuecIotChannelBitMaskMatter = 1 << 3
};

Create Group

API

Create a group.

objc
- (void)createGroupWithBean:(QuecGroupCreateBean *)bean
                    success:(QuecCreateGroupSuccess)success
                    failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
beanYQuecGroupCreateBean class object.
successNCallback function of successful executions.
failureNCallback function of failed executions.

QuecGroupCreateBean Definition

FieldTypeDescription
groupDeviceNameNSStringGroup name.
fidNSStringHome ID.
fridNSStringRoom ID.
isCommonUsedBOOLWhether the device is commonly used.
0-Not commonly used
1-Commonly used
deviceListNSArray<QuecGroupCreateDeviceBean *> *Device list.

QuecGroupCreateDeviceBean Definition

FieldTypeDescription
productKeyNSStringProductKey.
deviceKeyNSStringDeviceKey.

Example

objc
QuecGroupCreateBean *createBean = QuecGroupCreateBean.new;
createBean.groupDeviceName = @"group name";
createBean.fid = @"family id";
createBean.frid = @"family room id";
createBean.isCommonUsed = YES;
createBean.deviceList = @[QuecGroupCreateDeviceBean.new];
[QuecGroupService.sharedInstance createGroupWithBean:createBean success:^(QuecGroupCreateResultBean * _Nonnull result) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Query Group Details

API

Query group details.

objc
- (void)getGroupInfoWithId:(NSString *)groupId
                   success:(QuecGroupBeanSuccess)success
                   failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
groupIdYGroup ID.
successNCallback function of successful executions.
failureNCallback function of failed executions.

The response type is QuecGroupBean, and the properties are defined as above.

Example

objc
[QuecGroupService.sharedInstance getGroupInfoWithId:@"your gdid" success:^(QuecGroupBean * _Nonnull result) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Query Basic Group Information

API

Query the basic information of a group.

objc
- (void)getGroupDeviceInfoWithId:(NSString *)groupId
                         success:(QuecGroupDeviceSuccess)success
                         failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
groupIdYGroup ID.
successNCallback function of successful executions.
failureNCallback function of failed executions.

The response type is QuecDeviceModel, and the properties are defined in SDK description in the Device Management section.

Example

objc
[QuecGroupService.sharedInstance getGroupDeviceInfoWithId:@"your gdid" success:^(QuecDeviceModel * _Nonnull result) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Determine Whether Device Can Join Group

API

Determine whether devices can join the group in batches.

objc
- (void)checkDeviceAddGroupWithList:(NSArray<QuecGroupCreateDeviceBean *> *)deviceList
                                fid:(NSString *)fid
                            success:(QuecGroupCheckDeviceSuccess)success
                            failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
deviceListYQuecGroupCreateDeviceBean class object.
fidYHome ID.
successNCallback function of successful executions.
failureNCallback function of failed executions.

See QuecGroupDeviceBean and QuecGroupCreateDeviceBean Definitions above.

Example

objc
QuecGroupCreateDeviceBean *createDeviceBean = QuecGroupCreateDeviceBean.new;
createDeviceBean.productKey = @"your pk";
createDeviceBean.deviceKey = @"your dk";
[QuecGroupService.sharedInstance checkDeviceAddGroupWithList:@[createDeviceBean] fid:@"fid" success:^(NSArray<QuecGroupDeviceBean *> * _Nonnull result) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Get List of Devices to Be Added

API

Get the list of devices to be added.

objc
- (void)getAddableListWithList:(NSArray<QuecGroupCreateDeviceBean *> *)addedList
                           fid:(NSString *)fid
                          gdid:(nullable NSString *)gdid
                      pageSize:(NSInteger)pageSize
                          page:(NSInteger)page
                       success:(QuecGroupAddableListSuccess)success
                       failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
addedListYQuecGroupCreateDeviceBean
fidYHome ID.
gdidNGroup ID.
pageSizeNPage size. Default value: 10.
pageNPage number. Default value: 1.
successNCallback function of successful executions.
failureNCallback function of failed executions.

See QuecGroupCreateDeviceBean Definition above.

Example

objc
QuecGroupCreateDeviceBean *createDeviceBean = QuecGroupCreateDeviceBean.new;
createDeviceBean.productKey = @"your pk";
createDeviceBean.deviceKey = @"your dk";
[QuecGroupService.sharedInstance getAddableListWithList:@[createDeviceBean]
                                                        fid:@"your fid"
                                                       gdid:@"your gdid"
                                                   pageSize:10
                                                       page:1
                                                    success:^(NSArray<QuecGroupDeviceBean *> * _Nonnull result, NSUInteger total) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Control Group Device

API

Control group devices.

objc
- (void)controlGroupByHttp:(NSArray<QuecIotDataPoint*> *)dps
                   groupId:(NSString *)groupId
                 extraData:(NSDictionary *)extraData
                   success:(QuecVoidBlock)success
                   failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
dpsYdps data (The format encapsulation is the same as the device SDK).
groupIdYGroup ID.
extraDataNExtra data.
successNCallback function of successful executions.
failureNCallback function of failed executions.

extraData Parameter Specification (NSDictionary Format)

objc
{
 type Type 1: Transparent transmission 2: Property 3: Service
 dataFormat Data format 1: Hex 2: Text (If type is transparent transmission, dataFormat must be specified.)
 cacheTime Cache duration (seconds, range: 1-7776000). Required if isCache is enabled.
 isCache  Enable/disable caching 1: Enable 2: Disable (Default)
 isCover Overwrite previous commands: 1-Overwrite, 2-Do not overwrite (Default) This parameter is effective if isCache is enabled.
 }

See QuecIotDataPoint Definition in SDK description in the Device Management section.

Example

objc
QuecIotDataPoint *dp = QuecIotDataPoint.new;
dp.value = @(3);
dp.dataType = QuecIotDataPointDataTypeINT;
dp.Id = 2; /// tsl id
[QuecGroupService.sharedInstance controlGroupByHttp:@[dp] groupId:@"your gdid" extraData:@{} success:^{
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Query Group TSL Property

API

Query group TSL properties.

objc
- (void)groupAttributesById:(NSString *)groupId
                   codeList:(NSString *)codeList
                    success:(void (^)(QuecProductTSLInfoModel *tslInfoModel))success
                    failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
groupIdYGroup ID.
codeListNProperties to be queried. Separate multiple properties by commas.
successNCallback function of successful executions.
failureNCallback function of failed executions.

See QuecProductTSLInfoModel Definition in SDK description in the Device Management section.

Example

objc
[QuecGroupService.sharedInstance groupAttributesById:@"gdid" codeList:@"code1,code2" success:^(QuecProductTSLInfoModel * _Nonnull tslInfoModel) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Query Group TSL Property, Including Property Value

API

Query group TSL properties, including property values.

objc
- (void)groupAttributesWithTSLById:(NSString *)groupId
                        productKey:(NSString *)productKey
                          codeList:(NSString *)codeList
                           success:(void (^)(NSArray<QuecProductTSLPropertyModel *> *arrayData))success
                           failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
beanYQuecGroupCreateBean class object.
productKeyYProductKey.
codeListNProperties to be queried. Separate multiple properties by commas.
successNCallback function of successful executions.
failureNCallback function of failed executions.

See QuecProductTSLPropertyModel Definition in SDK description in the Device Management section.

Example

objc
[QuecGroupService.sharedInstance groupAttributesWithTSLById:@"your gdid" productKey:@"your pk" codeList:@"code1" success:^(NSArray<QuecProductTSLPropertyModel *> * _Nonnull arrayData) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Edit Basic Group Information

API

Edit the basic information of groups.

objc
- (void)editGroupBasicInfoWithId:(NSString *)groupId
                 groupDeviceName:(NSString *)groupDeviceName
                             fid:(nullable NSString *)fid
                            frid:(nullable NSString *)frid
                    isCommonUsed:(BOOL)isCommonUsed
                         success:(QuecVoidBlock)success
                         failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
groupIdYGroup ID.
groupDeviceNameYGroup name.
fidNHome ID.
fridNRoom ID.
isCommonUsedNWhether the device is commonly used.
0-Not commonly used
1-Commonly used
successNCallback function of successful executions.
failureNCallback function of failed executions.

Example

objc
[QuecGroupService.sharedInstance editGroupBasicInfoWithId:@"your gdid" groupDeviceName:@"name" fid:@"fid" frid:@"frid" isCommonUsed:YES success:^{
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Edit Group Information

API

Edit group information.

objc
- (void)editGroupInfoWithId:(NSString *)groupId
                       name:(NSString *)groupDeviceName
                        fid:(NSString *)fid
                       frid:(NSString *)frid
               isCommonUsed:(BOOL)isCommonUsed
                 deviceList:(NSArray<QuecGroupCreateDeviceBean *> *)deviceList
                    success:(QuecVoidBlock)success
                    failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
groupIdYGroup ID.
groupDeviceNameYGroup name.
fidNHome ID.
fridNRoom ID.
deviceListYDevice list.
isCommonUsedNWhether the device is commonly used.
0-Not commonly used
1-Commonly used
successNCallback function of successful executions.
failureNCallback function of failed executions.

Example

objc
QuecGroupCreateDeviceBean *createDeviceBean = QuecGroupCreateDeviceBean.new;
createDeviceBean.productKey = @"your pk";
createDeviceBean.deviceKey = @"your dk";
[QuecGroupService.sharedInstance editGroupInfoWithId:@"your gdid"
                                                name:@"name"
                                                    fid:@"fid"
                                                frid:@"frid"
                                        isCommonUsed:YES
                                            deviceList:@[createDeviceBean] success:^{
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Remove/Add Groups to Common in Batches

API

Remove or add groups to the common in batches.

objc
- (void)batchAddCommonWithIds:(NSArray<NSString *> *)groupIds
                          fid:(NSString *)fid
                 isCommonUsed:(BOOL)isCommonUsed
                      success:(QuecGroupBatchResultBlock)success
                      failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
groupIdsYGroup ID list.
fidNHome ID.
isCommonUsedNWhether the device is commonly used.
0-Not commonly used
1-Commonly used
successNCallback function of successful executions.
failureNCallback function of failed executions.

QuecGroupBatchResultBean Definition

FieldTypeDescription
codeNSStringCode.
msgNSStringPrompt message.
gdidNSStringGroup ID.

Example

objc
[QuecGroupService.sharedInstance batchAddCommonWithIds:@[@"group id1", @"group id2"] fid:@"fid" isCommonUsed:YES success:^(NSArray<QuecGroupBatchResultBean *> * _Nonnull successList, NSArray<QuecGroupBatchResultBean *> * _Nonnull failList) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Move Group to New Room

API

Move groups to a new room in batches. This API is effective only when the home mode is enabled.

objc
- (void)batchMovingWithIds:(NSArray<NSString *> *)groupIds
                   newFrid:(NSString *)newFrid
                   success:(QuecGroupBatchResultBlock)success
                   failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
groupIdsYGroup ID list.
newFridNNew room ID.
successNCallback function of successful executions.
failureNCallback function of failed executions.

See QuecGroupBatchResultBean Definition above.

Example

objc
[QuecGroupService.sharedInstance batchMovingWithIds:@[@"group id1", @"group id2"] newFrid:@"new frid" success:^(NSArray<QuecGroupBatchResultBean *> * _Nonnull successList, NSArray<QuecGroupBatchResultBean *> * _Nonnull failList) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Delete Groups in Batches

API

Delete groups in batches.

objc
- (void)deleteGroupWithIds:(NSArray<NSString *> *)groupIds
                   success:(QuecGroupBatchResultBlock)success
                   failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
groupIdsYGroup ID list.
successNCallback function of successful executions.
failureNCallback function of failed executions.

See QuecGroupBatchResultBean Definition above.

Example

objc
[QuecGroupService.sharedInstance deleteGroupWithIds:@[@"group id1", @"group id2"] success:^(NSArray<QuecGroupBatchResultBean *> * _Nonnull successList, NSArray<QuecGroupBatchResultBean *> * _Nonnull failList) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Set Group Sharing Information

API

Set the sharing information of the group.

objc
- (void)getShareCodeWithGroupId:(NSString *)groupId
              acceptingExpireAt:(long)acceptingExpireAt
           isSharingAlwaysValid:(BOOL)isSharingAlwaysValid
                sharingExpireAt:(long)sharingExpireAt
                      coverMark:(NSInteger)coverMark
                        success:(void(^)(NSString *shareCode))success
                        failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
groupIdYGroup ID.
acceptingExpireAtYExpiration time of the shared QR code, in milliseconds. This share will expire if it is not used before the expiration time.
isSharingAlwaysValidYWhether the device sharing is permanently valid.
sharingExpireAtYExpiration time of the device usage, in milliseconds. The shared group can be used by the recipient before the expiration time.
If this parameter is omitted, the share will be valid permanently.
coverMarkYOverwrite flag. Default value: 1.
1 Directly overwrite the previous valid share (overwrite the existing sharing code)
2 Add a new share directly, allowing multiple shares to coexist
3 Overwrite the previous share only when the sharing time is extended.
successNCallback function of successful executions.
failureNCallback function of failed executions.

Example

objc
[QuecGroupService.sharedInstance getShareCodeWithGroupId:@"your groupId" acceptingExpireAt:1745214106879 isSharingAlwaysValid:YES sharingExpireAt:sharingExpireTS(MS) coverMark:1 success:^(NSString * _Nonnull shareCode) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Get Group Shared Recipient List

API

Get the recipient list to whom the group is shared.

objc
- (void)getSharedListsWithGroupId:(NSString *)groupId
                          success:(void(^)(NSArray<QuecShareUserModel *> *list))success
                          failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
groupIdYGroup ID.
successNCallback function of successful executions.
failureNCallback function of failed executions.

QuecShareUserModel Definition

FieldTypeDescription
shareInfoQuecShareUserShareInfoModelSharing information.
userInfoQuecShareUserInfoModelUser information.

QuecShareUserShareInfoModel Definition

FieldTypeDescription
acceptTimeNSStringTime to accept the sharing.
acceptingExpireAtNSStringExpiration time of accepting the sharing.
coverMarkNSIntegerOverwrite flag.
deviceNameNSStringDevice name.
dkNSStringDeviceKey.
ownerUidNSStringOwner ID.
pkNSStringProductKey.
shareCodeNSStringShare code.
shareIdNSStringSharing ID.
shareStatusNSIntegerSharing status.
shareTimeNSStringTime to create the sharing.
shareUidNSStringUser ID of the share recipient.
sharingExpireAtNSStringExpiration time of the sharing after the sharing is accepted.
updateTimeNSStringUpdate time.

Example

objc
[QuecGroupService.sharedInstance getSharedListsWithGroupId:@"your groupId" success:^(NSArray<QuecShareUserModel *> * _Nonnull list) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Initiator Cancel Sharing

API

The share initiator cancels the sharing.

objc
- (void)ownerUnShareWithShareCode:(NSString *)shareCode
                          success:(QuecVoidBlock)success
                          failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
shareCodeYShare code.
successNCallback function of successful executions.
failureNCallback function of failed executions.

Example

objc
[QuecGroupService.sharedInstance ownerUnShareWithShareCode:@"share code" success:^{
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Recipient Cancel Sharing

API

The share recipient cancels the sharing.

objc
- (void)unShareWithShareCode:(NSString *)shareCode
                     success:(QuecVoidBlock)success
                     failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
shareCodeYShare code.
successNCallback function of successful executions.
failureNCallback function of failed executions.

Example

objc
[QuecGroupService.sharedInstance unShareWithShareCode:@"share code" success:^{
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Accept Sharing

API

The share recipient accepts the sharing.

objc
- (void)acceptShareWithShareCode:(NSString *)shareCode
                         success:(QuecVoidBlock)success
                         failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
shareCodeYShare code.
successNCallback function of successful executions.
failureNCallback function of failed executions.

Example

objc
[QuecGroupService.sharedInstance acceptShareWithShareCode:@"share code" success:^{
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Query Group-sharing Information

API

Query the group-sharing information.

objc
- (void)getShareGroupInfoWithShareCode:(NSString *)shareCode
                            success:(void (^)(QuecGroupBasicInfoBean *infoBean))success
                            failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
shareCodeYShare code.
successNCallback function of successful executions.
failureNCallback function of failed executions.

QuecGroupBasicInfoBean Definition

FieldTypeDescription
gdidNSStringGroup ID.
productkeyNSStringProductKey.
groupDeviceNameNSStringGroup name.
onlinestatusNSUIntegerGroup online status.
0-Offline
1-Online
logoImageNSStringGroup logo.
fidNSStringHome ID.
fridNSStringRoom ID.

Example

objc
[QuecGroupService.sharedInstance getShareGroupInfoWithShareCode:@"share code" success:^(QuecGroupBasicInfoBean * _Nonnull infoBean) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];