Group Control

Last Updated on : 2024-04-03 16:36:25download

Combination group control

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. These features can be controlled after the list of combination groups is obtained.

Get area control management class

API description

ILightingGroupPackDpsManager groupPackDpsManager = ThingCommercialLightingGroupPack.newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)

Parameter description

Parameter Description
projectId The project ID.
groupPackBean The combination group object.

Example

ILightingGroupPackDpsManager groupPackDpsManager = ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(projectId,groupPackBean)

Get area-specific DP data

API description

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .getDps()

Parameter description

Parameter Description
projectId The project ID.
groupPackBean The combination group object.

Example

String groupDps = ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .getDps()

Get area toggle status

API description

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .getSwitchStatus()

Parameter description

Parameter Description
projectId The project ID.
groupPackBean The combination group object.

Example

boolean switchOn = ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .getSwitchStatus()

Get brightness (%)

API description

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .getBrightPercent()

Parameter description

Parameter Description
projectId The project ID.
groupPackBean The combination group object.

Example

int brightnessPercent = ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .getBrightPercent()

Get color temperature (%)

API description

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .getTemperaturePercent()

Parameter description

Parameter Description
projectId The project ID.
groupPackBean The combination group object.

Example

int temperaturePercent = ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .getTemperaturePercent()

Get light color value

API description

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .getColorData();

Parameter description

Parameter Description
projectId The project ID.
groupPackBean The combination group object.

Example

String colorData = ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .getColorData();

Get scene mode

API description

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .getSceneStatus();

Parameter description

Parameter Description
projectId The project ID.
groupPackBean The combination group object.

Example

LightDefaultSceneType sceneType = ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .getSceneStatus();

Get current light mode

API description

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .getCurrentMode();

Parameter description

Parameter Description
projectId The project ID.
groupPackBean The combination group object.

Example

AreaDpMode groupDpMode = ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(projectId,groupPackBean)
        .getCurrentMode();

Turn switch on/off

API description

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .publishSwitchStatus(boolean status, final IResultCallback callback);

Parameter description

Parameter Description
status The on/off status.
  • true: Turn on
  • false: Turn off
callback The callback.

Example

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .publishSwitchStatus(true, new IResultCallback() {
            @Override
            public void onError(String errorCode, String errorMsg) {
                if (callback != null) {
                    callback.onError(errorCode, errorMsg);
                }
            }

            @Override
            public void onSuccess() {
                if (callback != null) {
                    callback.onSuccess();
                }
            }
        });

Change light mode

Three light modes are supported: white light, colored light, and scene, corresponding to the MODE_WHITE_LIGHT, MDOE_COLORFUL_LIGHT, and MODE_SCENE in AreaDpMode.

API description

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .publishWorkMode(AreaDpMode mode, IResultCallback callback);

Parameter description

Parameter Description
Mode The light mode. Valid values:
  • MODE_WHITE_LIGHT: White light.
  • MDOE_COLORFUL_LIGHT: Colored light.
  • MODE_SCENE: Scene mode.
callback The callback.

Example

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(projectId,groupPackBean)
        .publishWorkMode(AreaDpMode.MODE_WHITE_LIGHT, new IResultCallback() {
            @Override
            public void onError(String errorCode, String errorMsg) {
                if (callback != null) {
                    callback.onError(errorCode, errorMsg);
                }
            }

            @Override
            public void onSuccess() {
                if (callback != null) {
                    callback.onSuccess();
                }
            }
        });

Adjust color temperature

This operation only applies to the white light mode.

API description

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .publishTemperaturePercent(int value, IResultCallback callback);

Parameter description

Parameter Description
value The color temperature, ranging from 0 to 1,000.
callback The callback.

Example

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(projectId,groupPackBean)
        .publishTemperaturePercent(int value, new IResultCallback() {
            @Override
            public void onError(String errorCode, String errorMsg) {
                if (callback != null) {
                    callback.onError(errorCode, errorMsg);
                }
            }

            @Override
            public void onSuccess() {
                if (callback != null) {
                    callback.onSuccess();
                }
            }
        });

Set scene

This operation only applies to the scene mode.

API description

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .publishSceneStatus(LightDefaultSceneType type, IResultCallback callback);

Parameter description

Parameter Description
type The scene type:
  • NONE: No mode.
  • WORK: Work mode.
  • MEETING: Meeting mode.
  • SIESTA: Nap mode.
  • OFF_DUTY: Leisure mode.
callback The callback.

Example

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(projectId,groupPackBean)
        .publishSceneStatus(LightDefaultSceneType.WORK, new IResultCallback() {
            @Override
            public void onError(String errorCode, String errorMsg) {
                if (callback != null) {
                    callback.onError(errorCode, errorMsg);
                }
            }

            @Override
            public void onSuccess() {
                if (callback != null) {
                    callback.onSuccess();
                }
            }
        });

Set colored light

This operation only applies to the colored light mode.

Get the data for the colored light mode through getColorData. 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.

You can convert colorData into HSV values through stringToHSV, as shown below:

public static float[] stringToHSV(String hsv){
        int h = Integer.valueOf(hsv.substring(0,4),16);
        int s = Integer.valueOf(hsv.substring(4,8),16);
        int v = Integer.valueOf(hsv.substring(8,12),16);
        return new float[]{(float)h,(float)s,(float)v};
}

You can convert HSV values into colorData through hsvToString, as shown below:

public static String hsvToString(int[] hsv) {
        String h = numToHex4(hsv[0]);
        String s = numToHex4(hsv[1]);
        String v = numToHex4(hsv[2]);
        String hhhhssssvvvv = h + s + v;
        return  hhhhssssvvvv;
 }

 public static String numToHex4(int num) {
        return String.format("%04x", num);
 }

API description

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(long projectId,GroupPackBean groupPackBean)
        .publishColors(String color, IResultCallback callback);

Parameter description

Parameter Description
color The color value, a 16-bit string, in the format of hhhhssssvvvv.
callback The callback.

Example

ThingCommercialLightingGroupPack
        .newGroupPackDpsManager(projectId,groupPackBean)
        .publishColors("hhhhssssvvvv", new IResultCallback() {
            @Override
            public void onError(String errorCode, String errorMsg) {
                if (callback != null) {
                    callback.onError(errorCode, errorMsg);
                }
            }

            @Override
            public void onSuccess() {
                if (callback != null) {
                    callback.onSuccess();
                }
            }
        });