---
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+

### 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 | 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 |

##### `type` DpValue

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

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

##### `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

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

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