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:
|
workModel | NSString | The working mode. Valid values:
|
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 .
ThingLightingColorUtil provides the method decodeNewHsvWithHsvString to decode colorData into an HSV value. |
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");
}];
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");
}];
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:
|
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");
}];
API description
- (void)publishWorkMode:(NSString *)workMode
success:(nullable ThingSuccessID)success
failure:(nullable ThingFailureError)failure;
Parameters
Parameter | Description |
---|---|
workMode | The working mode. Valid values:
|
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");
}];
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");
}];
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");
}];
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");
}];
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");
}];
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback