SmartDeviceModel.getDpState()

版本要求:
@ray-js/panel-sdk≥1.0.0

描述

获取智能设备功能点状态

参数

无

返回值

类型:DpState
全量功能点状态对象,key 为功能点 code,value 为功能点值,可能是 boolean、number、string

引用对象

typeDpState功能点状态对象,key 为功能点 code,value 为功能点值
export type DpState = Record<string, DpValue>;
typeDpValue功能点值类型,可能为 boolean、number、string
export type DpValue = boolean | number | string;

示例代码

示例

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