---
name: "number2Temp"
mode: "api"
versionRequirements:
  - { name: "", version: "1.15.0" }
title: "number2Temp"
summary: "Convert standard temp_value 0–1000 to Kelvin color temperature."
questions:
  - "Which conversion is typically needed before publishing color temp to the device?"
  - "Which hook documents precision caveats?"
---

## number2Temp

> [VERSION] v1.15.0+

### Description

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

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `temperature` | `number` | Yes | Standard color-temperature value (0–1000) |
| `schemaObj` | `Record<string, DpSchema>` | Yes | dpSchema object |

### Return Value

None


### Referenced Types

##### `interface` DpSchema

| Property | Type | Description |
| --- | --- | --- |
| `attr` | `number` | DP attribute flag bit, used to mark additional capabilities of the DP |
| `canTrigger` | `boolean` | Whether it can be used as an automation trigger condition |
| `code` | `string` | DP code, e.g., switch |
| `defaultRecommend` | `boolean` | Whether it is the default recommended DP |
| `editPermission` | `boolean` | Whether it has edit permission |
| `executable` | `boolean` | Whether it can be issued (sent downstream) |
| `extContent` | `string` | DP extension content, typically a JSON string |
| `iconname` | `string` | DP icon name |
| `id` | `string \| number` | DP ID |
| `mode` | `"rw" \| "ro" \| "wr"` | DP mode type rw: writable and reportable (read/write) ro: report-only (read-only) wr: write-only |
| `name` | `string` | DP name, typically used in voice scenarios |
| `property` | `Object` | DP attributes |
| `type` | `"raw" \| "obj"` | DP data type categories: raw for raw byte stream, obj for structured object |

##### `type` DpSchema.property

| Property | Type | Description |
| --- | --- | --- |
| `type` | `"string" \| "bool" \| "value" \| "enum" \| "bitmap" \| "raw"` | DP type |
| `range` | `string[] \| string[]` | Enum value range; present only when type = enum |
| `label` | `string[] \| string[]` | Fault label list; present only when type = bitmap |
| `maxlen` | `number` | Maximum length for fault bitmap; present only when type = bitmap |
| `unit` | `string` | Unit (type = value only) |
| `min` | `number` | Minimum value (type = value only) |
| `max` | `number` | Maximum value (type = value only) |
| `scale` | `number` | Precision (type = value only) |
| `step` | `number` | Step (type = value only) |


### Examples

#### Example

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

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