Area Control

Last Updated on : 2024-04-03 08:20:35download

Centrally controls devices in an area. Currently, device features such as switches, brightness, modes, and color temperature can be controlled. ThingLightingArea provides the following properties to indicate the status in an area.

Data model of ThingLightingArea

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 works only when the target area stays in colored light mode. This 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 DPs to an area

API description

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

Parameters

Parameter Description
dps The collection of DPs in an area.
success The success callback.
failure The failure callback.

Sample code

Objective-C:

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

Set a shortcut switch in an area

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.area 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 target area 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.area 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.area 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 target area 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.area publishBrightPercent:100 success:^(id result) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];

Set color temperature

API description

This API method works only when the target area 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.area 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 target area 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.area publishBrightPercent:100 temperaturePercent:100 success:^(id result) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];

Set colored light

API description

This API method works only when the target area 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 Colored light
success The success callback.
failure The failure callback.

Sample code

Objective-C:

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