temp2Number(temperature: number, schemaObj: Record<string, DpSchema>)
Requires:
≥1.15.0
Description
Convert a Kelvin color-temperature value to a standard temp value (0–1000) for non-linear displays such as sliders.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
temperature | number | Yes | Color temperature in Kelvin (e.g., reported by color_temp_control) |
schemaObj | Record<string, DpSchema> | Yes | dpSchema object |
Return Value
Type: number
Standard color temperature value (0–1000)
Referenced Types
interface
DpSchema| Property | Type | Required | Description |
|---|---|---|---|
attr | number | No | DP attribute flag bit, used to mark additional capabilities of the DP |
canTrigger | boolean | No | Whether it can be used as an automation trigger condition |
code | string | Yes | DP code, e.g., switch |
defaultRecommend | boolean | No | Whether it is the default recommended DP |
editPermission | boolean | No | Whether it has edit permission |
executable | boolean | No | Whether it can be issued (sent downstream) |
extContent | string | No | DP extension content, typically a JSON string |
iconname | string | No | DP icon name |
id | string | number | Yes | DP ID |
mode | "rw" | "ro" | "wr" | Yes | DP mode type rw: writable and reportable (read/write) ro: report-only (read-only) wr: write-only |
name | string | Yes | DP name, typically used in voice scenarios |
| No | DP attributes | ||
type | "raw" | "obj" | Yes | DP data type categories: raw for raw byte stream, obj for structured object |