Function Definition of Spotlight

Last Updated on : 2024-06-21 04:01:09download

Types of data point (DP)

Tuya Developer Platform allows you to define functions with six data types, including Boolean, value, enum, fault, string, and raw. For more information, see Custom Functions.

Standard functions

DP Identifier Data transfer type DP type DP property Note
On/Off switch_led Send and report (read-write) Boolean / /
Mode work_mode Send and report (read-write) Enum The enum values include white, color, scene, and music. /
Brightness bright_value Send and report (read-write) Value
  • The value ranges from 10 to 1,000.
  • Pitch: 1
  • Scale: 0
/
Color temperature temp_value Send and report (read-write) Value
  • The value ranges from 10 to 1,000.
  • Pitch: 1
  • Scale: 0
/
Color colour_data Send and report (read-write) String / /
Scene scene_data Send and report (read-write) String / /
Timer countdown Send and report (read-write) Value Value range
  • 0 to 86,400
  • Pitch: 1
  • Scale: 0
  • Unit: second (s)
/
Music music_data Send only (write-only) String / /
Adjust control_data Send only (write-only) String / /
Debugger debug_data Send only (write-only) String / Used for gamma calibration only.

Description of DPs

DP20(1): on/off (required)

Data type Value range Example
Boolean
  • true: turn light on.
  • false: turn light off.
{"20":true}

DP21(2): mode (required)

Data type Value range Example
Enum
  • white: white light.
  • colour: colored light.
  • scene: scene.
  • music: music light.
{"21":"scene"}

Mode description

White light, colored light, scene, and music light are displayed at the bottom tab on the mobile app.

  • White light: determined by two DPs together, mode and brightness.
  • Colored light: determined by two DPs together, mode and color.
  • Scene: determined by two DPs together, mode and scene.
  • Music light: determined by two DPs together, mode and music.
  • Delay time: determined by the DP timer.
  • Schedule: determined by the enablement of cloud timing in the advanced cloud functions.

DP22(3): brightness

Data type Value range Example
Value 10 to 1,000
Note: The brightness range of 10 to 1,000 corresponds to the value range of 1% to 100% on the mobile app. The minimum value is 1%.
{"22":670 "}

DP23(4): color temp

Data type Value range Example
Value 0 to 1,000
Note: The color temperature range of 0 to 1,000 corresponds to the value range of 0% to 100% on the mobile app. The color temperature range is defined between the coolest white and warmest white. The actual color temperature depends on the bead specifications, such as 2700K to 6500K.
{"23":797"}

DP24(5): color

Data type Value range Example
String 000011112222
  • 0000: indicates hue. It ranges from 0 to 360, corresponding to 0x0000 to 0x0168.
  • 1111: indicates saturation. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
  • 2222: indicates value. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
{"24":"00DC004B004E"}
HSV value is 00DC, 004B, and 004E in hex format. After converting them to the decimal format, you will get 220°, 75%, 78%.

Color values are output in HSV format. Alternatively, you can convert values to the RGB format. For more information, visit color conversion.

DP25(6): scene

Data type Value range Example
String 0011223344445555666677778888
  • 00: the scene ID.
  • 11: the transition interval between lighting modes. It ranges from 0 to 100.
  • 22: the lighting mode duration. It ranges from 0 to 100.
  • 33: the lighting mode. 0: static. 1: jumping. 2: gradient.
  • 4444: indicates hue. It ranges from 0 to 360, corresponding to 0x0000 to 0x0168.
  • 5555: indicates saturation. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
  • 6666: indicates value. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
  • 7777: indicates brightness. It ranges from 0 to 1,000.
  • 8888: indicates color temperature. It ranges from 0 to 1,000.
    Note: Except for the scene ID, the data in this string represents one color data unit. If multiple colors are used, you will get multiple color data units accordingly.
{"25":"010b0a02000003e803e8000000000b0a02007603e803e8000000000b0a0200e703e803e800000000"}
  • 01: indicates the scene ID is 01.
  • 0b: indicates the transition interval between lighting modes is 0.
  • 0a: indicates the lighting mode duration is 10.
  • 02: indicates the lighting mode is gradient.
  • 0000: indicates hue is 0x0000.
  • 03e8: indicates saturation. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
  • 03e8: indicates value. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
  • 0000: indicates brightness. It ranges from 0 to 1,000.
  • 0000: indicates color temperature. It ranges from 0 to 1,000.

DP26(7): timer

Data type Value range Example
Value 0 to 86,400
  • 0: indicates the timer is turned off.
  • Other values: time value in the unit of seconds. The 86,400 represents 23:59.
{"26":"120"} indicates 120 seconds.

The time delay feature is available for users only after you add this DP to your product.

DP27(8): music

Data type Value range Example
String 011112222333344445555
  • 0: the lighting mode.
    • 0: direct output.
    • 1: gradient mode.
  • 1111: indicates hue. It ranges from 0 to 360, corresponding to 0x0000 to 0x0168.
  • 2222: indicates saturation. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
  • 3333: indicates value. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
  • 4444: indicates brightness. It ranges from 0 to 1,000.
  • 5555: indicates color temperature. It ranges from 0 to 1,000.
{"27":"1007603e803e800120025"}
  • 1: gradient mode.
  • 0076: indicates hue is 0x0076.
  • 03e8: indicates saturation is 0x03E8.
  • 03e8: indicates value is 0x03E8.
  • 0012: indicates brightness is 18%.
  • 0025: indicates color temperature is 37%.

This DP and the DP mode together determines whether the music light is available for users.

DP28(9): adjust

Data type Value range Example
String 011112222333344445555
  • 0: the lighting mode.
    • 0: direct output.
    • 1: gradient mode.
  • 1111: indicates hue. It ranges from 0 to 360, corresponding to 0x0000 to 0x0168.
  • 2222: indicates saturation. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
  • 3333: indicates value. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
  • 4444: indicates brightness. It ranges from 0 to 1,000.
  • 5555: indicates color temperature. It ranges from 0 to 1,000.
{"27":"1007603e803e800120025"}
  • 1: gradient mode.
  • 0076: indicates hue is 0x0076.
  • 03e8: indicates saturation is 0x03E8.
  • 03e8: indicates value is 0x03E8.
  • 0012: indicates brightness is 18%.
  • 0025: indicates color temperature is 37%.

This DP is used to receive commands from the cloud when users control the light on the mobile app.

DP29(10): debugger

Data type Value range Example
String 011112222333344445555
  • 0: the lighting mode.
    • 0: direct output.
    • 1: gradient mode.
  • 1111: indicates hue. It ranges from 0 to 360, corresponding to 0x0000 to 0x0168.
  • 2222: indicates saturation. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
  • 3333: indicates value. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
  • 4444: indicates brightness. It ranges from 0 to 1,000.
  • 5555: indicates color temperature. It ranges from 0 to 1,000.
{"27":"1007603e803e800120025"}
  • 1: gradient mode.
  • 0076: indicates hue is 0x0076.
  • 03e8: indicates saturation is 0x03E8.
  • 03e8: indicates value is 0x03E8.
  • 0012: indicates brightness is 18%.
  • 0025: indicates color temperature is 37%.

This DP is used along with a specific debugging panel to perform gamma calibration.

Custom functions

You can add custom functions that are not supported by standard functions. For more information, see Custom Functions.

Cloud functions

Cloud function supports cloud timing and jumping page. For more information, see Cloud Functions.

  • Cloud timing: allows you to implement the schedule feature without embedded development.
  • Jumping page: enables navigating to another web page, such as an online store and user guide.