Dreamcolor String Light Template

Last Updated on : 2023-10-12 08:00:21download

This topic describes the specific functions of dreamcolor string light templates and how to use these templates. For more information, see the GitHub repository.

This project depends on TYSdk.mobile.mobileInfo.appRnVersion v5.31 or later. If the earlier app version is used, go to Tuya Panel-RN to download the required version.

Overview

The template project is a TypeScript basic template based on React Native 0.59 and can be used to create an RGB dreamcolor string light with a few simple steps. The template project supports the following features:

  • Smudge dimming
  • Dreamcolor scene
  • Sync lights with music by control from the app or local device.
  • Cloud timing
  • Countdown

The template project supports the following protocols:

  • Wi-Fi and Bluetooth combo
Dreamcolor String Light Template

Directories

This topic only describes the directories related to the scaffold. For more information about the general directory structure, see RN 0.59 TS Template.

├── src
│   ├── api // Includes multiple types of cloud API operations that are used to run the project.
│   ├── components // Includes reusable functional components that are used to run the project.
│   ├── composeLayout.tsx // Encapsulates `device events` and `device information` that are required on the panel.
│   ├── config // Includes common configuration files that are used on the panel.
│   ├── i18n // Includes configuration files to support multiple languages.
│   ├── main.tsx // The project entry files that are inherited from `NavigatorLayout`. Rewrite the `hookRoute` method to define necessary configurations, such as the background and top bar. Rewrite the `renderScene` method to control route-based navigation.
│   ├── models // Includes the code of redux.
│   ├── pages // Includes page-level components of the project.
│   ├── res // Includes local resources, such as pictures and SVG paths.
│   └── utils // Includes common utilities and methods that are used on the panel.

Service process and UI interaction

  • Open the panel and tap the switch icon on the bottom navigation bar to turn on or off the light.
  • Switch between modes: Tap the bottom navigation bar on the homepage to switch between device modes. You can configure the bottom navigation bar based on the required data points (DPs).
  • Dimming: Use the hue, saturation, and value (HSV) slider and smudge tools such as the paint bucket, smudge, and eraser to control the color of each LED on the string light, and configure the animation.
  • Music: Implement lights sync by control from the app or local device.
  • Scene: Configure four groups of scene data, including eight default scenes. The scenes can be favorited.
  • Schedule: Set a countdown for the light switch, and configure cloud timing to define scheduled tasks for the switch and light control scenes.

DP protocol

Switch (required)

Parameter Value
id 20
code switch_led
type bool
mode Report and send
value {“type”:“bool”}
description Turns on and off the light.

Mode (required)

Parameter Value
id 21
code work_mode
type enum
mode Report and send
value {“range”:[“white”,“colour”,“scene”,“music”],“type”:“enum”}
description Controls the White, Color, and Scene modes of the light. The enumeration value of the DP cannot be modified. The Music feature is unavailable on the panel.

Colorful (required)

Parameter Value
id 24
code colour_data
type string
mode Report and send
value {“type”:“string”,“maxlen”:255}
description Controls the colored light of the light. The length of the value is set to 12 bits. The HSV model is supported. Example: {“24”:“000011112222”}
  • 0000: the hue. Valid values: 0 to 360, corresponding to 0x0000 to 0x0168.
  • 1111: the saturation. Valid values: 0 to 1000, corresponding to 0x0000 to 0x03E8.
  • 2222: the value. Valid values: 0 to 1000, corresponding to 0x0000 to 0x03E8.

Dreamcolor scene (required)

Parameter Value
id 56
code rgbic_linerlight_scene
type Raw
mode Report and send
value {“type”:“string”,“maxlen”:255}
description Switches to and edits the dreamcolor scene.
  • 00: the version number.
  • 11: the scene mode number. Valid values: 200 and higher.
  • 22: the lighting mode.
  • 33: the interval.
  • 44: the lighting mode duration. Valid values: 0 to 100.
  • 55: the setting items.
  • 66: the setting item B.
  • 77: the setting item C.
  • Node 1:
    • 00: the value. Valid values: 1 to 100.
    • 1111: the hue. Valid values: 0 to 360.
    • 22: the saturation. Valid values: 1 to 100.
    • 3333: the brightness. Valid values: 10 to 1000.
    • 4444: the color temperature. Valid values: 0 to 1000.
Note: Each digit that ranges from 1 to 8 in the preceding example specifies a unit and a group.

LED quantity setting (required)

Parameter Value
id 58
code led_number_set
type Value
mode Report and send
value Valid values: 1 to 5000
Pitch: 1
Scale: 0
description The number of beads of the string light. This parameter is used to define the string length and number of segments.

Smudge dimming (required)

Parameter Value
id 61
code paint_colour_data
type Raw
mode Report and send
value -
description Modify the DPs to control the color and animation of each segment of the string light.
For a 20-segment string light, the following example shows the hexadecimal DP data sent by the panel:
  • Color + paint bucket: 00 01 00 14 00 HH SS VV
  • Red color controlled with the paint bucket: 00 01 00 14 00 00 01 03 E8 03 E8

Countdown

Parameter Value
id 26
code countdown
type Value
mode Report and send
value
  • Valid values: 0 to 86400
  • Pitch: 1
  • Scale: 0
  • Unit: seconds
description Turn the light on or off after the specified time has elapsed.

Music sync

Parameter Value
id 27
code music_data
type Value
mode Send only
value String
description Implement music sync based on the built-in sync algorithm.

Local music sync

Parameter Value
id 57
code dreamlightmic_music_data
type Value
mode Report and send
value Raw
description Use a built-in microphone to collect audio and implements music sync. Data protocol:
  • 00: the version number.
  • 11: the built-in microphone switch. Valid values: 0: off. 1: on.
  • 22: the music mode number. Valid values: 0 to 4.
  • 33: the lighting mode. The value is 00.
  • 44: the lighting mode duration. Valid values: 1 to 100.
  • 55: the sensitivity. Valid values: 1 to 100.
  • 66: the setting item A.
  • 77: the setting item B.
  • 88: the setting item C.
  • 99: the brightness. Valid values: 1 to 100.
  • Node 1:
    • 0000: the hue. Valid values: 0 to 360.
    • 11: the saturation. Valid values: 1 to 100.