Lighting Scenario UI BizBundle

Last Updated on : 2024-04-28 06:10:09download

Lighting scenarios enable users to customize lighting colors for their homes with a color palette and a scene library.

Features

The Lighting Scenario UI BizBundle supports the following features:

  • Create a lighting scenario.
  • Edit a lighting scenario, including the icon, name, and all device scenes.
  • Preview the custom scene for a single device that supports the cool white light, cool and warm white light, colored light, cool white and colored light, and white and colored light.
  • Preview the mode, color, and flashing scenes for a single device.
  • Preview a lighting scenario.
  • Adjust brightness, color temperature, and hue on a single device.
  • Adjust the overall brightness and color temperature.

Fast integration

The UI BizBundle relies on Smart Life App SDK. Before the following procedure, you must first finish the steps in Preparation and Fast Integration with Smart Life App SDK for Android.

  1. Create a project.

    Smart Life App SDK for Android is integrated into your project with Android Studio. The UI BizBundle is added to your project. For more information, see Integration with UI BizBundle SDK for Android.

  2. Configure the build.gradle file.

    
    dependencies {
        api enforcedPlatform("com.thingclips.smart:thingsmart-BizBundlesBom:${biz_bom_version}")
        implementation 'com.thingclips.smart:thingsmart-bizbundle-light_scene'
        api "com.thingclips.smart:thingsmart:${sdk_version}}"
    }
    
    
  3. Obfuscate the code.

    #fresco
    -keep class com.facebook.drawee.backends.pipeline.Fresco
    -keep @com.facebook.common.internal.DoNotStrip class *
    -keepclassmembers class * {
    @com.facebook.common.internal.DoNotStrip *;
    }
    
    #thingclips
    -keep class com.thingclips.**{*;}
    -dontwarn com.thingclips.**
    
  4. (Optional) Configure multilingual options.

    Currently, the UI BizBundle supports Chinese and English only. However, in the following fields, you can customize value.

    • Settings in English: Copy and paste the following code block to the file res/values/strings.xml:

      <?xml version="1.0" encoding="utf-8"?>
      <resources>
          <string name="thing_light_scene_add">New Lighting Scenario</string>
          <string name="thing_light_scene_add_area_tip">Choose space to create a lighting Scenario</string>
          <string name="thing_light_lamp_add_area_empty">No Lamps</string>
          <string name="thing_light_scene_add_device_tip">Setting lamps to create a lighting Scenario</string>
          <string name="thing_light_scene_set_name_icon">Choose an icon and name you like</string>
          <string name="thing_light_scene_default_name">New lighting scenario</string>
          <string name="thing_light_scene_edit">Edit lighting scenario</string>
          <string name="thing_light_scene_manage_nav_title">Scene Management</string>
          <string name="thing_light_scene_manage_delete_tips">Are you sure you want to delete?</string>
          <string name="thing_light_scene_manage_delete_scene_tips_detail">Relevant schedules in this scenario will also be deleted</string>
          <string name="thing_scene_add_lamp_offline_tip">Lamp is offline</string>
          <string name="thing_scene_add_lamp_lack_gateway">Lighting not connected to gateway</string>
          <string name="thing_scene_add_lamp_group_empty_tip">No device in this group</string>
          <string name="thing_light_scene_edit_quit_tip">Are you sure to exit?</string>
          <string name="thing_light_scene_edit_quit_tip_detail">The content will not be saved after exiting</string>
          <string name="thing_light_scene_icon_select">Select Icon</string>
          <string name="thing_light_scene_add_success">Saved</string>
          <string name="thing_light_scene_main_light">Functional lighting</string>
          <string name="thing_light_scene_secondary_light">Ambience lighting</string>
          <string name="thing_light_scene_secondary_light_source">Ambience lighting</string>
      </resources>
      
    • Settings in Chinese: Copy and paste the following code block to the file res/values-zh/strings.xml.

      <?xml version="1.0" encoding="utf-8"?>
      <resources>
          <string name="thing_light_scene_add">添加新灯光场景</string>
          <string name="thing_light_scene_add_area_tip">选择一个空间区域创建灯光环境</string>
          <string name="thing_light_lamp_add_area_empty">暂无灯具</string>
          <string name="thing_light_scene_add_device_tip">按照主次调节灯光设置整体效果</string>
          <string name="thing_light_scene_set_name_icon">选择一个自己喜欢的图标和名称</string>
          <string name="thing_light_scene_default_name">新灯光场景</string>
          <string name="thing_light_scene_edit">编辑灯光场景</string>
          <string name="thing_light_scene_manage_nav_title">场景管理</string>
          <string name="thing_light_scene_manage_delete_tips">确定要删除?</string>
          <string name="thing_light_scene_manage_delete_scene_tips_detail">该场景下的相关日程也将会被删除</string>
          <string name="thing_scene_add_lamp_offline_tip">灯具已离线</string>
          <string name="thing_scene_add_lamp_group_empty_tip">该组灯中无设备</string>
          <string name="thing_scene_add_lamp_lack_gateway">灯具未连接网关</string>
          <string name="thing_light_scene_edit_quit_tip">确认退出?</string>
          <string name="thing_light_scene_edit_quit_tip_detail">退出后所填内容将不会保存</string>
          <string name="thing_light_scene_icon_select">选择图标</string>
          <string name="thing_light_scene_add_success">添加成功</string>
          <string name="thing_light_scene_main_light">功能灯光</string>
          <string name="thing_light_scene_secondary_light">氛围灯光</string>
          <string name="thing_light_scene_secondary_light_source">氛围灯光</string>
      </resources>
      

Functional description

Data model of ThingLightSceneBean

Property Type Description
sceneId String The unique identifier for the scenario.
code String The input parameter code to run the scenario.
parentRegionId String The room ID of the scenario.
icon String The scenario icon.
clickIcon String The single-tap icon to implement interactions in the scenario.
name String The name of the scenario.

Business API methods

Provide services

The UI BizBundle relies on the implementation of AbsLightScenePlugService to provide services.

Example

// Returns the services provided by the Lighting Scenario UI BizBundle.
AbsLightScenePlugService sceneLightingService = MicroContext.findServiceByInterface(AbsLightScenePlugService.class.getName());

Create a lighting scenario

API description

Create a lighting scenario

void launchLightSceneCreate(Context context, int requestCode);

Parameter description

Parameter Type Description
context Context The Context object.
requestCode int The value of requestCode must be larger than 0. After a scenario is created, you can get the code from onActivityResult().

Example

AbsLightScenePlugService sceneLightingService = MicroContext.findServiceByInterface(AbsLightScenePlugService.class.getName());
if(null != sceneLightingService) {
    sceneLightingService.launchLightSceneCreate(context, 100);
}

Modify a lighting scenario

API description

Opens the page to modify a lighting scenario.

launchLightSceneEdit(Context context, LightSceneDetailBean bean, int requestCode);

Parameter description

Parameter Type Description
context Context The Context object.
bean LightSceneDetailBean The Bean data of the lighting scenario.
requestCode int The value of requestCode must be larger than 0. After a scenario is modified, you can get the code from onActivityResult().

Example

AbsLightScenePlugService sceneLightingService = MicroContext.findServiceByInterface(AbsLightScenePlugService.class.getName());
if(null != sceneLightingService) {
    sceneLightingService.launchLightSceneEdit(context, new LightSceneDetailBean(thingLightSceneBean), 101);
}

Cloud service API methods

Class name Description
ThingLightSceneSdk The lighting scenario SDK.

Query a list of lighting scenarios

API description

Returns a list of lighting scenarios.

void getAllLightSceneList(long gid, IThingLightResultCallback<ArrayList<ThingLightSceneBean>> callback);

Parameter description

Parameter Description
gid The current home ID.
callback The callback.

Example

ThingLightSceneSdk.getThingLightSceneManagerInstance().getAllLightSceneList(gid, new IThingLightResultCallback<ArrayList<ThingLightSceneBean>>() {
    @Override
    public void onSuccess(ArrayList<ThingLightSceneBean> thingLightSceneBeans) {

    }

    @Override
    public void onFailure(String code, String detail) {

    }
});

Run a lighting scenario

API description

Runs a lighting scenario

void executeLightScene(long gid, IThingLightResultCallback<Boolean> callback);

Parameter description

Parameter Description
code The input parameter code to run the scenario.
gid The current home ID.
callback The callback.

Example

ThingLightSceneSdk.newLightSceneInstance(thingLightSceneBean.getCode()).executeLightScene(gid, new IThingLightResultCallback<Boolean> (){
    @Override
    public void onSuccess(Boolean aBoolean) {

    }

    @Override
    public void onFailure(String code, String detail) {

    }
});