SmartLampAdvancedAbility.convertDp(dpCode: "color_temp_control" | "temp_value" | "bright_value", dpValue: number)

Requires:
≥1.15.0

Description

Convert a raw DP value to a display value with unit by DP; supports bright_value, temp_value, color_temp_control.

Parameters

ParameterTypeRequiredDescription
dpCode"color_temp_control" | "temp_value" | "bright_value"YesDP code
dpValuenumberYesRaw DP value

Return Value

Type: ConvertValue | null
On success, returns the display value and unit; returns { value, unit: '' } when the advanced capability is not enabled; may be null if the cloud has no valid translation. Network required.

Referenced Types

typeConvertValue
PropertyTypeDescription
valuenumberValue
unitstringUnit

Valid Values

dpCode
ValueDescriptionSince
color_temp_control--
temp_value--
bright_value--

Examples

Example

const b = await sdm.lampAdv.convertDp('bright_value', 100);
const t = await sdm.lampAdv.convertDp('temp_value', 2700);
const m = await sdm.lampAdv.convertDp('color_temp_control', 2700);

Notes

  1. This method detects whether advanced capability is enabled for the given DP code.
  2. If advanced capability is off, it returns the raw value and an empty unit.
  3. Conversion calls the cloud API ty.device.dpTranslateAdvancedCapability; network is required.
  4. On Matter devices, use color_temp_control for color temperature.
  5. On standard protocol devices, use temp_value for color temperature.
  6. Internally calls getAdvanceHighEnabled first to check capability.