Group Control

Last Updated on : 2024-04-07 08:24:17download

This feature allows users to control the devices in a collection of groups in one go. The control supports on/off, brightness, mode, and color temperature. The following properties of the ThingSmartPackedGroup class can be used to get the status of the current combination group.

Data model of ThingSmartPackedGroup

Field Type Description
dps NSDictionary The data points (DPs) of a device.
switchStatus BOOL The on/off status.
sceneStatus NSString The scene mode. Valid values:
  • THING_LIGHTING_SCENE_WORK: working
  • THING_LIGHTING_SCENE_MEETING: meeting
  • THING_LIGHTING_SCENE_SIESTA: nap
  • THING_LIGHTING_SCENE_OFF_DUTY: leisure
workModel NSString The working mode. Valid values:
  • THING_LIGHTING_MODE_WHITE: the white light mode
  • THING_LIGHTING_MODE_COLOUR: the colored light mode
  • THING_LIGHTING_MODE_SCENE: the scene mode
brightPercent NSInteger The brightness percentage. Valid values: 0 to 100.
temperaturePercent NSInteger The color temperature percentage. Valid values: 0 to 100.
colorData NSString The data of colored light. This API method only works when the combination group stays in colored light mode. The 12-bit data is formatted as hhhhssssvvvv.
  • hhhh represents the hue value in hex format.
  • ssss represents the saturation value in hex format.
  • vvvv represents the brightness value in hex format.
ThingLightingColorUtil provides the method decodeNewHsvWithHsvString to decode colorData into an HSV value.

Send DP commands

API description

- (void)publishDps:(NSDictionary *)dps
           success:(nullable ThingSuccessHandler)success
           failure:(nullable ThingFailureError)failure;

Parameters

Parameter Description
dps The DPs of a specified combination group.
success The success callback.
failure The failure callback.

Sample code

Objective-C:

[self.packedGroup publishDps:@{@"1" : @"1"} success:^(void) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];

Set a shortcut switch for a combination group

API description

- (void)publishSwitchStauts:(BOOL)switchValue
                    success:(nullable ThingSuccessID)success
                    failure:(nullable ThingFailureError)failure;

Parameters

Parameter Description
switchStatus The on/off status.
success The success callback.
failure The failure callback.

Sample code

Objective-C:

[self.packedGroup publishSwitchStatus:YES success:^(id result) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];

Set a scene mode

API description

This API method works only when the combination group stays in scene mode.

- (void)publishSceneStatus:(NSString *)sceneId
                   success:(nullable ThingSuccessID)success
                   failure:(nullable ThingFailureError)failure;

Parameters

Parameter Description
sceneId The scene ID. Valid values:
  • THING_LIGHTING_SCENE_WORK: working
  • THING_LIGHTING_SCENE_MEETING: meeting
  • THING_LIGHTING_SCENE_SIESTA: nap
  • THING_LIGHTING_SCENE_OFF_DUTY: leisure
success The success callback.
failure The failure callback.

Sample code

Objective-C:

[self.packedGroup publishSceneStatus:THING_LIGHTING_SCENE_WORK success:^(id result) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];

Set working mode

API description

- (void)publishWorkMode:(NSString *)workMode
                success:(nullable ThingSuccessID)success
                failure:(nullable ThingFailureError)failure;

Parameters

Parameter Description
workMode The working mode. Valid values:
  • THING_LIGHTING_MODE_WHITE: the white light mode
  • THING_LIGHTING_MODE_COLOUR: the colored light mode
  • THING_LIGHTING_MODE_SCENE: the scene mode
success The success callback.
failure The failure callback.

Sample code

Objective-C:

[self.packedGroup publishWorkMode:THING_LIGHTING_MODE_WHITE success:^(id result) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];

Set brightness

API description

This API method works only when the combination group stays in white light mode.

- (void)publishBrightPercent:(NSInteger)brightPercent
                     success:(nullable ThingSuccessID)success
                     failure:(nullable ThingFailureError)failure;

Parameters

Parameter Description
brightPercent The brightness percentage. Valid values: 0 to 100.
success The success callback.
failure The failure callback.

Sample code

Objective-C:

[self.packedGroup publishBrightPercent:100 success:^(id result) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];

Set color temperature

API description

This API method works only when the combination group stays in white light mode.

- (void)publishTemperaturePercent:(NSInteger)temperaturePercent
                          success:(nullable ThingSuccessID)success
                          failure:(nullable ThingFailureError)failure;

Parameters

Parameter Description
TemperaturePercent The color temperature percentage. Valid values: 0 to 100.
success The success callback.
failure The failure callback.

Sample code

Objective-C:

[self.packedGroup publishTemperaturePercent:100 success:^(id result) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];

Set brightness and color temperature

API description

This API method works only when the combination group stays in white light mode.

- (void)publishBrightPercent:(NSInteger)brightPercent
          temperaturePercent:(NSInteger)temperaturePercent
                     success:(nullable ThingSuccessID)success
                     failure:(nullable ThingFailureError)failure;

Parameters

Parameter Description
brightPercent The brightness percentage. Valid values: 0 to 100.
temperaturePercent The color temperature percentage. Valid values: 0 to 100.
success The success callback.
failure The failure callback.

Sample code

Objective-C:

[self.packedGroup publishBrightPercent:100 temperaturePercent:100 success:^(id result) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];

Set colored light

API description

This API method only works when the combination group stays in colored light mode. colors indicates the result string of HSV encoding. ThingLightingAreaHelper provides the method encodeNewHsvWithHue:saturation:brightness: to encode an HSV value into colorData.

- (void)publishColors:(NSString *)colors
              success:(nullable ThingSuccessID)success
              failure:(nullable ThingFailureError)failure;

Parameters

Parameter Description
colors The colored light.
success The success callback.
failure The failure callback.

Sample code

Objective-C:

[self.packedGroup publishColors:@"" success:^(id result) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];