---
name: "mapMatterDpState"
mode: "api"
versionRequirements:
  - { name: "", version: "1.15.0" }
title: "mapMatterDpState"
summary: "Map Matter DP state to standard DP state (report / merge scenarios)."
questions:
  - "Is mapMatterDpState used on report or publish paths?"
  - "When is the shouldConvert argument passed?"
---

## mapMatterDpState

> [VERSION] v1.15.0+

### Method signature

```typescript
mapMatterDpState(dpState: DpState, updateDpState: DpState, dpSchema: DpSchema, shouldConvert?: boolean)
```

### Description

Map Matter DP state to standard DP state (report/merge scenario: matterDpState → standardDpState).

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `dpState` | `DpState` | Yes | Current full DP state |
| `updateDpState` | `DpState` | Yes | Subset of DPs involved in this change, used to determine which keys to convert |
| `dpSchema` | `DpSchema` | Yes | dpSchema object |
| `shouldConvert` | `boolean` | No | Whether to perform numeric conversion; defaults to true (aligned with shouldConvert semantics in the interceptor) |

### Return Value

Type: `DpState`

Converted Matter DP state

**`type` DpState**

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

### Referenced Types

##### `type` DpState

Datapoint status object, where the key is the datapoint code and the value is the datapoint value.

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

##### `interface` DpSchema

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

##### `type` DpValue

Datapoint value type, which can be boolean, number, or string.

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

##### `type` DpSchema.property

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


### Valid Values

##### `DpSchema.mode`

| Value | Description | Since |
| --- | --- | --- |
| `rw` | - | - |
| `ro` | - | - |
| `wr` | - | - |

##### `DpSchema.property.type`

| Value | Description | Since |
| --- | --- | --- |
| `string` | - | - |
| `bool` | - | - |
| `value` | - | - |
| `enum` | - | - |
| `bitmap` | - | - |
| `raw` | - | - |

##### `DpSchema.type`

| Value | Description | Since |
| --- | --- | --- |
| `raw` | - | - |
| `obj` | - | - |


### Examples

#### Example

```ts
import { createMatterKit } from '@ray-js/panel-sdk';

const matterKit = createMatterKit();
const next = matterKit.mapMatterDpState(dpState, updateDpState, dpSchema);
```
