SmartDeviceModel.getDpState()

Requires:
@ray-js/panel-sdk≥1.0.0

Description

Get smart device DP status

Parameters

None

Return Value

Type: DpState
Full DP state object: keys are DP codes, values are DP values, which may be boolean, number, or string

Referenced Types

typeDpStateDatapoint status object, where the key is the datapoint code and the value is the datapoint value.
export type DpState = Record<string, DpValue>;
typeDpValueDatapoint value type, which can be boolean, number, or string.
export type DpValue = boolean | number | string;

Examples

Example

const dpState = device.getDpState();
console.log(dpState.switch_led);  // true (boolean, corresponds to bool DP)
console.log(dpState.brightness);  // 500 (number, corresponds to value DP)
console.log(dpState.work_mode);   // 'white' (string, corresponds to enum DP)