---
name: "SmartGroupModel.init"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.5.0" }
title: "init"
---

## SmartGroupModel.init

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

> 💡 Similar to SmartDeviceModel.init but for group devices.
> Devices in a group share the same DP Schema, and control commands are dispatched to all devices in the group.

### Description

Asynchronously initialize the smart group and then return its instance

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | `string` | No | Group ID; if not provided, it is automatically obtained from the mini program launch parameters |

### Return Value

Type: `Promise<SmartGroupModel>`

An initialized smart group device model instance

### Examples

#### Basic initialization.

```typescript
import { SmartGroupModel } from '@ray-js/panel-sdk';

const schema = [
  { code: 'switch_led', property: { type: 'bool' }, type: 'obj', mode: 'rw', id: 1, name: 'Switch' },
  { code: 'brightness', property: { type: 'value', min: 10, max: 1000, step: 1 }, type: 'obj', mode: 'rw', id: 2, name: 'Brightness' },
] as const;

type Schema = typeof schema;
const group = new SmartGroupModel<Schema>();
await group.init();                   // Automatically obtain groupId from miniapp launch parameters
await group.init('your-group-id');   // Or specify groupId
```
