Function Definition

Last Updated on : 2022-03-02 02:05:46

Types of data point (DP)

Tuya IoT Platform allows you to define functions with six data types, including Boolean, value, enum, fault, string, and raw.

Bool: Binary variable (true or false), such as the function of the switch.

Value: Apply to the data that can be linearly adjusted, such as adjusting the temperature.

Enum value: A custom finite set of values, such as the high, medium, and low levels.

Fault: specified for fault report and statistics. Support Only report when multiple faults occur.

Char type: It indicates data transfer in char type.

RAW type: It indicates data transfer in a raw binary format.

Standard functions

Data point Identifier Transmission Type DP type DP property
Switch switch_led Send/report Bool -
Mode work_mode Send/report Enum The enum values include white, color, scene, and music.
Brightness bright_value Send/report Integer The value ranges from 10 to 1,000, with a pitch of 1 and a scale of 0.
Color temperature temp_value Send/report Integer The value ranges from 0 to 1,000, with a pitch of 1 and a scale of 0.
Colored light colour_data Send/report String -
Scene scene_data Send/report String -
Countdown countdown Send/report Integer The value ranges from 0 to 86400, with a pitch of 1 and a scale of 0. Unit:s.
Music music_data Send only String -
Adjust control_data Send only String -
Energy-saving switch switch_save_energy Send/report Bool -
Battery capacity battery_percentage Send/report Integer -

Description of DPs

DP20(1): on/off (required)

Type: Boolean.
Value: true/false. Turn on or turn off.
Example, {"20":true}.

DP21(2): mode (required)

Type: enum.
Value: white”/”colour”/”scene”/”music.
White light mode/color light mode/scene/music light.

Example, {"21":"scene"}.

Note: 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

Type: value.
Value: 10 to 1000.

Example: {"22":670 "}.

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%.

DP23(4): color temp

Type: value
Value: 0 to 1000.
Example: {"23":797"}.
Note: The color temperature range is from 0 to 1,000. It is defined between the coolest white and warmest white. The actual color temperature depends on the bead specifications, such as 2700K to 6500K.

DP24(5): color

Data type: string.
Value: 000011112222.
0000: H (hue: 0–360, 0X0000–0X0168).
1111: S (saturation: 0–1000, 0X0000–0X03E8).
2222: V (value: 0–1000, 0X0000–0X03E8).

Example: 1{"24":"000011112222"}1.

HSV value is 00DC, 004B, and 004E in hex format. After converting them to the decimal format, you will get 220°, 75%, 78%.

Note:Color values are output in HSV format. Alternatively, you can convert values to the RGB format. For more information, visit color conversion. You can obtain RGB (R,G,B): (HEX)(32,64,C8),(DEC)(50,100,200).

DP25(6): the scene

Data type: string.
Value: 0011223344445555666677778888.
00: the scene No.
11: the unit switch interval (0–100).
22: the unit change time (0–100).
33: the lighting mode. 0: static. 1: jumping. 2: gradient.
4444: H (hue: 0–360, 0X0000–0X0168).
5555: S (saturation: 0–1000, 0X0000–0X03E8).
6666: V (value: 0–1000, 0X0000–0X03E8).
7777: white light brightness (0–1000).
8888: temperature value (0–1000).
Note: Each digit that ranges from 1 to 8 in the preceding example specifies a unit and a group.
Example{“25”:“010b0a02000003e803e8000000000b0a02007603e803e8000000000b0a0200e703e803e800000000”}`.

01: It indicates the scene ID is 01.
0b: It indicates the transition interval between lighting modes is 0.
0a: It indicates the lighting mode duration is 10.
02: It indicates the lighting mode is gradient.
0000: It indicates hue is 0x0000.
03e8: It indicates saturation. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
03e8: It indicates value. It ranges from 0 to 1,000, corresponding to 0x0000 to 0x03E8.
0000: It indicates brightness. It ranges from 0 to 1,000.
0000: It indicates color temperature. It ranges from 0 to 1,000.

DP26(7): timer

Type: value.
Value: 0-86400.
The data unit is second, which corresponds to a value of 60 for one minute, and the maximum setting is 86400=23 hours and 59 minutes.
0: It indicates the timer is turned off.
Example: {"26":"120"} indicates 120 seconds.
120 s is 2 mins.
Note: The time delay feature is available for users only after you add this DP to your product.

DP27(8): music

Data type: string
Value: 011112222333344445555
The change mode (0: jumping. 1: gradient.)
1111: H (hue: 0–360, 0X0000–0X0168)
2222: S (saturation: 0–1000, 0X0000–0X03E8)
3333: V (value: 0–1000, 0X0000–0X03E8)
4444: indicates brightness. It ranges from 0 to 1,000.
5555: the temperature value (0–1000)
Example: {"27":"1007603e803e800120025"}

The change mode (0: jumping. 1: gradient.)
Sample description:
The change mode: 0: jumping. 1: gradient.
0076: It indicates hue is 0x0076.
03e:8: It indicates saturation is 0x03E8.
03e8: It indicates value is 0x03E8.
0012: It indicates brightness is 18%.
0025: It indicates color temperature is 37%.
Note: This DP and the DP mode together determines whether the music light is available for users.

DP28(9): adjust

Data type: string.
Value: 011112222333344445555.
The change mode (0: jumping, 1: gradient).
1111: H (hue: 0–360, 0X0000–0X0168).
2222: S (saturation: 0–1000, 0X0000–0X03E8).
3333: V (value: 0–1000, 0X0000–0X03E8).
4444: indicates brightness. It ranges from 0 to 1,000.
5555: the temperature value (0–1000)
Example: {"27":"1007603e803e800120025"}

The change mode: 0: jumping. 1: gradient.
0076: It indicates hue is 0x0076.
03e8: It indicates saturation is 0x03E8.
03e8: It indicates value is 0x03E8.
0012: It indicates brightness is 18%.
0025: It indicates color temperature is 37%.
Note: This DP is used to receive commands from the cloud when users control the light on the mobile app.

DP51: Energy-saving switch

Type: Bool.
Value: true/false. Turn on or turn off.
Example: {"51":true}.

DP 9: the battery level

Type: value.
value: 0.
Example: {"52":50 "}.

Custom functions

You can customize functions that are not supported by standard functions. Data point (DP) is the abstract representation of a function, and each function can be defined by different function types. Six data types, namely Boolean, Integer, Enum, Fault, Char type, and RAW type.

Custom DP does not support third-party voice and third-party cloud docking. If you have good suggestions for the expansion of our standard DP. It is recommended to submit a ticket. Tuya will help create standard data functions as soon as possible.

(https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/content-platform/hestia/16339205898ffc91b0ab5.png)

DP ID is synonymous with the function, and the function name is used to quickly distinguish the function represented by the function.
The identification name is the unique identity that distinguishes functions in the product software.
You can select the type according to the DPs. The Tuya IoT Platform supports six data types, including Boolean, value, enum, fault, string, and raw.

Bool: Binary variable (true or false), such as the function of the switch.
Function Definition

Value: Apply to the data that can be linearly adjusted, such as adjusting the temperature. You should set the value range, spacing, and scale value. The scale value can be set to 0, 1, 2, 3 and transmitted in the exponential conversion of 10, suitable for decimals.

Function Definition

Enum: a self-defined limited set of values, you need to set the enumeration value and confirm with Enter. It supports numbers, letters, and underscores, such as high, mid, and low gears.
Function Definition

Fault: specified for fault report and statistics. Support Only report when multiple faults occur.

Function Definition

RAW type: It indicates data transfer in a raw binary format.

Function Definition

The data transmission type is divided into send and report, send only, and report only. Select a type according to product functions and the panel.
Send and report: Command data can be sent to the device, and device data can be reported to the cloud.
Report only: Data can only be reported from the device.
Send only: Data can only be sent from the cloud.

Function Definition

Cloud functions

Cloud function: It supports cloud timing and jumping page.
Timing allows you to implement functions of on/off timer and weekly schedule without embedded hardware development.
Jumping Page: With a link, users can navigate to another page, such as the online store and user guide.
Function Definition