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

## SmartDeviceModel.getDevInfo

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

### Description

Get smart device information, implemented based on ty.device.getDeviceInfo

### Parameters

None


### Return Value

Type: `DevInfo`

Device info object that includes devId, name, schema, dps, isOnline, codeIds (Code→ID), idCodes (ID→Code), etc.
Note that compared with the return type of ty.device.getDeviceInfo, it adds the codeIds and idCodes fields.
In a group context, it returns GroupInfo, whose field structure differs from DeviceInfo.

**`type` DevInfo**

```typescript
export type DevInfo = Omit<
  ty.device.DeviceInfo,
  'schema' | 'panelConfig' | 'capability' | 'devAttribute'
> & {
  /**
   * dp id 与 dp code 的映射
   */
  idCodes: Record<string, string>;

  /**
   * dp code 与 dp id 的映射
   */
  codeIds: Record<string, string>;

  /**
   * 产品通讯能力标位，按二进制位运算的方式进行判断计算，如 Wi-Fi、Bluetooth、ZigBee、SigMesh 等
   *
   * - Wi-Fi (bit 0, 十进制值: 1): wifi无线
   * - Cable (bit 1, 十进制值: 2): 有线
   * - GPRS (bit 2, 十进制值: 4): 类似2g网络
   * - NB-IoT (bit 3, 十进制值: 6): 物联网卡网络
   * - Bluetooth (bit 10, 十进制值: 1024): 蓝牙单点
   * - BLEMesh (bit 11, 十进制值: 2048): 蓝牙私有mesh
   * - ZigBee (bit 12, 十进制值: 4096): 2.4g频段
   * - Infrared (bit 13, 十进制值: 8192): 红外
   * - 433 (subpieces) (bit 14, 十进制值: 16384): 433mhz
   * - SigMesh (bit 15, 十进制值: 32768): 蓝牙标准Mesh
   * - MCU (bit 16, 十进制值: 65536): mcu
   * - SMesh (bit 17, 十进制值: 131072): 类似ZigBee
   * - Cat1 (bit 20, 十进制值: 1048576): 通常使用3g网络
   * - Beacon (bit 21, 十进制值: 2097152): 蓝牙Beacon
   * - Thread (bit 25, 十进制值: 33554432): Thread能力
   */
  capability: Capability;

  /**
   * 设备能力标位，由固件上报
   * 位数含义:
   * - 第 1 位 (bit 0): 设备是否支持免配网
   * - 第 2 位 (bit 1): 设备支持 dp query 31 号协议查询
   * - 第 3 位 (bit 2): 设备是否具有本地联动能力
   * - 第 4 位 (bit 3): 设备是否支持 WIFI 扫描
   * - 第 5 位 (bit 4): 设备是否支持 Google Local Home
   * - 第 6 位 (bit 5): 设备是否支持闪电配网能力
   * - 第 7 位 (bit 6): 设备是否支持蓝牙控制
   * - 第 8 位 (bit 7): 设备是否支持安防能力
   * - 第 9 位 (bit 8): 设备是否是共享设备
   * - 第 10 位 (bit 9): 设备是否支持日出日落定时
   * - 第 11 位 (bit 10): 设备是否支持故障替换能力
   * - 第 12 位 (bit 11): 设备是否支持 OTA
   * - 第 13 位 (bit 12): 设备是否支持 WIFI 备用切换
   * - 第 15 位 (bit 14): 设备支持涂鸦标准协议
   * - 第 16 位 (bit 15): 设备支持自定义透传
   * - 第 17 位 (bit 16): 设备是否支持行业能力
   */
  devAttribute: DevAttribute;

  /**
   * 产品信息，schema，功能定义都在里面
   */
  schema: Array<DpSchema>;

  /**
   * 面板云配置
   */
  panelConfig: PanelConfig;
};
```

### Referenced Types

##### `type` DevInfo

Device information

| Property | Type | Description |
| --- | --- | --- |
| `idCodes` | `Record<string, string>` | Mapping of dp id to dp code |
| `codeIds` | `Record<string, string>` | Mapping of dp code to dp id |
| `capability` | `Capability` | Product communication capability bit flags, determined via bitwise operations, such as Wi‑Fi, Bluetooth, ZigBee, SigMesh, etc.  - Wi‑Fi (bit 0, decimal value: 1): Wi‑Fi - Cable (bit 1, decimal value: 2): Wired - GPRS (bit 2, decimal value: 4): similar to 2G networks - NB‑IoT (bit 3, decimal value: 6): IoT SIM network - Bluetooth (bit 10, decimal value: 1024): Bluetooth point‑to‑point - BLEMesh (bit 11, decimal value: 2048): proprietary Bluetooth mesh - ZigBee (bit 12, decimal value: 4096): 2.4 GHz band - Infrared (bit 13, decimal value: 8192): Infrared - 433 (subpieces) (bit 14, decimal value: 16384): 433 MHz - SigMesh (bit 15, decimal value: 32768): Bluetooth standard mesh - MCU (bit 16, decimal value: 65536): MCU - SMesh (bit 17, decimal value: 131072): similar to ZigBee - Cat1 (bit 20, decimal value: 1048576): usually uses 3G networks - Beacon (bit 21, decimal value: 2097152): Bluetooth Beacon - Thread (bit 25, decimal value: 33554432): Thread capability |
| `devAttribute` | `DevAttribute` | Device capability bit flags, reported by firmware Bit meanings: - Bit 0: Whether the device supports zero‑config networking - Bit 1: Device supports dp query protocol 31 - Bit 2: Whether the device has local automation capability - Bit 3: Whether the device supports Wi‑Fi scanning - Bit 4: Whether the device supports Google Local Home - Bit 5: Whether the device supports fast provisioning - Bit 6: Whether the device supports Bluetooth control - Bit 7: Whether the device supports security capability - Bit 8: Whether the device is a shared device - Bit 9: Whether the device supports sunrise/sunset scheduling - Bit 10: Whether the device supports fault replacement capability - Bit 11: Whether the device supports OTA - Bit 12: Whether the device supports Wi‑Fi backup switchover - Bit 14: Device supports the Tuya standard protocol - Bit 15: Device supports custom passthrough - Bit 16: Whether the device supports industry capabilities |
| `schema` | `DpSchema[]` | Product information, including schema and function definitions |
| `panelConfig` | `PanelConfig` | Panel cloud configuration |

##### `type` Capability

Product communication capability bit flags, determined via bitwise operations, such as Wi-Fi, Bluetooth, ZigBee, SigMesh, etc.

- Wi-Fi (bit 0, decimal value: 1): Wi-Fi wireless
- Cable (bit 1, decimal value: 2): Wired
- GPRS (bit 2, decimal value: 4): 2G-like network
- NB-IoT (bit 3, decimal value: 6): IoT SIM network
- Bluetooth (bit 10, decimal value: 1024): Single-point Bluetooth
- BLEMesh (bit 11, decimal value: 2048): Proprietary Bluetooth mesh
- ZigBee (bit 12, decimal value: 4096): 2.4 GHz band
- Infrared (bit 13, decimal value: 8192): Infrared
- 433 (subpieces) (bit 14, decimal value: 16384): 433 MHz
- SigMesh (bit 15, decimal value: 32768): Standard Bluetooth Mesh
- MCU (bit 16, decimal value: 65536): MCU
- SMesh (bit 17, decimal value: 131072): Similar to ZigBee
- Cat1 (bit 20, decimal value: 1048576): usually uses 3G network
- Beacon (bit 21, decimal value: 2097152): Bluetooth Beacon
- Thread (bit 25, decimal value: 33554432): Thread capability

```typescript
export type Capability = number;
```

##### `type` DevAttribute

Device capability bitmask, reported by firmware

Bit meanings:
- Bit 1 (bit 0): Whether the device supports zero-configuration networking
- Bit 2 (bit 1): Device supports dp query protocol 31
- Bit 3 (bit 2): Whether the device has local linkage capability
- Bit 4 (bit 3): Whether the device supports Wi-Fi scanning
- Bit 5 (bit 4): Whether the device supports Google Local Home
- Bit 6 (bit 5): Whether the device supports fast provisioning (Lightning pairing)
- Bit 7 (bit 6): Whether the device supports Bluetooth control
- Bit 8 (bit 7): Whether the device supports security capabilities
- Bit 9 (bit 8): Whether the device is a shared device
- Bit 10 (bit 9): Whether the device supports sunrise/sunset scheduling
- Bit 11 (bit 10): Whether the device supports fault replacement capability
- Bit 12 (bit 11): Whether the device supports OTA
- Bit 13 (bit 12): Whether the device supports Wi-Fi backup switchover
- Bit 15 (bit 14): Device supports the Tuya standard protocol
- Bit 16 (bit 15): Device supports custom passthrough
- Bit 17 (bit 16): Whether the device supports industry capabilities

```typescript
export type DevAttribute = number;
```

##### `interface` PanelConfig

| Property | Type | Description |
| --- | --- | --- |
| `bic` | `CloudConfig[]` | Cloud scheduling and navigation link configuration |
| `fun` | `FunConfig` | Feature configuration |

##### `interface` DpSchema

| Property | Type | Description |
| --- | --- | --- |
| `attr` | `number` | DP attribute flag bit, used to mark additional capabilities of the DP |
| `canTrigger` | `boolean` | Whether it can be used as an automation trigger condition |
| `code` | `string` | DP code, e.g., switch |
| `defaultRecommend` | `boolean` | Whether it is the default recommended DP |
| `editPermission` | `boolean` | Whether it has edit permission |
| `executable` | `boolean` | Whether it can be issued (sent downstream) |
| `extContent` | `string` | DP extension content, typically a JSON string |
| `iconname` | `string` | DP icon name |
| `id` | `string \| number` | DP ID |
| `mode` | `"rw" \| "ro" \| "wr"` | DP mode type rw: writable and reportable (read/write) ro: report-only (read-only) wr: write-only |
| `name` | `string` | DP name, typically used in voice scenarios |
| `property` | `Object` | DP attributes |
| `type` | `"raw" \| "obj"` | DP data type categories: raw for raw byte stream, obj for structured object |

##### `interface` JumpUrlConfig

| Property | Type | Description |
| --- | --- | --- |
| `code` | `"jump_url"` | Navigation link config code |
| `description` | `string` | Navigation link config description |
| `name` | `string` | Navigation link config name |
| `selected` | `boolean` | Whether the navigation link config is selected |

##### `interface` TimerConfig

| Property | Type | Description |
| --- | --- | --- |
| `code` | `"timer"` | Cloud schedule config code |
| `description` | `string` | Cloud schedule config description |
| `name` | `string` | Cloud schedule config name |
| `selected` | `boolean` | Whether the cloud schedule config is selected |

##### `interface` FunConfig

| Property | Type | Description |
| --- | --- | --- |
| `tyabirysr4` | `string` | Background color, currently supported only in the Tuya official mini program |
| `tyabirysr4_app` | `"follow" \| "--app-B1"` | Background color follow strategy: 'follow' means inherit from the App; otherwise, specify the App variable path to replace. Currently supported only in the Tuya official mini program |
| `tyabis5d9w` | `string` | Theme color, currently supported only in the Tuya official mini program |
| `tyabis5d9w_app` | `"follow" \| "--app-M1"` | Theme color follow strategy: 'follow' means inherit from the App; otherwise, specify the App variable path to replace. Currently supported only in the Tuya official mini program |

##### `interface` CloudConfig

| Property | Type | Description |
| --- | --- | --- |
| `jump_url` | `JumpUrlConfig` | Navigation link configuration |
| `timer` | `TimerConfig` | Cloud scheduling configuration |

##### `type` DpSchema.property

| Property | Type | Description |
| --- | --- | --- |
| `type` | `"string" \| "bool" \| "value" \| "enum" \| "bitmap" \| "raw"` | DP type |
| `range` | `string[] \| string[]` | Enum value range; present only when type = enum |
| `label` | `string[] \| string[]` | Fault label list; present only when type = bitmap |
| `maxlen` | `number` | Maximum length for fault bitmap; present only when type = bitmap |
| `unit` | `string` | Unit (type = value only) |
| `min` | `number` | Minimum value (type = value only) |
| `max` | `number` | Maximum value (type = value only) |
| `scale` | `number` | Precision (type = value only) |
| `step` | `number` | Step (type = value only) |


### Examples

#### Example

```typescript
const devInfo = device.getDevInfo();
console.log(devInfo.name);                    // Device name
console.log(devInfo.isOnline);                // Online status
console.log(devInfo.codeIds.switch_led);      // 20 (Code→ID)
console.log(devInfo.idCodes[20]);             // 'switch_led' (ID→Code)
```
