English
English
简体中文
Contact Us
Register
Log In
layoutIndex

Lighting SDK

Last Updated on : 2022-03-30 10:18:54download

The development of lighting devices is complex due to two coexisting versions of light firmware coexist, v1 and v2. You must develop two sets of control logic even though standard commands are used. The packaged lighting functions include on/off, working mode, brightness, color temperature, multi-color, and four scenes.

Demo app

For more information about the Lighting SDK on GitHub, see Lighting SDK.

Follow the instructions in the Smart Life App SDK demo app, and configure the values of BundleId, AppKey, AppSecret, and security image.

Based on the features of the Smart Life App SDK demo app, the Lighting SDK demo app is added with the capabilities to connect lighting devices. You can call the encapsulated APIs to implement these capabilities and accelerate the app development process. The following features are supported:

  • Get the light type
  • Get all DP values
  • Turn a light on or off
  • Switch between working modes
  • Adjust light brightness
  • Adjust color temperature
  • Switch between scenes
  • Adjust light colors

Depend on services

Add dependencies

implementation 'com.tuya.smart:tuyasmart:3.22.0'
// Control SDK dependencies
implementation 'com.tuya.smart:tuyasmart-centralcontrol:1.0.3'

Integrate with Kotlin dependency

tuyasmart-centralcontrol is compiled in Kotlin, so you need to import the Kotlin library to ensure that dependencies can be properly used. If you have imported the Kotlin library, you can ignore the following configuration.

  1. Import the dependencies of the Kotlin plug-in to the build.gradle file.

    buildscript {
    	ext.kotlin_version = '1.3.72'
    	dependencies {
    		...
    		classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    	}
    }
    
  2. Import the Kotlin plug-in and Kotlin package to the build.gradle file.

    apply plugin: 'kotlin-android'
    dependencies {
    	implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    }
    

This section contains the following topics to help you quickly understand related concepts and how-to guides: