Last Updated on : 2025-07-29 03:05:05download
$ npm install @tuya/tuya-panel-protocols
// or
$ yarn add @tuya/tuya-panel-protocols
Action
encodeColorData
Description
Converts the hue, saturation, and value (HSV) color data from the decimal format to the hexadecimal format of hhhhssssvvvv.
Request parameter
| Parameter | Data type | Description | Required |
|---|---|---|---|
| h | number | The value of hue. Valid values: [0, 360]. | Yes |
| s | number | The value of saturation. Valid values: [ 0, 1000]. | Yes |
| v | number | The value of value. Valid values: [ 0, 1000]. | Yes |
Return parameter
| Parameter | Data type | Description |
|---|---|---|
| hsv | string | The HSV color data in the hexadecimal format. |
Sample request
import { lampProtocol } from '@tuya/tuya-panel-protocols';
const { ColorProtocol } = lampProtocol;
ColorProtocol.encodeColorData(h, s, v);
// Example
ColorProtocol.encodeColorData(360, 1000, 1000)
Sample response
'016803e803e8'
Action
decodeColorData
Description
Converts the hue, saturation, and value (HSV) color data from the hexadecimal format of hhhhssssvvvv to the decimal format.
Request parameter
| Parameter | Data type | Description | Required |
|---|---|---|---|
| hsv | string | The HSV color data in the hexadecimal format. | Yes |
Return parameter
| Parameter | Data type | Description |
|---|---|---|
| result | number[] | [ h: hue, s: saturation, v: value] |
Sample request
import { lampProtocol } from '@tuya/tuya-panel-protocols';
const { ColorProtocol } = lampProtocol;
ColorProtocol.decodeColorData(hsv);
// Example
ColorProtocol.decodeColorData('016803e803e8')
Sample response
[360, 1000, 1000]
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback