---
name: "SmartDeviceModel.onDeviceInfoUpdated"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
---

## SmartDeviceModel.onDeviceInfoUpdated

> [VERSION] @ray-js/panel-sdk >= 1.0.0

### 描述

监听智能设备信息变更事件（包括设备名称、DP 名称等变更）

### 参数

`(listener: Function)`

| 参数 | 类型 | 必填 | 描述 |
| --- | --- | --- | --- |
| `listener` | `(data: DeviceInfoChanged) => number` | 是 | 事件回调，接收包含 deviceId、变更数据等信息的参数 |

### 返回值

无


### 引用对象

##### `type` DeviceInfoChanged

设备信息变更事件回调参数

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `deviceId` | `string` | 设备 id |
| `dps` | `DpState` | 变化的功能点数据（可能为空） |

##### `type` DpState

功能点状态对象，key 为功能点 code，value 为功能点值

```typescript
export type DpState = Record<string, DpValue>;
```

##### `type` DpValue

功能点值类型，可能为 boolean、number、string

```typescript
export type DpValue = boolean | number | string;
```


### 示例代码

#### 示例

```typescript
const id = device.onDeviceInfoUpdated((data) => {
  console.log('设备信息变更:', data.deviceId);
});
// 取消监听
device.offDeviceInfoUpdated(id);
```
