number2Temp(temperature: number, schemaObj: Record<string, DpSchema>)

Requires:
≥1.15.0

Description

Convert a standard temp value (0–1000) to a Kelvin color-temperature value for sending to Matter color_temp_control.

Parameters

ParameterTypeRequiredDescription
temperaturenumberYesStandard color-temperature value (0–1000)
schemaObjRecord<string, DpSchema>YesdpSchema object

Return Value

Type: number
Color temperature in Kelvin

Referenced Types

interfaceDpSchema
PropertyTypeRequiredDescription
attrnumberNoDP attribute flag bit, used to mark additional capabilities of the DP
canTriggerbooleanNoWhether it can be used as an automation trigger condition
codestringYesDP code, e.g., switch
defaultRecommendbooleanNoWhether it is the default recommended DP
editPermissionbooleanNoWhether it has edit permission
executablebooleanNoWhether it can be issued (sent downstream)
extContentstringNoDP extension content, typically a JSON string
iconnamestringNoDP icon name
idstring | numberYesDP ID
mode"rw" | "ro" | "wr"YesDP mode type
rw: writable and reportable (read/write)
ro: report-only (read-only)
wr: write-only
namestringYesDP name, typically used in voice scenarios
NoDP attributes
type"raw" | "obj"YesDP data type categories: raw for raw byte stream, obj for structured object

Examples

Example

import { createMatterKit, useDpSchema } from '@ray-js/panel-sdk';

const matterKit = createMatterKit();
const dpSchema = useDpSchema();
const kelvin = matterKit.utils.number2Temp(600, dpSchema);