Colored Light Protocol

Last Updated on : 2021-12-16 03:11:51download


ColourFormatter is a class method used to parse and reversely parse data points (DPs) for colored lighting. The parse method can be called to parse the hexadecimal strings reported by firmware into data structures required by device panels. The format method can be called to reversely parse object data into hexadecimal strings in line with generic protocols for colored light.

API methods


Type Required Description
String Yes The hexadecimal string.


Type Required Description
Object Yes The object of the IColour class.
declare interface IColour {
  hue?: number;
  saturation: number;
  value: number;


import { Utils, Formatter } from '@tuya/tuya-panel-lamp-sdk';

const { SupportUtils } = Utils;
const { ColourFormatter } = Formatter;

const d = new ColourFormatter()


  hue: 0, 
  saturation: 1000, 
  value: 1000